

function validatefaq()
{
	if (document.frmFaq.search.value == "")
	{
		alert("Enter text for search");
		document.frmFaq.search.focus();
		return false;
	}
	frmFaq.action="faqdetails.aspx?flag=2&search="+document.frmFaq.search.value;
	return true;
}
function ValidateContactUs()
{
	var strd;
	var emailPat = /^[A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)*[@][A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)+$/
	var matchArray = document.Form1.Contactus2_txtEmail.value.match(emailPat);
	if(document.Form1.Contactus2_txtFname.value=="" )
	{
		strd = document.Form1.MRF1.value;
		alert(strd);
		document.Form1.Contactus2_txtFname.focus();
		return false;
	}
	
	if(document.Form1.Contactus2_txtFname.value.charAt(0)==' ')
	{  
		 strd = document.Form1.MRF8.value;
		 alert(strd);
		 document.Form1.Contactus2_txtFname.focus();
		 return false;
	}	
	if(document.Form1.Contactus2_txtLName.value=="" )
	{
		strd = document.Form1.MRF2.value;
		alert(strd);
		document.Form1.Contactus2_txtLName.focus();
		return false;
	}
	
	if(document.Form1.Contactus2_txtLName.value.charAt(0)==' ')
	{  
		 strd = document.Form1.MRF8.value;
		 alert(strd);
		 document.Form1.Contactus2_txtLName.focus();
		 return false;
	}	
	
	if(document.Form1.Contactus2_txtEmail.value=="")
	{
	    strd = document.Form1.MRF3.value;
		alert(strd);		
		document.Form1.Contactus2_txtEmail.focus();
		return false;
	}
	else if (matchArray == null)
	{
		strd = document.Form1.MRF4.value;
		alert(strd);
		document.Form1.Contactus2_txtEmail.focus();
		return false;
	}	
	if(document.Form1.Contactus2_txtComments.value=="")
	{
	    strd = document.Form1.MRF5.value;
		alert(strd);
		document.Form1.Contactus2_txtComments.focus();
		return false;		
	}	
	if(document.Form1.Contactus2_txtComments.value.charAt(0)==' ')
	{  
	    strd = document.Form1.MRF8.value;
		alert(strd);
	    document.Form1.Contactus2_txtComments.focus();
		return false;
    }
	if(document.Form1.Contactus2_txtComments.value.length > 250)
	 {
		strd = document.Form1.MRF6.value;
		alert(strd);
		document.Form1.Contactus2_txtComments.focus();
		return false; 
	}	
	if(document.Form1.Contactus2_CodeNumberTextBox.value=="")
	{
		strd = document.Form1.MRF7.value;
		alert(strd);
		document.Form1.Contactus2_CodeNumberTextBox.focus();
		return false;
	}
	if(document.Form1.Contactus2_CodeNumberTextBox.value.charAt(0)==' ')
	{  
	    strd = document.Form1.MRF8.value;
		alert(strd);
	    document.Form1.Contactus2_CodeNumberTextBox.focus();
		return false;
    }
	return true;	
}
function ValidateFaqDetails()
{
	var emailPat = /^[A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)*[@][A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)+$/
	var matchArray = Form1.TextBox2.value.match(emailPat);
	if(document.Form1.TextBox2.value=="")
	{
		alert("Email required");
		document.Form1.TextBox2.focus();
		return false;
	}
	else if (matchArray == null)
	{
		alert("Invalid Email format");
		document.Form1.TextBox2.focus();
		return false;
	}
	if(document.Form1.txtArea.value=="")
	{
		alert("Question required");
		document.Form1.txtArea.focus();
		return false;
	}
	return true;
}
function ValidateProfile()
{
	var strd;
 	var emailPat = /^[A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)*[@][A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)+$/;
	var matchArray = document.Form2.Profile1_txtEmail.value.match(emailPat);
	if(document.Form2.Profile1_txtUserName.value=="")
	{
		strd = document.Form2.MRF1.value;
		alert(strd);
		document.Form2.Profile1_txtUserName.focus();
		return false;
	}
	if(document.Form2.Profile1_txtUserName.value.charAt(0)==' ')
	{   
		strd = document.Form2.MRF2.value;
		alert(strd);
		document.Form2.Profile1_txtUserName.focus();
		return false; 
    }
    if(document.Form2.Profile1_txtPassword.value=="")
	{
		strd = document.Form2.MRF3.value;
		alert(strd);
		document.Form2.Profile1_txtPassword.focus();
		return false;
	}
	if(document.Form2.Profile1_txtPassword.value.charAt(0)==' ')
	{    
		strd = document.Form2.MRF2.value;
		alert(strd);
		document.Form2.Profile1_txtPassword.focus();
		return false;
	}
	if(document.Form2.Profile1_txtConfrimPass.value=="")
	{
		strd = document.Form2.MRF4.value;
		alert(strd);
		document.Form2.Profile1_txtConfrimPass.focus();
		return false;
	}
	if(document.Form2.Profile1_txtConfrimPass.value.charAt(0)==' ')
	{    
		strd = document.Form2.MRF2.value;
		alert(strd);
		document.Form2.Profile1_txtConfrimPass.focus();
		return false;
	}
	if (document.Form2.Profile1_txtPassword.value!=document.Form2.Profile1_txtConfrimPass.value)
	{  
		strd=document.Form2.MRF5.value;
		alert(strd);
		document.Form2.Profile1_txtConfrimPass.focus();
		return false;
	}
	if(document.Form2.Profile1_txtMobile.value=="")
	{
		strd = document.Form2.MRF11.value;
		alert(strd);
		document.Form2.Profile1_txtMobile.focus();
		return false;
	}
	if(document.Form2.Profile1_txtMobile.value.charAt(0)==' ')
	{   
		strd = document.Form2.MRF2.value;
		alert(strd);
		document.Form2.Profile1_txtMobile.focus();
		return false; 
    }
		
	if(document.Form2.Profile1_txtEmail.value=="")
	{
		strd=document.Form2.MRF6.value;
		alert(strd);
		document.Form2.Profile1_txtEmail.focus();
		return false;
	}
	else if (matchArray == null)
	{
		strd=document.Form2.MRF7.value;
		alert(strd);
		document.Form2.Profile1_txtEmail.focus();
		return false;
	}	
	if(document.Form2.Profile1_txtLName.value=="")
	{  
		strd = document.Form2.MRF9.value;
		alert(strd);
		document.Form2.Profile1_txtLName.focus();
		return false;
	}
	if(document.Form2.Profile1_txtLName.value.charAt(0)==' ')
	{   
		strd = document.Form2.MRF2.value;
		alert(strd);
		document.Form2.Profile1_txtLName.focus();
		return false;
	}	
	if(document.Form2.Profile1_txtFName.value=="")
	{  
		strd = document.Form2.MRF8.value;
		alert(strd);
		document.Form2.Profile1_txtFName.focus();
		return false;
	}
	if(document.Form2.Profile1_txtFName.value.charAt(0)==' ')
	{   
		strd = document.Form2.MRF2.value;
		alert(strd);
		document.Form2.Profile1_txtFName.focus();
		return false;
	}	
	
	if(document.Form2.Profile1_txtdescription.value=="")
	{
		strd = document.Form2.MRF10.value;
		alert(strd);
		document.Form2.Profile1_txtdescription.focus();
		return false;
	}
	if(document.Form2.Profile1_txtdescription.value.charAt(0)==' ')
	{  
	    strd = document.Form2.MRF2.value;
		alert(strd);
		document.Form2.Profile1_txtdescription.focus(); 
		return false;
	}
	
	if(document.Form2.Profile1_CodeNumberTextBox.value=="")
	{
		strd = document.Form2.MRF12.value;
		alert(strd);
		document.Form2.Profile1_CodeNumberTextBox.focus();
		return false;
	}
	if(document.Form2.Profile1_CodeNumberTextBox.value.charAt(0)==' ')
	{  
	    strd = document.Form2.MRF2.value;
		alert(strd);
	    document.Form2.Profile1_CodeNumberTextBox.focus();
		return false;
    }
	
	
	return true;
}

	
function loopy() {
		loc = window.location.href
		sPos =loc.lastIndexOf("/")+1;
		if (sPos != -1) loc = loc.substring(0,sPos); // loose existing search
		window.location = loc+'logout.aspx';
	}

function popup(url)
{
	width = 450;
	height = 345;
	xx = window.screen.width;
	yy = window.screen.height;
	xx = (xx/2) - (width/2);
	yy = (yy/2) - (height);
	style = 'left = ' +  xx + ',top = ' + yy + ',width='+ width +',height=' + height + ',directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no';
	newwindow=window.open(url,'name',style);
	if (window.focus) {newwindow.focus()}
}

function HeaderEmailValidation()
{
	var emailPat = /^[A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)*[@][A-Za-z0-9_\-]+([.][A-Za-z0-9_\-]+)+$/
	var matchArray =document.newsletter.m_txtNewsLetter.value.match(emailPat);
	if(document.newsletter.m_txtNewsLetter.value==" ")
	{
		alert("Enter Email address.");
		document.newsletter.m_txtNewsLetter.focus();
		return false;
	}
	else if (matchArray == null)
	{
		alert("Invalid Email format.");
		document.newsletter.m_txtNewsLetter.value="";
		document.newsletter.m_txtNewsLetter.focus();
		return false;
	}
}


function HeaderLoginValidation()
{
	
	if(document.login.m_txtUserName.value=="")
	{
		
		strd=document.login.MRF3.value;
		alert(strd);
		document.login.m_txtUserName.focus();
		return false;
	}
	
	if(document.login.m_txtUserName.value.charAt(0)==' ')
	{
		
		strd=document.login.MRF5.value;
		alert(strd);
		document.login.m_txtUserName.focus();
		return false;
	}
	
	if(document.login.m_txtPassword.value=="")
	{
		
		strd=document.login.MRF4.value;
		alert(strd);
		document.login.m_txtPassword.focus();
		return false;
	}
	if(document.login.m_txtPassword.value.charAt(0)==' ')
	{
		
		strd=document.login.MRF5.value;
		alert(strd);
		document.login.m_txtPassword.focus();
		return false;
	}
	return true;
}

function HeaderSearchValidation()
{
	if(document.Search.m_txtSearch.value==" ")
	{
		alert("Enter search text.");
		document.Search.m_txtSearch.focus();
		return false;
	}
}

///Photo Gallery////
function HideAll(LayerCount)
{	
	for (i=1;i<=LayerCount;i++)
	{
		MM_showHideLayers('Layer'+i,'','hide');
	}
}
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 Pre(LayerCount)
{
	
	for (i=1;i<=LayerCount;i++)
	{
		var layer='Layer'+i;
		var style2 = document.getElementById(layer).style.visibility;
		if(style2=='visible')
		{
			var layno=parseInt(layer.substring(5));		
		}
	}	
	/* MERA CODE[START]*/
	var t_layno=parseInt(layno);
	//alert(parseInt(t_layno));	
	if(parseInt(t_layno)>=1)
	{
		//alert("");
		document.getElementById('nxt').src='dynamicdata/images/nxt.gif'
	}
	if(t_layno==2)
	{
		document.getElementById('pre').src='dynamicdata/images/pre1.jpg'
		//alert("It is first picture on this page.");
	}
	/* MERA CODE[END]*/	
	if(layno==1)
	{
		//alert("It is first picture on this page.");
	}
	else
	{
		if(layno!=null)
		{
			HideAll(LayerCount);
			var newlay=layno-1;			
			MM_showHideLayers('Layer'+newlay,'','show');
		}
		
	}
}

function Nex(LayerCount)
{
		//alert(LayerCount);	
		
		if(LayerCount!=1)
		{
					/*** step1**/
					for (i=1;i<=LayerCount;i++)
					{					
						var layer='Layer'+i;
						//alert(layer);
						var style2 = document.getElementById(layer).style.visibility;
						//salert(style2);
						if(style2=='visible')
						{
							var layno=parseInt(layer.substring(5));				
						}
					}				
					/*** step2**/
					if(parseInt(LayerCount)> 1)
					{
					/* MERA CODE[START]*/
					var t_layno=layno;
					var t_layercnt=parseInt(LayerCount)-1
					if(isNaN(t_layno))
					{
						t_layno="1";
					}
					//alert(t_layno);
					//alert(t_layercnt);
						if(parseInt(t_layno)>=1)
						{
							document.getElementById('pre').src='dynamicdata/images/pre.gif'
						}
					if(t_layno==t_layercnt)
					{
						//alert("It is last picture on this page.");
						document.getElementById('nxt').src='dynamicdata/images/nxt1.jpg'
					}
					/* MERA CODE[END]*/
					}
					else
					{
						//alert(layer);
						document.getElementById(layer).style.visibility='visible';
						//alert("It is last picture on this page.");
						
						
					}		
					/*** step3**/
					if(layno==parseInt(LayerCount))
					{		
						
					}
					else
					{
						HideAll(LayerCount);
						if(layno!=null)
						{
							var newlay=layno+1;
							MM_showHideLayers('Layer'+newlay,'','show');
						}
						else
						{
							MM_showHideLayers('Layer2','','show');
						}
					}
		}
		else
		{
			document.getElementById('nxt').src='dynamicdata/images/nxt1.jpg'
			document.getElementById('pre').src='dynamicdata/images/pre1.jpg'
		}
}
function ResetCtrl()
{
	//alert(document.Form1.cnt.value);
	if(document.Form1.cnt.value=="1")
	{
			document.getElementById('nxt').src='dynamicdata/images/nxt1.jpg'
			document.getElementById('pre').src='dynamicdata/images/pre1.jpg'
	}	
	if(document.Form1.cnt.value=="0")
	{
		document.getElementById('pre').style.visibility='hidden';
		document.getElementById('nxt').style.visibility='hidden';
		
	
	}	
}

function ValidateParticipar()
{
	var strd;
	if(document.Form1.filedialogbrowsefile.value == "")
	{
		strd = document.Form1.MRF1.value;
		alert(strd);
		document.Form1.filedialogbrowsefile.focus();
		return false;
	}	
	if(document.Form1.filedialogbrowsefile.value.charAt(0) == ' ')
	{
		strd = document.Form1.MRF2.value;
		alert(strd);
		document.Form1.filedialogbrowsefile.focus();
		return false;
	}
	if (document.Form1.filedialogbrowsefile.value!="")
	{
		filename = document.Form1.filedialogbrowsefile.value;
		i = filename.lastIndexOf(".");
		ext = filename.substr(i+1);
		ext= ext.toLowerCase();
		if (ext != "zip" && ext != "rar" && ext != "txt" && ext != "doc" && ext != "pdf" && ext != "jpg" && ext != "jpeg" && ext != "gif" && ext != "png" && ext != "htm" && ext != "xls" && ext != "html" && ext != "rtf")
		{
		    strd=document.Form1.MRF3.value;
			alert(strd);
			document.Form1.filedialogbrowsefile.value="";
			document.Form1.filedialogbrowsefile.select();
			return false;
		}
	}
	if(document.Form1.txtdescription.value == "")
	{
		strd = document.Form1.MRF4.value;
		alert(strd);
		document.Form1.txtdescription.focus();
		return false;
	}	
	if(document.Form1.txtdescription.value.charAt(0) == ' ')
	{
		strd = document.Form1.MRF2.value;
		alert(strd);
		document.Form1.txtdescription.focus();
		return false;
	}
	return true
}
/******Cookie**/

function getCookieVal (offset) 
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
	alert("sag")
		
}
		
function GetCookie (name)
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
		while (i < clen) 
		{
				var j = i + alen;
				if (document.cookie.substring(i, j) == arg)
				return getCookieVal (j);
				i = document.cookie.indexOf(" ", i) + 1;
				if (i == 0) break; 
		
		}
	return null;
}
		
function SetCookie (name,value,expires,path,domain,secure) 
{
	document.cookie = name + "=" + escape (value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}

function DeleteCookie (name) 
{
var cookie_date = new Date ( );  // current date &amp; time
cookie_date.setTime ( cookie_date.getTime() - 1 );
document.cookie = name += "=; expires=" + cookie_date.toGMTString();
	
}
			
			
			
var usr;
var pw;
var sv;
		
function getme()
{
	usr = document.login.m_txtUserName;
	pw = document.login.m_txtPassword;
	sv = document.login.save;
	if (GetCookie('username') != null)
	{
		usr.value = GetCookie('username')
		pw.value = GetCookie('password')
		if (GetCookie('save') == 'true')
		{
			sv.checked = true;
		}
	}
}
	function saveme()
{
		usr = document.login.m_txtUserName;
		pw = document.login.m_txtPassword;
		sv = document.login.save;
		if (usr.value.length != 0 && pw.value.length != 0)
		{
			if (sv.checked==true)
			{
				expdate = new Date();
				expdate.setTime(expdate.getTime()+(365 * 24 * 60 * 60 * 1000));
				SetCookie('username', usr.value, expdate);
				SetCookie('password', pw.value, expdate);
				SetCookie('save', 'true', expdate);
			}
			if (sv.checked==false)
			{
				DeleteCookie('username');
				DeleteCookie('password');
				DeleteCookie('save');
			}
		}	
		else
		{
				alert('Either your userid or password field is left empty You must enter a userid/password.');
				document.login.emailid.focus();
				return false;
		}
		} 
		function getidentity()
		{
		if(document.login.chkRember.checked)
		{
			var unm = GetCookie("UserName");
			if(unm==null)
			{
			//alert("Empty1");
			document.login.m_txtUserName.value=="";
			document.login.m_txtUserName.focus(); 
			}
			else
			{
			// alert(unm);
			document.login.m_txtUserName.value = GetCookie("UserName");
			}
			
			var pass= GetCookie("Password");
			if(pass==null)
			{
			//alert("Empty2");
			document.login.m_txtPassword.value=="";
			}
			else
			{
				//alert(pass);
				document.login.m_txtPassword.value = GetCookie("Password");
			}
		}
			
return true;
}

function Init()
{

document.login.m_txtUserName.value = GetCookie("UserName");
document.login.m_txtPassword.value = GetCookie("Password");
}
