/* Talentsecure Common Scripts */
/* Copyrighted 2005 - 2010 :: TalentSecure LLC */
/* Author : Manoj babu.B */
/* Developed @ Arman Infotech Systems, Bangalore , INDIA*/
/* Created on 08-Nov-2006 */

function firstFocus(ObjID){
	var Element = document.getElementById(ObjID);
	Element.focus();
	
}
// Function for Date picker
function clickIt(value)
		{
			if (value != null &&  typeof(gfPop) != 'undefined'  &&  typeof(gfPop.fPopCalendar) != 'undefined')
			{
				gfPop.fPopCalendar(value);
			}
				return false;
		}
// Function for opening a pop up window in a new window
function newwindow(w,h,webaddress) 
	{
		var viewimageWin = window.open(webaddress,'New_Window','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=Yes,resizable=no,copyhistory=no,width='+w+',height='+h);
		viewimageWin.moveTo(screen.availWidth/2-(w/2),screen.availHeight/2-(h/2));
		viewimageWin.focus();
	}
//function for date in footer
function currentYear(){
	var d = new Date();
	var currentYear = d.getFullYear();
	var divCurrentYear=document.getElementById('divCurrentYear');
	divCurrentYear.innerHTML = currentYear;
}
function CurrentDate(){
	var d = new Date();
	var CurrentDate = d.getDate();
	var hdnToday = document.getElementById('hdnToday');
	hdnToday.value = CurrentDate;
}
// Function for Close of window on unload
function HandleOnClose() 
{
	   if (event.clientY < 0) 
			    {
			    event.returnValue = 'Are you sure you want to leave the page?';
//			    alert(event.clientY);
//			    if (event.clientY < -100)
//			    {
//			        window.open('../frmExit.aspx','Thanks','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=Yes,resizable=no,copyhistory=no,width=100,height=100');
//			    }
			}
 }	
function EndSession()
{
		if (event.clientY < 0) 
		{
			var Action = confirm("Are you sure you want to leave the page?");
			if(Action != true)
			{
				return false;	
			}
			else
			{				
				HandleOnClose();
			}
		}
}
// Function for setting maslength for a field
function setFieldMaxLength(event,cntrlName,limit) {
	var keyCod = (navigator.appName.indexOf("Microsoft")!=-1 )? event.keyCode:event.which ;
	var Elemnt = document.getElementById(cntrlName);

	if(keyCod == 8 || keyCod == 0 ) 
		return true;
	if(Elemnt.value.length>=limit) {
		alert("Maximum field length is "+limit+" char!");
		return false;
	}
	return true;
} //End of setFieldMaxLength


// Function for Cancel button
// RDPath = It is the Link to redirect the page if True
function cancelBtn(RDPath)
{
	var Action = confirm("Are you sure do you wish to cancel.");
	if (!Action == true)
	{
		return false;
	}
	else
	{
		location.href=RDPath;
		return true;
	}
}
function Reportwindow(reportPath) 
{
	//alert(reportPath);
	var w = 800;
	var h = 640;
	var reportWindow = window.open(reportPath,'report_Window','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=yes,copyhistory=no,width='+w+',height='+h+' ');
	reportWindow.focus();
}
// Function for Setting the height dynamically for <DIV> tag
function setDivHeight(divElemnt) {
		if(document.getElementById && !(document.all)) { //Handling only for Firefox
			frameHeight = parent.document.getElementById("topFrame").contentDocument.body.scrollHeight; // Inner frame ID
			frameHeight += 98; //Remove the Tabs and Buttons Height
			document.getElementById(divElemnt).style.height = frameHeight+'px';
			}
} //End of setDivHeight

// Function for setting the height dynamically for <iframe> tag
function  setDynamicHeight(frameName) {
    if(document.getElementById && !(document.all)) { //For NON-IE Browsers
        h = document.getElementById(frameName).contentDocument.body.scrollHeight;
        document.getElementById(frameName).style.height = h+20;
    }
    else if(document.all) { //For MSIE Browsers
        h = eval("window.frames."+frameName+".document.body.scrollHeight");
       //h = document.frames(frameName).document.body.scrollHeight;
	   
        document.getElementById(frameName).style.height = h+195;
    }
} //End of setDynamicHeight

// function for changing the Style of login box hover of textbox
function fnSetStyle(ctrlName,FlagAction)
	{
		if(!FlagAction)
			{
				ctrlName.className = 'LoginboxHover';
				if((ctrlName.name =='txtPWD') ||(ctrlName.name =='txtPassword'))
					document.getElementById('dvPassword').innerHTML = '';
				else
					document.getElementById('dvUserName').innerHTML = '';
			}
		else
			ctrlName.className = 'Loginbox';
	}
function checkEmpty(userName,Passwd)
	{
		if(document.getElementById(userName).value == '') {
			document.getElementById('dvUserName').innerHTML = '&nbsp;<font color="red">*</font>';
		}
		if(document.getElementById(Passwd).value == '')
			document.getElementById('dvPassword').innerHTML = '&nbsp;<font color="red">*</font>';
	}



function Money_OnKeyPress(e)
	{
		// e.keyCode - IE; e.which - Firefox
		var k = window.event ? event.keyCode : e.which;
		//k < 32  functions like 'refresh', 'backspace', 'delete' etc.
		// Only for Numbers
		
		if(k < 32 || k == 46 || k > 47 && k < 58)		
		return true;
		
		else
		return false;
	}
	
function Numeric_OnKeyPress(e)
	{
		// e.keyCode - IE; e.which - Firefox
		var k = window.event ? event.keyCode : e.which;
		//k < 32  functions like 'refresh', 'backspace', 'delete' etc.
		// Only for Numbers
		
		if(k < 32 || k > 47 && k < 58)		
		return true;
		
		else
		return false;
	}


<!--Javascript for highlighting the Datagrid rows on mouse over
function startHighlight(datagridId)
{
	
			if (document.all && document.getElementById)
			{ 
			
			 navRoot = document.getElementById(datagridId); // DatagridID
				 if(navRoot != null)
				 {
					  // Get a reference to the TBODY element 
					  tbody = navRoot.childNodes[0];		 
						
								  for (i = 0; i < tbody.childNodes.length; i++)
								  {
									node = tbody.childNodes[i];
				
										if(node.className == 'MyAlternate')
										{
												if(node.nodeName == "TR")
												{
												  node.onmouseover=function()
													  {
														this.className = "over";                
													  }
												  node.onmouseout=function()
													  {
														this.className = this.className.replace("over", "MyAlternate");
													  }
												}
										}// IF
						
										else
										{
											
												if(node.nodeName == "TR" && node.className != "MyHeader" && node.className != "MyFooterGrid")
												{
													  node.onmouseover=function()
														  {
															this.className = "over";                
														  }
													  node.onmouseout=function()
														  {
															this.className = this.className.replace("over", "");
														  }
												 }
											}//else
									}//For
						}// IF navRoot != null
				}// IF 
			}//Function