/**
*	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