/**
*	Utility functions will include in this library.
*
*	@author     	Himadri Shekhar Roy
*	@date   	 	March 06, 2008
*	@version 		2.0
*	@copyright 		Analyze System
*	@email			himadri.s.roy@ansysoft.com
*/

//to open browser
function MM_openBrWindow(theURL,winName,features) 
{ 
  window.open(theURL,winName,features);
}//eof

/**
*	This function will write message on the page on clicked on an input field
*	
*	@param
*			id			Div, table or span id
*			mesg		Message to display
*			tMsg		Type of the messsage
*			pathImg		Path to the image
*			alrtImg		Alert Image
*			normImg		Normal Image
*			errImg		Error message image to display
*			sucImg		Success message image to display
*			
*/
function writeMessage(id, mesg, tMsg, pathImg, errImg, sucImage, alrtImg, normImg)
{
	//declare variables
	var	id		=	id;
	var mesg	=	mesg;
	
	
	if(tMsg == 'NORMAL')
	{
		document.getElementById(id).innerHTML = "<img src='"+pathImg+normImg+"' height='15' width='15'  alt='' class='padR10' /><label class='marB5 blackLarge'>" + mesg + "</label>";
	}
	else if(tMsg == 'SUCCESS')
	{
		document.getElementById(id).innerHTML = "<img src='"+pathImg+sucImage+"' height='15' width='15'  alt='' class='padR10' /><label class='marB5 blackLarge'>" + mesg + "</label>";
	}
	else if(tMsg == 'ERROR')
	{
		document.getElementById(id).innerHTML = "<img src='"+pathImg+errImg+"' height='15' width='15'  alt='' class='padR10' /><label class='marB5 blackLarge'>" + mesg + "</label>";
	}
	else if(tMsg == 'ALERT')
	{
		document.getElementById(id).innerHTML = "<img src='"+pathImg+alrtImg+"' height='15' width='15'  alt='' class='padR10' /><label class='marB5 blackLarge'>" + mesg + "</label>";
	}
	
}//eof


/**
*	This function will write message on the page on mouse out from an input field
*/
function writeMesgOff(id)
{
	document.getElementById(id).innerHTML = '';
}

/**
*	Download CV
*/
function downloadCV(id)
{
	var downloadId = id;
	var url= "job_res_save.php?downloadId=" + escape(id);
	request.open('GET',url,true);
	//set up a function to the server when its done
	request.onreadystatechange = getCV;
	
	document.getElementById('downloadRes').innerHTML=
	"<span class='orangeLetter padT10'>" +
	"<img src='../images/icon/green_flower.gif' border='0' alt='image loading' />" + 
	"<span class='padB5'> Loading ... </span></span>";
	
	//send the request
	request.send(null);
}
function getCV()
{
	
	if(request.readyState == 4)
	{
		
		if(request.status == 200)
		{
			var xmlResponse = request.responseText;//.split("|")
			//var obj = document.getElementById('txtCountyId');
			document.getElementById("downloadRes").innerHTML = xmlResponse;
		}
		else if(request.status == 404)
		{
			alert("Request page doesn't exist");
		}
		else if(request.status == 403)
		{
			alert("Request page doesn't exist");
		}
		else
		{
			alert("Error: Status Code is " + request.statusText);
		}
	}
}

//eof

/**
*	Show hide div
*/

function showHideDiv(divId, txtId) 
{
	var divId	= divId;
	var txtId	= txtId;
	
	if (document.getElementById(divId).style.display == 'none') 
	{
		document.getElementById(divId).style.display = 'block';
		document.getElementById(txtId).innerHTML = 'Close';
	}
	else 
	{
		document.getElementById(divId).style.display = 'none';
		document.getElementById(txtId).innerHTML = 'Choose Language';
	}
}

/**
*	This function will enable another form field, once clicked on this field
*	
*	@param
*			fieldW		Field to be worked on 
*	
*	@return	boolean
*/
function enableField(fieldW)
{
	var	fieldW = fieldW;
	if(document.getElementById(fieldW).disabled == true)
	{
		document.getElementById(fieldW).disabled = false;
		document.getElementById(fieldW).style.backgroundColor  = "#EEF4FB";
	}
}//eof

/**
*	This function will disable another form field, once clicked on this field
*	
*	@param
*			fieldW		Field to be worked on 
*	
*	@return	boolean
*/
function disableField(fieldW)
{
	var	fieldW = fieldW;
	
	if(document.getElementById(fieldW).disabled == false)
	{
		document.getElementById(fieldW).disabled = true;
		document.getElementById(fieldW).style.backgroundColor  = "#E4E4E4";
	}
	
}//eof

/**
*	This function will show div
*	
*	@param
*			divId		Div to be worked on 
*	
*	@return	boolean
*/
function showDiv(divId)
{
	var	divId = divId;
	if(document.getElementById(divId).style.display == 'none')
	{
		document.getElementById(divId).style.display = 'block';
	}
}//eof

/**
*	This function will hide div
*	
*	@param
*			divId		Div to be worked on 
*	
*	@return	boolean
*/
function hideDiv(divId)
{
	var	divId = divId;
	if(document.getElementById(divId).style.display == 'block')
	{
		document.getElementById(divId).style.display = 'none';
	}
}//eof


/**
*	This function will allow text area to take maximum length allowed by admin. Below is the
*	example of how to use this function. Source: Dynamic drive.
*
*	e.g.	<textarea maxlength="40" onkeyup="return isMaxLength(this)"></textarea>
*	
*	@param
*			obj		Object fixed for max length
*	
*	@return	null
*/
function isMaxLength(obj)
{
	var mlength	=	obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : "" ;
	
	if (obj.getAttribute && obj.value.length>mlength)
	{
		obj.value=	obj.value.substring(0,mlength) ;
	}
}//eof


/**
*	Download CV
*/
function regSess(pageName)
{
	var pageName = pageName;
	var url= "reg_sess.php?regSessVar=" + escape(pageName);
	request.open('GET',url,true);
	//set up a function to the server when its done
	request.onreadystatechange = getRegSess;
	
	document.getElementById('showSess').innerHTML="";
	
	//send the request
	request.send(null);
}
function getRegSess()
{
	
	if(request.readyState == 4)
	{
		
		if(request.status == 200)
		{
			var xmlResponse = request.responseText;
			
			document.getElementById("showSess").innerHTML = xmlResponse;
		}
		else if(request.status == 404)
		{
			alert("Request page doesn't exist");
		}
		else if(request.status == 403)
		{
			alert("Request page doesn't exist");
		}
		else
		{
			alert("Error: Status Code is " + request.statusText);
		}
	}
}


/**
*	Get background color for the currently selected box in ajax driven image gallery.
*
*	@param
*			pId			Place id
*			newColor	New color to display
*			oldColor	Return to old color
*
*	@return null
*/
function getBackColor(pId, newColor, oldColor)
{
	var pId			= pId;
	var newColor	= newColor;
	var divId		= "breadCrumb_" + pId;
	
	for(i=1; i<=5; i++)
	{
		var divId		= "breadCrumb_" + i;
		document.getElementById(divId).style.backgroundColor	= oldColor;
		
		if(pId == i)
		{
			document.getElementById(divId).style.backgroundColor	= newColor;
		}
	}
	
}//eof


/**
*	Allow user to type only numerical values in the text field
*
*	@param
*			evt		Name of the event
*
*	@return boolean
*/

function intOnly(myfield, e, dec)
{
	var key;
	var keychar;
	 
	if (window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	keychar = String.fromCharCode(key);
	 
	// control keys
	if ((key==null) || (key==0) || (key==8) || 
		(key==9) || (key==13) || (key==27) )
	   return true;
	 
	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
	   return true;
	else if (((".").indexOf(keychar) > -1)){
	   if (myfield.value.indexOf(".") >-1){
		   return false;
	   }else 
	   return true;
	   }
	 
	else
	   return false;
}





<!--

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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; }
    obj.visibility=v; }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->


