// Get today's current date.
var now = new Date();

// Array list of days.
var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');

// Array list of months.
var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');

// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();

// Calculate four digit year.
function fourdigits(number)	
	{
	return (number < 1000) ? number + 1900 : number;
	}

function KMpopup(mylink, windowname)
	{
	if (! window.focus)return true;
	var href;
	if (typeof(mylink) == 'string')
	href=mylink;
	else
   href=mylink.href;
	window.open(href, windowname, 'width=640,height=470,scrollbars=yes,toolbar=no,resizable=no,menubar=no');
	return false;
	}


function submitProfile()
	{
	document.profile.submit();
	}

function checkRulesForm()
	{	
	
	if (rulesForm.agreement.checked==false)
		{
		alert("Please check I have read, and agree to abide by the SynergemIndia rules.")
		rulesForm.agreement.focus()
		return false
		}
	else
		return true;
	}

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("password");
	    var tfpasswordPlace = GetPageElement("passwordPlace");

        tfpasswordPlace.style.display = "none";
        tfpassword.style.display = "";
        tfpassword.focus();
    }
    
    function Swapusername()
    {
	    var tfusername = GetPageElement("username");
	    var tfusernamePlace = GetPageElement("usernamePlace");

        tfusernamePlace.style.display = "none";
        tfusername.style.display = "";
        tfusername.focus();
    }     
    
    function SwapusernamePlace()
    {
	    var tfusername = GetPageElement("username");
	    var tfusernamePlace = GetPageElement("usernamePlace");
	    
        if (tfusername.value == '')
        {
            tfusernamePlace.style.display = "";
            tfusername.style.display = "none";
        }
    }
    
    function SwappasswordPlace()
    {
	    var tfpassword = GetPageElement("password");
	    var tfpasswordPlace = GetPageElement("passwordPlace");

        if (tfpassword.value == '')
        {
            tfpasswordPlace.style.display = "";
            tfpassword.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;
}