function GetPageElement(ElementName)
	{
    var ReturnElement = "";

    if (document.getElementById)
		{
        ReturnElement = "document.getElementById('" + ElementName + "')";
		}
    else if (document.all)
		{
        ReturnElement = "document.all['" + ElementName + "']";
		}
    return eval(ReturnElement);
}


function SwapPassword()
    {
	    var tfPassword = GetPageElement("lastname");
	    var tfPasswordPlace = GetPageElement("PasswordPlace");

        tfPasswordPlace.style.display = "none";
        tfPassword.style.display = "";
        tfPassword.focus();
    }
    
    function SwapUsername()
    {
	    var tfUserName = GetPageElement("firstname");
	    var tfUsernamePlace = GetPageElement("UsernamePlace");

        tfUsernamePlace.style.display = "none";
        tfUserName.style.display = "";
        tfUserName.focus();
    }     
    
    function SwapUsernamePlace()
    {
	    var tfUserName = GetPageElement("firstname");
	    var tfUsernamePlace = GetPageElement("UsernamePlace");
	    
        if (tfUserName.value == '')
        {
            tfUsernamePlace.style.display = "";
            tfUserName.style.display = "none";
        }
    }
    
    function SwapPasswordPlace()
    {
	    var tfPassword = GetPageElement("lastname");
	    var tfPasswordPlace = GetPageElement("PasswordPlace");

        if (tfPassword.value == '')
        {
            tfPasswordPlace.style.display = "";
            tfPassword.style.display = "none";
        }
    }
	
	function SwapEmail()
    {
	    var tfEmail = GetPageElement("email");
	    var tfEmailPlace = GetPageElement("EmailPlace");

        tfEmailPlace.style.display = "none";
        tfEmail.style.display = "";
        tfEmail.focus();
    }     
    
    function SwapEmailPlace()
    {
	    var tfEmail = GetPageElement("email");
	    var tfEmailPlace = GetPageElement("EmailPlace");
	    
        if (tfEmail.value == '')
        {
            tfEmailPlace.style.display = "";
            tfEmail.style.display = "none";
        }
    }
	
	function SwapPhone()
    {
	    var tfPhone = GetPageElement("search");
	    var tfPhonePlace = GetPageElement("PhonePlace");

        tfPhonePlace.style.display = "none";
        tfPhone.style.display = "";
        tfPhone.focus();
    }     
    
    function SwapPhonePlace()
    {
	    var tfPhone = GetPageElement("search");
	    var tfPhonePlace = GetPageElement("PhonePlace");
	    
        if (tfPhone.value == '')
        {
            tfPhonePlace.style.display = "";
            tfPhone.style.display = "none";
        }
    }					


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 email address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid email address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid email address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid email address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid email address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid email address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid email address")
		    return false
		 }

 		 return true					
	}


function checkEmailForm()
	{

	if ((emailForm.email.value==null)||(emailForm.email.value=="")){
		alert("Please enter email address.")
		emailForm.email.focus()
		return false
	}

	if (echeck(emailForm.email.value)==false){
		emailForm.email.value=""
		emailForm.email.focus()
		return false
	}

	else
		return true;
 }


 /*
Auto center window script- Eric King (http://redrival.com/eak/index.shtml)
Permission granted to Dynamic Drive to feature script in archive
For full source, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}

function popitup(url) {
	newwindow=window.open(url,'name','height=200,width=150');
	if (window.focus) {newwindow.focus()}
	return false;
}
