//To Get Position of Control Control
function findPos(obj)
{
var curleft = curtop = 0;
if (obj.offsetParent)
{
curleft = obj.offsetLeft;
curtop = obj.offsetTop;
while (obj = obj.offsetParent)
{
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
}
}
//alert("Left= "+curleft + "      Right: " + curtop);
return [curleft,curtop];
}


//To Set Massage in BottomLeft of Control
  function AlertBottomLeft(obj,obj1)
{
var obj1=document.getElementById(obj1);
//var obj=document.getElementById(obj);
findPos(obj1);
obj1.style.display="block";
obj1.style.position="absolute";
var h=obj.clientHeight+10;
var w=obj1.clientWidth;
obj1.style.top=obj.offsetTop+h+"px";
obj1.style.left=obj.offsetLeft-w+"px";

}

//To Set Massage in BottomRight of Control
  function AlertBottomRight(obj,obj1)
{
var obj1=document.getElementById(obj1);
findPos(obj1);
alert(obj1);
obj1.style.display="block";
obj1.style.position="absolute";
var h=obj.clientHeight+10;
var w=obj.clientWidth;
obj1.style.top=obj.offsetTop+h+"px";
obj1.style.left=obj.offsetLeft+w+"px";
//obj.className="DisplayPopup";
alert(h)
alert(obj1.offsetTop)
}


//To Set Massage in TopRight of Control
  function AlertTopRight(obj,obj1)
{
var obj1=document.getElementById(obj1);
findPos(obj1);
obj1.style.position="absolute";
obj1.style.display="block";
var h=obj.clientHeight+10;
var w=obj.clientWidth;
obj1.style.top=obj.offsetTop-h+"px";
obj1.style.left=obj.offsetLeft+w+"px";
//obj.className="DisplayPopup";
//alert(h)
//alert(obj1.offsetTop)
}


//To Show Massage in TopLeft of Control
  function AlertTopLeft(obj,obj1)
{
var obj1=document.getElementById(obj1);
findPos(obj1);
obj1.style.position="absolute";
obj1.style.display="block";
var h=obj.clientHeight+10;
var w=obj1.clientWidth;
obj1.style.top=obj.offsetTop-h+"px";
obj1.style.left=obj.offsetLeft-w+"px";

//obj.className="DisplayPopup";
//alert(h)
//alert(obj1.offsetTop)
}








function HideAlertMessage()
{
document.getElementById("DivEmailAlert").className="HidePopup";
}
function AlertMessage()
{
document.getElementById("DivEmailAlert").className="DisplayPopup";
}
function HideProfileAlertMessage()
{
document.getElementById("DivProfileIDAlert").className="HidePopup";
}
function AlertProfileidMessage()
{

document.getElementById("DivProfileIDAlert").className="DisplayProfilePopup";
//AlertBottomLeft('PPP','DivProfileIDAlert');
}

//DisplayPopup

function WaterMarkDisable1()
{
var ID=document.getElementById("TextBox1");
//alert(ID.value.length);
if(ID.value.length==20)
{
ID.className="";
ID.value="";
}
else
{

}

//alert(ID.value.length);
}



function PasswordRequired()
{

var username=document.getElementById("<%=TxtUsername.ClientID %>");
var Password=document.getElementById("<%=TxtPassword.ClientID %>");
 
alert(Password.value.length);
return false;
//if(username.value.length==0)
//{
//username.value="Enter Username";
//return false;
//}
//else if(Password.value.length==0)
//{
//Password.value="Enter Password";
//return false;
//}
//else
//{
//return false;
//}

}


function WaterMarkEnable1()
{
var ID=document.getElementById("TextBox1");
if(ID.value.length==0)
{

ID.className="watermarked";
ID.value="Enter Valid Email Id";
}
}



function WaterMarkDisable()
{
var ID=document.getElementById("TxtProfileId");
//alert(ID.value.length);
if(ID.value.length==17)
{
ID.className="";
ID.value="";


}
else
{

}

//alert(ID.value.length);
}


function WaterMarkEnable()
{
HideProfileAlertMessage();
var ID=document.getElementById("TxtProfileId");
if(ID.value.length==0)
{
ID.className="watermarked";
ID.value="  Enter ProfileId";

}
}
function showChat()
         {  
          window.open('chat/Login.aspx','newWin','height=450,width=608,left=100,top=100,status=no,toolbar=no,menubar=no,scrollbars=no,maximize=false,resizable=0');	 
         }
     function popitup()
      {
	   window.open('Forgotpassword.aspx','newWin','height=300,width=600,left=200,right=200,top=100');
	
	} 

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));


function alphanumeric_only(e)
{
var keycode;

if (window.event) keycode = window.event.keyCode;
else if (event) keycode = event.keyCode;

else if (e) keycode = e.which;
//else return true;if( (keycode >= 47 && keycode <= 57) || (keycode >= 65 && keycode <= 90) || (keycode >= 97 && keycode <= 122)||(keycode == 95) )
else return true;if( keycode==32)
{
//alert(keycode);
return false;
}
else
{
return true;
}
return true;
}


function ProfileIDMust()
{
var ID=document.getElementById("TxtProfileId");
//alert(ID.value.length);
if(ID.value.length==17)
{
//alert("Enter ProfileID");
AlertProfileidMessage();
ID.focus();

return false;
}
else
{
return true;
}

}





//Following All Code is Use for Email Validation

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		  // alert("Invalid E-mail ID")
		   AlertMessage();
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		  AlertMessage();
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		  //alert("Invalid E-mail ID")
		  AlertMessage();
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		 AlertMessage();
		  //  alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   //alert("Invalid E-mail ID")
		   AlertMessage();
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		 AlertMessage();
		  // alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		AlertMessage();
		  // alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	//var emailID=document.frmSample.txtEmail
	var emailID=document.getElementById("TextBox1")
	if ((emailID.value==null)||(emailID.value=="")){
		//AlertMessage();
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		//emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }


