﻿// JScript File

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_nbGroup(event, grpName) { //v6.0
	  var i,img,nbArr,args=MM_nbGroup.arguments;
	  if (event == "init" && args.length > 2) {
	    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
	      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
	      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
	      nbArr[nbArr.length] = img;
	      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
	        if (!img.MM_up) img.MM_up = img.src;
	        img.src = img.MM_dn = args[i+1];
	        nbArr[nbArr.length] = img;
	    } }
	  } else if (event == "over") {
	    document.MM_nbOver = nbArr = new Array();
	    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
	      if (!img.MM_up) img.MM_up = img.src;
	      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
	      nbArr[nbArr.length] = img;
	    }
	  } else if (event == "out" ) {
	    for (i=0; i < document.MM_nbOver.length; i++) {
	      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
	  } else if (event == "down") {
	    nbArr = document[grpName];
	    if (nbArr)
	      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
	    document[grpName] = nbArr = new Array();
	    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
	      if (!img.MM_up) img.MM_up = img.src;
	      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
	      nbArr[nbArr.length] = img;
	  } }
	}
	
/*********************************************** Begin bookmarksite ***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}
/*********************************************** End bookmarksite ***********************************************/

function movewin(win, width, height) 
	{
	var fullWidth = screen.availWidth;
	var fullHeight = screen.availHeight;
	var x = (fullWidth/2)-(width/2);
	var y = (fullHeight/2)-(height/2);
	win.moveTo(x,y); 
	}

	function viewWin(filenames)
	{
	
	var mybars='width=600,height=700,directories=no,location=no,menubar=no,status=no,screenX=0,screenY=0';
	mybars+=',titlebar=no,toolbar=no';
	myoptions='scrollbars=yes,resizeable=yes';
	myfeatures=mybars+ ','+myoptions
	
	var newwin=window.open(filenames,'mydoc',myfeatures);
		movewin(newwin, 600, 700);
	
	    if (navigator.appName=="Netscape") newwin.location=url;
		newwin.opener=window;
		newwin.focus();
		return false;
	}
	
	function viewWincustom(filenames,width,height)
{
	filenames=filenames;
		
	var newwin = window.open(filenames, 'Image', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,maximize=0,width='+width+',height='+height);
	
	movewin(newwin, width, height);
	    if (navigator.appName=="Netscape") 
	        newwin.location=url;
		
		newwin.opener=window;
		newwin.focus();
		return false;
}

function ajaxRating(fileid,rate,valurl) {
		
	url="/ajaxfunction.aspx?Call=rating&fileid="+fileid+"&rating="+rate+"&rateurl="+valurl+"&sid="+Math.random();
		
       var XMLhttpObj = false;
		    if (typeof XMLHttpRequest != 'undefined'){
		        XMLhttpObj = new XMLHttpRequest();
		    } else if (window.ActiveXObject){
		        	try{
		            	XMLhttpObj = new ActiveXObject('Msxml2.XMLHTTP');
		        	} catch(e) {
		            		try{
		                		XMLhttpObj = new ActiveXObject('Microsoft.XMLHTTP');
		            		} catch(e) {}
		        	}
		    }
		    if (!XMLhttpObj) return;
			
			XMLhttpObj.onreadystatechange = function() {
		    	if (XMLhttpObj.readyState == 4) { // when request is complete
		    		alertContents(XMLhttpObj.responseText);
		        }
		    };
            XMLhttpObj.open('GET', url, true);
		    try {
					XMLhttpObj.send(null);
				} catch (e) {
					alert('There was a problem with the request.');
				}

    }

    function alertContents(objData) {
        var result;
        result=objData;
				document.getElementById('rate').style.display="none";
				document.getElementById('ratethanks').style.display="block";
				//document.getElementById('ratethanks').innerHTML = result;
    }
    
    function _AjaxCallBackHandler(urlToCall,callMethod,elmDivToFill,evaluateJS){
    	if(urlToCall != ""){
	    	var XMLhttpObj = false;
			  if (typeof XMLHttpRequest != 'undefined'){
			  	XMLhttpObj = new XMLHttpRequest();
			  } else if (window.ActiveXObject){
			     	try{
			        	XMLhttpObj = new ActiveXObject('Msxml2.XMLHTTP');
			     	} catch(e) {
			       		try{
			         		XMLhttpObj = new ActiveXObject('Microsoft.XMLHTTP');
			       		} catch(e) {}
			     	}
			  }
			  if (!XMLhttpObj) return;

				XMLhttpObj.onreadystatechange = function() {
			  	if (XMLhttpObj.readyState == 4) { // when request is complete
			  			if(evaluateJS)
			  				eval(XMLhttpObj.responseText);
			  			else
			  				_AjaxResponseOnCall(XMLhttpObj.responseText,elmDivToFill);
			  	}
				};
			    
			  if(callMethod.toUpperCase()=="GET"){
			  	XMLhttpObj.open('GET', urlToCall, true);
				  try {
						XMLhttpObj.send(null);
					} catch (e) {
						alert('There was a problem with the request. Server is not responding to request');
					}
			  }
			  else if(callMethod.toUpperCase()=="POST"){
				  XMLhttpObj.open('POST', urlToCall, true);
				  XMLhttpObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				  try {
						XMLhttpObj.send("data="+postData);
					} catch (e) {
						alert('There was a problem with the request. Server is not responding to request');
					}
			 	}
			  else{
			   	alert('Calling method is not supported.');
			  }
			}
    }
    
    function _AjaxResponseOnCall(objResponse,elmDivToFill){
    	//alert(objResponse);
    	if(elmDivToFill != ""){
    		if(document.getElementById(elmDivToFill) != undefined){
    			var elm = document.getElementById(elmDivToFill);
    			elm.innerHTML = objResponse;
    			if(elm.childNodes[0].nodeName.toUpperCase == "MARQUEE")
    				elm.childNodes[0].start();
    		}
    		else
    		{
    			alert(elmDivToFill + " Object Required");
    		}
    	}
    }
    
    function JsRedirect(redirectUrl){
    	location.href = redirectUrl;
    }
    
    function JsReload(){
       	document.location.reload(true);
    //	window.opener.location.reload();
    }
    
    function logout(urlToRedirect){
    	_AjaxCallBackHandler("/ajaxFunction.aspx?Call=logout&url="+urlToRedirect+"&sid="+Math.random(),"get","",true);
    }
    
    function showhide(elmDiv){
    	var elm = document.getElementById(elmDiv);
    	if(elm.offsetHeight == 0){
    		showDiv(elmDiv,parseInt(elm.style.height));
    	}
    	else{
    		hideDiv(elmDiv,parseInt(elm.style.height));
    	}
    }
    
    function showDiv(elmDiv,objHght){
    	var obj = document.getElementById(elmDiv);
    	if(obj.offsetHeight < objHght){
    		obj.style.height = eval(obj.offsetHeight + 10) + "px";
    		obj.style.display = "block";
    		obj.style.visibility = "visible";
    		setTimeout("showDiv('"+elmDiv+"',"+objHght+")",0);
    	}
    }
    
    function hideDiv(elmDiv,objHght){
    	var obj = document.getElementById(elmDiv);
    	if(obj.offsetHeight > 0){
    		if(eval(obj.offsetHeight - 10)>10)
    			obj.style.height = eval(obj.offsetHeight - 10) + "px";
    		else
    			obj.style.height = 0 + "px";
    		setTimeout("hideDiv('"+elmDiv+"',"+objHght+")",0);
    	}
    	else
    	{
    		obj.style.display = "none";
    		obj.style.visibility = "hidden";
    		obj.style.height = objHght + "px";
    	}
    }
   
function validateTime(elmId,val){
	if(val == ""){
		return false;
	}
	var elm = document.getElementById(elmId);
	//alert(elmId);
	var validItems = "0123456789:";
	intvaluelen = val.length;
	for(j=0;j<intvaluelen;j++)
	{
		var ch = val.charAt(j);
		if(validItems.indexOf(ch) == -1)
		{
			elm.className = "errborder";
			elm.select();
			return false;
		}
	}
	elm.className = "none";
	var hours;
	var minutes;
	if(val.indexOf(":")>-1){
		hours = val.substr(0,val.indexOf(":"));
		minutes = val.substr(val.indexOf(":")+1);
	}
	else
	{
		hours=val.substr(0,2);
		minutes=val.substr(2,2);
	}
		
	if(hours>=24){
		elm.className = "errborder";
		elm.select();
		return false;
	}
	if(minutes>=60){
		elm.className = "errborder";
		elm.select();
		return false;
	}
	elm.className = "none";
	if(hours == ""){
		hours = "00";
	}
	else if(hours.length<2){
		hours = "0" + hours;
	}
	if(minutes == ""){
		minutes = "00";
	}
	else if(minutes.length<2){
		minutes = minutes + "0";
	}
	
	elm.value = hours+":"+minutes;
	return true;
}
   	
function AjaxSearchResults(article,from,keysearch,vacancy,currentpage) {
		
	url="/ajaxfunction.aspx?Call="+article+"&from="+from+"&keyword="+keysearch+"&vacancies="+vacancy+"&currentpage="+currentpage+"&sid="+Math.random();
	
    var XMLhttpObj = false;
    if (typeof XMLHttpRequest != 'undefined'){
        XMLhttpObj = new XMLHttpRequest();
    } else if (window.ActiveXObject){
        	try{
            	XMLhttpObj = new ActiveXObject('Msxml2.XMLHTTP');
        	} catch(e) {
            		try{
                		XMLhttpObj = new ActiveXObject('Microsoft.XMLHTTP');
            		} catch(e) {}
        	}
    }
    if (!XMLhttpObj) return;
	
	XMLhttpObj.onreadystatechange = function() {
    	if (XMLhttpObj.readyState == 4) { // when request is complete
    		alertResultContent(XMLhttpObj.responseText,article);
    		window.scrollTo(0,0);
    		        }
    };
         XMLhttpObj.open('GET', url, true);
    try {
			XMLhttpObj.send(null);
		} catch (e) {
			alert('There was a problem with the request.');
		}
//document.body.scrollTop=0;

 }

function alertResultContent(objData,article) {
    var result;
    result=objData;
    //alert(result);
		document.getElementById(article).innerHTML=result;
}