
var bIsIE   = (document.all) ? true : false;
var bIsDOM  = (document.getElementById) ? true : false;

function findPosX(obj) 
{     
	var curleft = 0;     
	if (obj.offsetParent) 
	{         
		while (obj.offsetParent) 
		{             
			curleft += obj.offsetLeft             
			obj = obj.offsetParent;         
		}      
	} 
	else 
		if (obj.x)         
			curleft += obj.x;     
	
	return curleft; 
}   

function findPosY(obj) 
{     
	var curtop = 0;     
	if (obj.offsetParent) 
	{         
		while (obj.offsetParent) 
		{             
			curtop += obj.offsetTop             
			obj = obj.offsetParent;         
		}      
	} 
	else 
		if (obj.y)         
			curtop += obj.y;     
	
	return curtop; 
}


function adjustDropDownMenus() {

	var MenuWidth = new Array( 81, 75, 82 );
	
	if(bIsIE)
		var StartingPoint = findPosX( document.all.menuanchor );
	else if(bIsDOM)
		var StartingPoint = findPosX( document.getElementById( "menuanchor" ) );
		
	if(bIsIE){
		for( i=1; i<=6; i++ ){
			if( !(Tmp = eval("document.all.dropdown"+i))) break;
			Tmp.style.pixelLeft = (StartingPoint += MenuWidth[i-1]);
		}
	}
	else if(bIsDOM) {
		for( i=1; i<=6; i++ ){
			if( !document.getElementById( "dropdown"+i ) ) break;
			document.getElementById( "dropdown"+i ).style.left = (StartingPoint += MenuWidth[i-1]);
		}
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
		if ((obj=MM_findObj(args[i]))!=null) 
		{   v=args[i+2];
			if (obj.style) 
			{
				obj=obj.style;
				v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
			}
			if (obj.visibility!=v){
				obj.visibility=v;
				// start menu shim
				if( ShimObj = MM_findObj("menu_shim"+args[i].substr(8,1)) )
					ShimObj.src = (v=='visible')?"images/spacer_red.gif":"images/spacer.gif";
				// end menu shim

			}
		}
}

function hideAll(SelectedMenu){
	MM_showHideLayers('dropdown1','','hide','dropdown2','','hide','dropdown3','','hide');
}

var timerID = null;
var timerOn = false;
var timecount = 200;

var allowDropdown = false;

function startTime() {
	   allowDropdown = true;
       if (timerOn == false) {
              timerID = setTimeout( "hideAll()" , timecount);
              timerOn = true;
       }
}

function stopTime() {
       if (timerOn) {
  	        clearTimeout(timerID);
              timerID = null;
              timerOn = false;
       }
}

window.onresize = adjustDropDownMenus;

function setImgSrc( ImgObj, Filename ){
	if( !ImgObj ) return false;
	ImgObj.src = Filename;
}


function setObjectStyle( Object, StyleElement, Value ){
		eval('Object.style.'+StyleElement+' = "'+ Value +'"');
}

function setValue( Object, Value ){
	if( Object ){
		Object.value = Value;
	}
}



function popupWindow( Page, Width, Height ){
	popWindow = window.open( Page,"popWindow","width="+Width+",height="+Height+",scrollbars=1,left="+((screen.width-Width)/2)+",top="+((screen.height-Height)/2)).focus();
}
// ...................................................
// Image enlarger in popup
// ...................................................
function enlargeInPopup( Image, Width, Height ){
		window.open( Image,'','menubar=0,scrollbars=0,toolbar=0,location=0,directories=0,status=0,copyhistory=0,width='+Width+',height='+Height+',resizable=0');
}

function showImg(img,width,height){
   file="showimg.php?img="+img;
   settings="menubar=0,scrollbars=0,toolbar=0,location=0,directories=0,status=0,copyhistory=0,width="+width+",height="+height+",resizable=0"
  
   newWindow=window.open(file,'',settings);
   newWindow.moveTo( (screen.width-width)/2 , (screen.height-height)/2 );

}
