/*---------------------------------------------------
| Copyright (c) 2007-2010 Arman Infotech Systems	|
| Project : HPRO									|
| Author  : B.Manojbabu			   					|
| Company : Arman Infotech Systems,Bangalore ,INDIA |
---------------------------------------------------*/

// Function for Opening a popup window in center of a screen
function newwindow(w,h,webaddress) 
{
	var viewimageWin = window.open(webaddress,'New_Window','toolbar=yes,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 picker
function clickIt(value)
		{
			if (value != null &&  typeof(gfPop) != 'undefined'  &&  typeof(gfPop.fPopCalendar) != 'undefined')
			{
				gfPop.fPopCalendar(value);
			}
				return false;
		}
//Function for setting the focus on Body Load.
function firstFocus(ObjID){
	var Element = document.getElementById(ObjID);
	Element.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 for setting maxlength 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+" chars!");
		return false;
	}
	return true;
} //End of setFieldMaxLength

// Function for Membership type in New registration form.
function fnCheckType(){
	
	var MemberType = '<% = request.QueryString("Type") %>'
	var tblPersonalInfo = document.getElementById('tblPersonalInfo');
	var tblCreditInfo = document.getElementById('tblCreditInfo');
	if(MemberType == 'Free')
	{
		tblPersonalInfo.style.display='';
	}
	else if(MemberType == 'Paid')
	{
		tblPersonalInfo.style.display='';
		tblCreditInfo.style.display='';
	}
}
// Function for AgreementCheck in New registration form.
function fnAgreementCheck(){
	var chkAgree = document.getElementById('chkAgree');
	var btnRegister = document.getElementById('btnRegister');
	
	if(chkAgree.checked == true)
	{
		btnRegister.disabled = false;
		btnRegister.className = 'btn';
	}
	else
	{
		btnRegister.disabled = true;
		btnRegister.className = 'btnDisabled';
	}
}
// Function for Word Verification in New registration form.

function fnWordVerify()	{
	var imgVerify = document.getElementById('imgVerify');
	var hdnWordVerify = document.getElementById('hdnWordVerify');
	var currIndex = Math.floor(Math.random( ) * (698154));
	var currIndexTotal = "" + ((currIndex)*5); // "" is used to avoid the integer values.
	hdnWordVerify.value = currIndexTotal;		
		for(var i=0; i<=currIndexTotal.length-1; i++)
		{
			imgVerify.innerHTML += "<img src='Images/MemberCode/" + currIndexTotal.charAt(i) + ".gif'>";
			
		}
}
// Function for Displaying the Table in Forget password.

function fnShowPQuestion(Obj){
	var tblPHintQuestion = document.getElementById('tblPHintQuestion');
	if(Obj == "Show")
		tblPHintQuestion.style.display = '';
	else
		tblPHintQuestion.style.display = 'none';
}

<!--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 != "GridHeader" && 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
function spaceKeypress(ctrl)
	{
		// e.keyCode - IE; e.which - Firefox
		var k = window.event ? event.keyCode : event.which;
		
		// to avoid space in first place
		if(obj.value.length == 0) if (k == 32) return false;
		
		return true;
	}
function Alphabets_OnKeyPress(obj, e)
	{
		// e.keyCode - IE; e.which - Firefox
		var k = window.event ? event.keyCode : e.which;
		// functions like 'refresh', 'backspace', 'delete' etc.
		if (k < 32) return true;
		// to avoid space in first place
		if(obj.value.length == 0) if (k == 32) return false;
		if ((k > 32 && k< 39) || (k > 39 && k < 65) || (k > 90 && k < 97)) return false; 
		return true;
	}
function Numeric_OnKeyPress(e)
	{
		// e.keyCode - IE; e.which - Firefox
		var k = window.event ? event.keyCode : e.which;
		
		// functions like 'refresh', 'backspace', 'delete' etc.
		if (k < 32) return true;
		// Only for Numbers
		if (k < 48 || k > 57) return false; 
		
		return true;
	}
// Script for Redirecting auomatically within specify Timeline
			var count=5;
			var fredlayer;
			function countdown()
			{				
				count--; 
				changelayer_content(count);					
				if (count>0)
					Id = window.setTimeout("countdown()",1000); 		
				else 
					document.location.href='Default.aspx';
				
			}			
			function Membercountdown()
			{				
				count--; 
				changelayer_content(count);					
				if (count>0)
					Id = window.setTimeout("Membercountdown()",1000); 		
				else 
					document.location.href='MembersHome.aspx';
				
			}	
			function changelayer_content(counter)
			{
				msgstring="<FONT color=#e40000 size=1pt> "+counter+"</Font>";
			if(document.layers)
			{
				//thisbrowser="NN4";
				fredlayer = document.layers[0];
				fredlayer.document.open();
				fredlayer.document.write(msgstring);
				fredlayer.document.close();
			}			
			if(document.all)
			{
				//thisbrowser="ie"
				fredlayer = document.all["fred"];
				fredlayer.innerHTML=msgstring;
			}			
			if(!document.all && document.getElementById)
			{
				//thisbrowser="NN6";
				fredlayer = document.getElementById("fred");
				fredlayer.innerHTML =msgstring;
			}
		}
// Function for Cancel 
// PageName -  object Name where to be redirected
function fnCancel(pageName){
	var Action = confirm("All unsaved data will be lost!. Do you wish to cancel?");
	if(Action ==  true)
		location.href = pageName ;
	else
		return false;			
}
// Function for Bookmarking the Page.
function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
	   window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    	window.sidebar.addPanel(title,url,"");
  } else {
   	 alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}
// Function for fnLogOff
	function fnLogOff(){
		var Action = confirm("Are you sure, that you wish to Logoff from the Application?");
		if (Action == true)
		{
			window.location.href ='Logout.aspx';
		}
		else
		{
			return false;
		}
	}
		
// validation for  Credit Card
function formatCardNumber(event,elementId,e) 
{
	// e.keyCode - IE; e.which - Firefox
	var k = window.event ? event.keyCode : e.which;
	// functions like 'refresh', 'backspace', 'delete' etc.
	if (k < 32) return true;
	{
	//if(isNum(event)) 
		if (k < 48 || k > 57) 
		{
			return false;
		}
		else
		{
			var secondDelimter = 9;
			var ThirdDelimter = 14;
			var Elemnt = document.getElementById(elementId);
			 var CardType = document.getElementById('ddlPaymentMethod');
			if(CardType.value == 'American Express')
					{
						Elemnt.maxLength = 18;
						CCLen = 18;
					}
			else
				{
					Elemnt.maxLength = 19;
					CCLen = 19;
						}
			if(Elemnt.value.length > 0 && (Elemnt.value.length== 4 || Elemnt.value.length== secondDelimter || Elemnt.value.length== ThirdDelimter))
					Elemnt.value = Elemnt.value + " ";
			
		}
	}
	
	return true;
} //End of formatCardNumber


function isValidCardNumber(elementId,maxLength,msg) 
{
	 var Elemnt = document.getElementById(elementId);
	 var CardType = document.getElementById('ddlPaymentMethod').value;
		
		if(Elemnt.value.length == 0)
			return true;
		if(CardType == 'American Express')
			{
				Elemnt.maxLength = 18;
				CCLen = 18;
			}
		else
			{
				Elemnt.maxLength = 19;
				CCLen = 19;
			}
		//alert(CCLen.length);
		if((Elemnt.value.length < CCLen) || (Elemnt.value.length > maxLength) ) 
		{
				alert(msg);
				Elemnt.value = '';
				setTimeout(function(){Elemnt.focus()}, 10);
		}
	
	else
	{
		return true;
	}
} // End of isValidCardNumber

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();
}
			