// DYNAMIC IMAGE OBJECT CONSTRUCTOR
function DynamicImage (imgName, imgOff, imgOn)
{
	var imgDir = "http://www.wizziq.co.id/images/";
	this.name = imgName;
	this.imgOff = loadImage(imgOff, imgDir);
	this.imgOn = loadImage(imgOn, imgDir);
	this.on = on;
	this.off = off;
}

// RANDOM IMAGE OBJECT CONSTRUCTOR
function RandomImage (imgName, arrayOff, arrayOn, width, height)
{
	this.name = imgName;
	this.num = getRandNum(arrayOff.length);
	this.imgOff = loadRandImage(arrayOff, this.num, width, height);
	this.imgOn = loadRandImage(arrayOn, this.num, width, height);
	this.on = on;
	this.off = off;
	this.printTag = printTag;
}

// MEMBER
function on ()
{
	document[this.name].src = this.imgOn.src;
}

// MEMBER
function off ()
{
	document[this.name].src = this.imgOff.src;
}

// MEMBER
function printTag ()
{
	document.write('<IMG NAME="' + this.name + '" SRC="' + this.imgOff.src + '" WIDTH=' + this.imgOff.width + ' HEIGHT=' + this.imgOff.height + ' BORDER=0 ALT="">');
}

// CREATE IMAGE
function loadImage (img, imgDir)
{
	//imgDir = "<?php echo $imUrl;?>images/"
	imgObject = new Image()
	imgObject.src = imgDir + img;
	return imgObject;
}

// CREATE IMAGE FROM ARRAY
function loadRandImage (imgDir, arr, i, x, y)
{
	//imgDir = "<?php echo $imUrl;?>images/";
	imgObject = new Image(x, y)
	imgObject.src = imgDir + arr[i];
	return imgObject;
}

// RETURNS RANDOM NUMBER
function getRandNum (len)
{
	randNum = parseInt(Math.random() * len);
	if (isNaN(randNum))
		randNum = 0;
	return randNum;
}

function openCalendar(params, form, field, type) {
    window.open("calendar.php?" + params, "calendar", "width=400,height=200,status=yes");
    dateField = eval("document." + form + "." + field);
    dateType = type;
}

function quickJump(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function popupWin(locationURL, lebar, tinggi) { 
	var winLeft = (screen.width - lebar) / 2;
	var winTop = (screen.height - tinggi) / 2;
	winProp = 'width='+lebar+', height='+tinggi+', top='+winTop+', left='+winLeft+', directories=no, location=no, menubar=no, scrollbars=no, status=no, toolbar=no, resizable=yes';
	window.open(locationURL, "player", winProp);
}
