
function SwitchMenu(masterdiv,topobj,obj){
	if(document.getElementById){
		var el = document.getElementById(obj);
		var topMenuClick = document.getElementById(topobj);
		var topMenuList = document.getElementById(masterdiv).getElementsByTagName("div"); 
		var ar = document.getElementById(masterdiv).getElementsByTagName("span"); 
		if(el.style.display != "block"){ 
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") ar[i].style.display = "none";
				topMenuList[i].className="menutitleClosed";
			}
			el.style.display = "block";
			topMenuClick.className="menutitleOpened";
		}else{
			el.style.display = "none";
			topMenuClick.className="menutitleClosed";
		}
	}
}

function SwitchMenu2(masterdiv,topobj,obj){
	if(document.getElementById){
		var el = document.getElementById(obj);
		var topMenuClick = document.getElementById(topobj);
		var topMenuList = document.getElementById(masterdiv).getElementsByTagName("div"); 
		var ar = document.getElementById(masterdiv).getElementsByTagName("span"); 
		if(el.style.display != "block"){ 
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") ar[i].style.display = "none";
				topMenuList[i].className="menuGreenClosed";
			}
			el.style.display = "block";
			topMenuClick.className="menuGreenOpened";
		}else{
			el.style.display = "none";
			topMenuClick.className="menuGreenClosed";
		}
	}
}

function get_cookie(Name) { 
	var search = Name + "="
	var returnvalue = "";
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(search)
		if (offset != -1) { 
			offset += search.length
			end = document.cookie.indexOf(";", offset);
			if (end == -1) end = document.cookie.length;
			returnvalue=unescape(document.cookie.substring(offset, end))
		}
	}
	return returnvalue;
}

function onloadfunction(){
	if (persistmenu=="yes"){
		var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
		var cookievalue=get_cookie(cookiename)
		if (cookievalue!="") document.getElementById(cookievalue).style.display="block"
	}
}

function savemenustate(){
	var inc=1, blockid=""
	while (document.getElementById("sub"+inc)){
		if (document.getElementById("sub"+inc).style.display=="block"){
			blockid="sub"+inc
			break
		}
		inc++
	}
	var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
	var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
	document.cookie=cookiename+"="+cookievalue
}


function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}
function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function fixHeight(divname,margin){ 
//divname: name of the div elements which you want to have fixed size
//margin: the uncalculated height of the div due to a margins or padding

     var divs,minHeight,divHeight,d; 

     // get all div elements in the document 
     divs=document.getElementsByTagName('div'); 

     contDivs=[]; 

     // initialize maximum height value 
     maxHeight=50; 

     // iterate over all div elements in the document 
	
	for(var i=0;i<divs.length;i++){ 
		if (divs[i].name==divname) {
			d=divs[i]; 
			// determine height for div element 
			if(d.offsetHeight){ 
				divHeight=d.offsetHeight; 
			} else if(d.style.pixelHeight){ 
				divHeight=d.style.pixelHeight; 
			} 
			if (divHeight>maxHeight) maxHeight=divHeight+margin;
		}
	} 
	
	for(var i=0;i<divs.length;i++){ 
		if (divs[i].name==divname) {
			d=divs[i]; 
			d.style.height=maxHeight;
		}
	} 
	
} 


//Random generator
var keylist="abcdefghijklmnopqrstuvwxyz123456789"
var temp=''

function generateRand(plength){
temp=''
for (i=0;i<plength;i++)
temp+=keylist.charAt(Math.floor(Math.random()*keylist.length))
return temp
}


function changeAction(f,formName)
{
	if (formName=='EIM Mail') {
		f.action = f.action + '&mm=' + generateRand(20);
	}
	return true;
}


//feedback form check validation
function CheckAll()
{
	if (document.feedback.name.value == ""){ 
		alert("Please enter your name");
		document.feedback.name.focus();
		return false ;
	}
	if (document.feedback.email.value == ""){
		alert("Please enter your email address");
		document.feedback.email.focus();
		return false;
	}
	if(!isEmail(document.feedback.email.value)){
		alert("The email address you entered wasn't correct \nPlease check it again");
		document.feedback.email.focus();
		return false;
	}
	if ((document.feedback.gender[0].checked == false) && (document.feedback.gender[1].checked == false)){
		alert("Please select your gender");
		document.feedback.gender.focus();
		return false;
	}
	if (document.feedback.age.value == ""){ 
	    alert("Please enter your age");
		document.feedback.age.focus() ;
	    return false ;
	}	
	if (document.feedback.city.value == ""){ 
	    alert("Please enter your city");
		document.feedback.city.focus() ;
	    return false ;
	}
	if (document.feedback.nationality.value == ""){ 
	    alert("Please enter your nationality");
		document.feedback.nationality.focus() ;
	    return false ;
	}
	if (document.feedback.subject.value == ""){ 
		document.feedback.subject.focus() ;
		alert("Please enter feedback subject");
		return false;
	}
	if (document.feedback.comments.value == ""){ 
		document.feedback.comments.focus() ;
		alert("Please enter your comments");
		return false ;
	}
  return true;	
}

function isEmail(str) 
{
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) 
  {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
    var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
    var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
    return (!r1.test(str) && r2.test(str));
}



//Disable right mouse click
/*
var clickmessage="Right click disabled on images" \nfunction disableclick(e) {\nif (document.all) {\nif (event.button==2||event.button==3) {\nif (event.srcElement.tagName=="IMG"){\nalert(clickmessage);\nreturn false;\n}\n}\n}\else if (document.layers) {\n if (e.which == 3) {\n alert(clickmessage);\n return false;\n }\n }\n else if (document.getElementById){\n if (e.which==3&&e.target.tagName=="IMG"){\n alert(clickmessage)\n return false\n }\n }\n }\n function associateimages(){\n for(i=0;i<document.images.length;i++)\n document.images[i].onmousedown=disableclick;\n }\n if (document.all)\n document.onmousedown=disableclick\n else if (document.getElementById)\n document.onmouseup=disableclick\n else if (document.layers)\n associateimages()\n
*/


//Auto Size Image

// Set the horizontal and vertical position for the popup
PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 640;
defaultHeight = 480;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;
var path = "http://10.0.5.23:17000/ejunior";
// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(300,100);');
writeln('width=300-(document.body.clientWidth-document.images[0].width);');
writeln('height=300-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
//writeln('<img name="George" src='+imageURL+' style="display:block"><br /><br />Download<br /></body></html>');
writeln('<p><br /> &nbsp;To save an image, <b>right-click</b> on the image and then select <b>Save Picture As</b></p>');
//writeln('<a href='+imageURL+'>Download</a>');
writeln('<img name="George" src='+imageURL+' width="640" height="480" style="display:block"><br /><br />');
writeln('</body></html>');
close();		
}}


//THUMBNAIL POPUP SCRIPTING ENGINE
function newWin(imgName,winName,imgWdth,imgHght,top,left){
	var wh=parseInt(imgHght)+90;
	var ww=parseInt(imgWdth)+80;
	
	var oImg = window.open("",winName,"status=no,scrollbars=1, width="+ ww +",height="+ wh +",top="+((screen.height-imgHght)/5)+",left="+((screen.width-imgWdth)/2.1));
	var markup = ('<html>\n<head>\n<title></title>\n<script type="text/javascript">\n\nfunction do_err(){\n return true\n }\n onerror=do_err;\n function no_cp()\n {\n clipboardData.clearData();setTimeout("no_cp()",100)\n }\n no_cp();\n\n<!--\n\nvar clickmessage="right click disabled on images" \nfunction disableclick(e) {\nif (document.all) {\nif (event.button==2||event.button==3) {\nif (event.srcElement.tagName=="IMG"){\nalert(clickmessage);\nreturn false;\n}\n}\n}\else if (document.layers) {\n if (e.which == 3) {\n alert(clickmessage);\n return false;\n }\n }\n else if (document.getElementById){\n if (e.which==3&&e.target.tagName=="IMG"){\n alert(clickmessage)\n return false\n }\n }\n }\n function associateimages(){\n for(i=0;i<document.images.length;i++)\n document.images[i].onmousedown=disableclick;\n }\n if (document.all)\n document.onmousedown=disableclick\n else if (document.getElementById)\n document.onmouseup=disableclick\n else if (document.layers)\n associateimages()\n\nx = 0;\n\nfunction getCnt(){\n\nvar doc = document;\nif(doc.images[0].complete){\nclearInterval(setInt);\ndoc.title = "Download Complete!";\n}else{\ndoc.title = "Loading: [" + x + "]";\nx++;\n}\n}\nvar setInt = setInterval(getCnt,10);\n\nfunction printpage(){\ndocument.getElementById("printpage").style.display="none";\n\n window.print();\n return showLayer();}\nfunction showLayer(){document.getElementById("printpage").style.display="block";} //-->\n<\/script>\n</head>\n<body onload="disableclick();">\n\n<table border=0 width=100% align=center><tr><td align=center><img src="'+ imgName +'" border="0" width="'+ imgWdth +'" height="'+ imgHght +'" alt="image.jpg" onerror="document.title=\'image not found!\';alert(\'image not found!\');self.close();" style="cursor:pointer;" /></td></tr><tr><td align=center id="printpage" display="block"><a href="javascript:printpage()">Print</a></td></tr></table>\n\n</body>\n</html>');
	//var markup = ('<html>\n<head>\n<title></title>\n<script type="text/javascript">\n<!--\n\n\nx = 0;\n\nfunction getCnt(){\n\nvar doc = document;\nif(doc.images[0].complete){\nclearInterval(setInt);\ndoc.title = "Download Complete!";\n}else{\ndoc.title = "Loading: [" + x + "]";\nx++;\n}\n}\nvar setInt = setInterval(getCnt,10);\n\nfunction printpage(){\ndocument.getElementById("printpage").style.display="none";\n\n window.print();\n return showLayer();}\nfunction showLayer(){document.getElementById("printpage").style.display="block";} //-->\n<\/script>\n</head>\n<body onload="self.focus();">\n\n<table border=0 width=100% align=center><tr><td align=center><img src="'+ imgName +'" border="0" width="'+ imgWdth +'" height="'+ imgHght +'" alt="image.jpg" onerror="document.title=\'image not found!\';alert(\'image not found!\');self.close();" style="cursor:pointer;" /></td></tr><tr><td align=center id="printpage" display="block"><a href="javascript:printpage()">Print</a></td></tr></table>\n\n</body>\n</html>');
	oImg.document.write(markup);
	oImg.document.close();
	
}




