var isloaded=false;

var PageMenuImages = [];
PageMenuImages['PAGE_COMPANY']='menu1';
PageMenuImages['PAGE_DESTINATION']='menu2';
PageMenuImages['PAGE_SERVICES']='menu3';
PageMenuImages['PAGE_CLIENTS']='menu4';
PageMenuImages['PAGE_NEWS']='menu5';
PageMenuImages['PAGE_GALLERY']='menu6';
PageMenuImages['PAGE_LINKS']='menu7';
PageMenuImages['PAGE_CONTACT']='menu8';

function preloadimages(){
	for (i=0;i<preloadimages.arguments.length;i++){
		myimages[i]=new Image()
		myimages[i].src=preloadimages.arguments[i]
	}
}

function SelectedImagePage(page)
{
	var myimg=PageMenuImages[page];
	document.getElementById(myimg).setAttribute('src','img/'+myimg+'_on.gif');
	document.getElementById(myimg).setAttribute('onmouseout','');
}


function changeIm(imid,flag) 
{  
	if(isloaded==true) {
			  var im= (!flag) ? imid+'.gif' : imid+'_on.gif' ; 		
			  document.getElementById(imid).setAttribute('src','img/'+im);	
			  if(flag)
				document.getElementById(imid).style.cursor="hand";
			  else
			    	document.getElementById(imid).style.cursor="arrow";
	}
}

function enlarge(id) 
{
	 
	URL = "thumbnail.php?imgid="+id+"&resize=0";
	winPopUp = window.open(URL,"Image","directories=no, location=no, menubar=no, resizable=1, status=0, scrollbars=1, titlebar=no, toolbar=no, width=500, height=300");
	winPopUp.focus();
}
							
function inf(t) {
	if (t==0) 
		document.login.username.value='';  
	else if (t==1)  
		document.login.password.value=''; 	
}

function outf(t) {  
	if (t==0) {
		if(document.login.username.value=='')  
			document.login.username.value='username';  
	} else if (t==1) { 
		if(document.login.password.value=='')  
			document.login.password.value='password'; 
			
	}
}

function opensub(sc) {
    var subcat= 'S'+sc;
    var stl=parent.frames[0].document.getElementById(subcat).style;	

	if(stl.visibility=='visible' && stl.position=='relative')
	{
	stl.visibility ='hidden';
	stl.position = 'absolute';
	}
	else {
	stl.visibility ='visible';
	stl.position = 'relative';
	}
}

function closerest(sc) {
	for(var i=0; i<3; i++) 
	{
	     var ids='S'+i;
	     if(ids!=sc) 
	     {
			var stl=parent.frames[0].document.getElementById(ids).style;

			if(stl.visibility=='visible' && stl.position=='relative')
			{
			stl.visibility ='hidden';
			stl.position = 'absolute';
			}

	     }
	}
}

<!-------Preview Functions---->
function Preview(imgid,title,w,h) 
{	
	if (document.compatMode && document.compatMode != "BackCompat")
	{
	   theY = document.documentElement.clientHeight;
	   theX = document.documentElement.clientWidth;
	}else {
	   theX = document.body.clientWidth;
   	   theY = document.body.clientHeight;
	}

	var x=theX;
	var y=theY;
	var top = (y-h)/4;
	var left = (x-w)/2;

	if(h+top>theY)
	{
		var res="&resize="+(w*3/5);
		left = (x-w*3/5)/2;
		top = (y-h*3/5)/4;
	}else
		var res="";
		
	var URL = "thumbnail.php?imgid="+imgid+res;

	var htmlc;
	htmlc  = '<div id="FrameTheme" style=" width:'+screen.width+'px; height:'+screen.height+'px; ">&nbsp;</div>';
	htmlc += '<div id="FrameImg" style=" top:'+top+'px; left:'+left+'px; "  onClick="ClosePreviewImage();" align="center" valign="middle">';
	htmlc += '<table><tr>';
	htmlc += '<td colspan="2"><div id="photoholder"><img width="'+w+'" height="'+h+'" src="'+URL+'" border="0" id="thephoto"></div></td>';
	htmlc += '<tr><tr>'; 
	htmlc += '<td align="left">'+title+'</td>';
	htmlc += '<td align="right"><a href="#" onClick="ClosePreviewImage(); return false">close</a> or Esc Key</td>';
	htmlc += '<tr></table></div>';
	document.getElementById('Preview').innerHTML=htmlc;
	//Hide Scrolling bars
	document.body.style.overflow='hidden';
	document.body.scroll='no';
}

document.onkeypress = function(e) 
{
    e = e||window.event||{}
    var key = e.keyCode||e.charCode
    var target = e.target||e.srcElement||window
    if (key == 27 && target.type != 'text') 
    	ClosePreviewImage();
}


function ClosePreviewImage()
{
	var FrameTheme = document.getElementById('FrameTheme');
	var FrameImg = document.getElementById('FrameImg');
	
	if(FrameTheme!=null)
	{
		FrameTheme.style.visibility='hidden'; 
		FrameTheme.style.width='auto';	
	}
		
	if(FrameImg!=null)
	{
		FrameImg.style.visibility='hidden';
		FrameImg.style.width='auto';	
	}
		
	//Unhide Scrolling bars	

	document.body.style.overflow='';
	document.body.scroll='yes';
}