function validate_form(formname)  {
	if(!checkRequired_with_default_text(formname.username, "Please enter Username", "Username")) return false;    
	if(!checkRequired_with_default_text(formname.username, "Please enter Username", "Enter Email Address")) return false;    
	if(!validateEmail(formname.username, "Please enter Valid Email Address")) return false;
	if(!checkRequired_with_default_text(formname.username, "Please enter Password", "password")) return false;    
    var ajaxIndex = ajaxObjects.length;
    ajaxObjects[ajaxIndex] = new sack();
    ajaxObjects[ajaxIndex].requestFile = "login.process.php";	// Saving product in this file
    ajaxObjects[ajaxIndex].method = "POST";
    ajaxObjects[ajaxIndex].setVar('username', formname.username.value);
    ajaxObjects[ajaxIndex].setVar('password', formname.password.value);
	ajaxObjects[ajaxIndex].setVar('competition_no', formname.competition_no.value);
	ajaxObjects[ajaxIndex].setVar('redirecturl', "");
    ajaxObjects[ajaxIndex].setVar('jsdone', 1);
    ajaxObjects[ajaxIndex].onCompletion = function(){ updateLogin(ajaxObjects[ajaxIndex].response); }
    ajaxObjects[ajaxIndex].runAJAX();
    return false;
}

function updateLogin (result) {
    if (result == 4) {
		location.href = "create_exhibit.php?competition_no=" + competition_no;
	} else if (result == 1) {
        location.href = "exhibitlist.php";
	} else if(result == 3)	{
		location.href = "createnewexhibit.php";
    } else if(result == 2)	{	
        alert("Email address not authenticated. Kindly check your email.");
    } else {
		alert("Invalid username and/or Password");
	}
}

function forgot_password()
{
	document.getElementById('fpwd').style.display = "block";
}

function validate_forgot_password(formname)
{
	document.getElementById('fpwd').style.display = "block";
	if(!checkRequired_with_default_text(formname.email, "Please enter password","Enter Email Address")) return false; 
	if(!validateEmail(formname.email, "Invalid Email Address")) return false;
	return true;
}

function updateLogin_forgot_password (result) {
	
    if (result == 1) {
        location.href = "index.php";
    }	else	{	
        alert("Invalid username and/or Password");
    }
}

function hide_fpwd_div()
{
	current_status = document.getElementById('fpwd').style.display;
	if(current_status == "")
	{
	document.getElementById('fpwd').style.display = "none";
	}
	else if(current_status = "block" )
	{
	}
	else
	{
	document.getElementById('fpwd').style.display = "none";
	}
}


function f_filterResults(n_win, n_docel, n_body) {
		var n_result = n_win ? n_win : 0;
		if (n_docel && (!n_result || (n_result > n_docel)))
			n_result = n_docel;
		return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
	}

function f_clientWidth() {
	return f_filterResults (
	window.innerWidth ? ((window.innerWidth / 4) + 100) + "px" : 0,
	document.documentElement ? ((document.documentElement.clientWidth / 4) + 100) + "px" : 0,
	document.body ? ((document.body.clientWidth / 4) + 100) + "px" : 0
	);
}

function show_hide_member_layer_function()
{
	
	if(document.getElementById('forgotpasswordlayer').style.display == "block"){
		document.getElementById('forgotpasswordlayer').style.display = 'none';
	}	else	{
        document.getElementById('forgotpasswordlayer').style.display = 'block';
		//document.getElementById('HomeTransLayer').style.display = "none";
	}
}
