//************************* FILE DETAILS *************************
//Description:			Netresort main.js
//Last Modified:			20/08/2005
//Programmer:			George Milios
//************************* END OF FILE DETAILS ******************

function PSBcatid(frmName,frmFieldName,a){
	var frm= eval("document." + frmName);
	var frmext= eval("document." + frmName + "." + frmFieldName);
	frmext.value=a;
    frm.submit();
	return true;
}

//CHECK BROWSER TYPE
isNav = false;
newerBrowser = false;
NavName = navigator.appName.substring(0,3);
var imgpath='/images/main/portal/';

if ( parseInt( navigator.appVersion ) >= 4 ) {
  newerBrowser = true;
  if ( NavName == "Net" ) {
    isNav = true;
  }
}
//END OF CHECK BROWSER TYPE

// LOADING TIME
if (NavName != "Mic" || newerBrowser) {
	entree = new Date;
	entree = entree.getTime();
}

//Preload

function preloadImages(the_images_array){
   for(var loop = 0; loop < the_images_array.length; loop++){
	var an_image = new Image();
	an_image.src = imgpath+the_images_array[loop]+".gif";
   }
   	var an_image = new Image();
	an_image.src = "/images/spacer.gif";
}

function doPreload() {
	var the_images = new Array('home_off','subscribe_off','newsletter_off','tellafriend_off','buygames_off','help_off','myprofile_off','newsletter_info','tellafriend_info','buygames_info','help_info','myprofile_info');
	preloadImages(the_images);
}
//doPreload();
//End of Preload

//CONVERT INTO APPROPRIATE SIZE DEPENDING TO RESOLUTION
var stat=0
var defaultsize=778
var defaultdifference=15	
function tbl_Dim() {
	var tbl = (window.document.getElementById("tbl"));
	var innertbl = (window.document.getElementById("innertbl"));
	var innertd = (window.document.getElementById("innertd"));
	var innertd1 = (window.document.getElementById("innertd1"));
 	var picsize = (window.document.getElementById("picsize"));
	if(stat == 0) {	
		if ( isNav ){
			if ((window.innerWidth-defaultdifference < 1 )  || (window.innerWidth<defaultsize))
				tbl.width = defaultsize;
			else			
				tbl.width = window.innerWidth-defaultdifference;
			innertbl.width = tbl.width;
		}
    		else {
			if ((document.body.clientWidth-defaultdifference <1) || (document.body.clientWidth<defaultsize))
				tbl.width = defaultsize;
			else
				tbl.width = document.body.clientWidth-defaultdifference;
			innertbl.width = tbl.width;
		}  
  	 	stat = 1;
	}
  	else {
		tbl.width = defaultsize;
		innertbl.width = defaultsize;
		stat = 0; 
 	}
	if(stat == 0) {
		innertd.width=1;
		innertd1.width=1;
 		picsize.src= imgpath + "stretch_button.gif";
		picsize.alt="Click Here to stretch the page";	
	}
	else {
		if (tbl.width-defaultsize+defaultdifference < 1)
			innertd.width=1;
		else {
			innertd.width = Math.round((tbl.width-defaultsize+defaultdifference)/2);
		}		
		innertd1.width = innertd.width;
		picsize.src= imgpath + "unstretch_button.gif";
		picsize.alt="Click Here to lock the width of the page";
	}

}
//END OF CONVERT INTO APPROPRIATE SIZE DEPENDING TO RESOLUTION


//DYNAMICALLY CHANGE CSS
function change(getcolor)
{
	myRE = new RegExp("changebgcolor", "i");
	myRE1 = new RegExp("changecolor", "i");
	myRE2 = new RegExp("changelncolor", "i");
	document.body.style.scrollbarFaceColor=getcolor;
	document.body.style.scrollbarArrowColor=getcolor;
	document.body.style.scrollbarTrackColor=getcolor;
	document.body.style.scrollbarShadowColor=getcolor;
	document.body.style.scrollbarHighlightColor=getcolor;
	document.body.style.scrollbar3dlightColor=getcolor;
	document.body.style.scrollbarDarkshadowColor=getcolor;
	if(document.getElementsByTagName)//check for obj
   	{
		var nodes = document.getElementsByTagName('td');
		var max = nodes.length;

		for(var i = 0;i < max;i++)
      		{
				var nodeObj = nodes.item(i);
      			var attrMax = nodeObj.attributes.length;	
				for(var j = 0; j < attrMax; j++)
				{
					if(nodeObj.attributes.item(j).nodeName == 'class')
					{
						if (nodeObj.attributes.item(j).nodeValue != null)
						{
							if(nodeObj.attributes.item(j).nodeValue.match(myRE) == "changebgcolor")
								{
								nodeObj.style.backgroundColor = getcolor;
								}
							if(nodeObj.attributes.item(j).nodeValue.match(myRE1) == "changecolor")
								nodeObj.style.color = getcolor;
							if(nodeObj.attributes.item(j).nodeValue.match(myRE2) == "changelncolor")
								nodeObj:hover.style.color = getcolor;
						}

					}
				}
			}

		
	}
}
//END OF DYNAMICALLY CHANGE CSS

//SWAPPING IMAGES
function imgSwap(daImage, pos, layer) {
	if (document.images) {
		if (layer != null && document.layers) {
			objStr = 'document.layers[layer].document.layers[0].document.' + daImage;
		} else {
			objStr = 'document.' + daImage;
		}
		obj = eval(objStr);
		obj.src = imgpath+daImage+(pos == 0 ? "_off" : "_on")+".gif";
	}
}
//END OF SWAPPING IMAGES


function showElement(element) {
	if (element) {
		if (isNav && !newerBrowser) {
			document.eval(element).visibility='show';
			} 
		else {
			document.getElementById(element).style.visibility='visible';
		}
	}
}

function hideElement(element) {
        if (element) {
                if (isNav && !newerBrowser) document.eval(element).visibility='hide'; else document.getElementById(element).style.visibility='hidden'
        }
}

function ZsortIe() {
	if (NavName != "Mic" || newerBrowser) {
		fin = new Date;
		fin = fin.getTime();
		secondes = (fin-entree)/1000;
		window.status='Page loading in ' + secondes + ' secondes.';
	}
}