/**
 * common 10MAR2009 Version 1.0
 * Abhimanyu Dawar, March 2009
 * Copyright (c) NIS Sparta.
 *
 */
function fnValid()
{
	returnValue = true;
	if(document.frmEnquiry.txtName.value.length==0)
	{
		alert("Please fill in your NAME");
		document.frmEnquiry.txtName.focus();
		document.frmEnquiry.txtName.select();
		returnValue = false;
	}
	/*else if(document.frmEnquiry.txtAddress.value.length==0)
	{
		alert("Please fill-in your ADDRESS");
		document.frmEnquiry.txtAddress.focus();
		document.frmEnquiry.txtAddress.select();
		returnValue = false
	}*/
	else if(document.frmEnquiry.txtMobile.value.length==0)
	{
		alert("Please fill in your MOBILE NUMBER");
		document.frmEnquiry.txtMobile.focus();
		document.frmEnquiry.txtMobile.select();
		returnValue = false
	}
	else if(document.frmEnquiry.txtEmail.value.length==0)
	{
		alert("Please fill-in your E-MAIL ADDRESS");
		document.frmEnquiry.txtEmail.focus();
		document.frmEnquiry.txtEmail.select();
		returnValue = false
	}
	else if(document.frmEnquiry.txtEmail.value.indexOf("@") == -1) 
	{
	    alert("Please enter a valid E-MAIL ADDRESS")
    	document.frmEnquiry.txtEmail.focus()
    	document.frmEnquiry.txtEmail.select()      
        returnValue = false
	}
	else if(document.frmEnquiry.txtEmail.value.indexOf(".") == -1) 
	{
    	alert("Please Enter a valid E-MAIL ADDRESS")
	    document.frmEnquiry.txtEmail.focus()
	    document.frmEnquiry.txtEmail.select()      
    	returnValue = false 
	}
	else if(document.frmEnquiry.txtEmail.value.indexOf("'")!= -1)
	{
    	alert("Please Enter a valid E-MAIL ADDRESS")
	    document.frmEnquiry.txtEmail.focus()
    	document.frmEnquiry.txtEmail.select()      
	    returnValue = false 
	}
	else if(document.frmEnquiry.cmbReason.value.length==0)
	{
		alert("Please select your REASON");
		document.frmEnquiry.cmbReason.focus();
		returnValue = false
	}
	else if(document.frmEnquiry.cmbReason.value == "course")
	{
		if(document.frmEnquiry.cmbCourse.value.length==0)
		{
			alert("Please select a COURSE");
			document.frmEnquiry.cmbCourse.focus();
			returnValue = false
		}
		else if(document.frmEnquiry.txtCity.value.length==0)
		{
			alert("Please fill-in your CITY/STATE");
			document.frmEnquiry.txtCity.focus();
			returnValue = false
		}
		else if(document.frmEnquiry.txtComments.value.length==0)
		{
			alert("Please enter your COMMENTS/QUERY");
			document.frmEnquiry.txtComments.focus();
			returnValue = false
		}
	}
	else if(document.frmEnquiry.cmbReason.value == "franchise")
	{
		if(document.frmEnquiry.txtCity.value.length==0)
		{
			alert("Please fill-in your CITY/STATE");
			document.frmEnquiry.txtCity.focus();
			returnValue = false
		}
		else if(document.frmEnquiry.txtComments.value.length==0)
		{
			alert("Please enter your COMMENTS/QUERY");
			document.frmEnquiry.txtComments.focus();
			returnValue = false
		}
	}
	else if(document.frmEnquiry.txtComments.value.length==0)
	{
		alert("Please enter your COMMENTS/QUERY");
		document.frmEnquiry.txtComments.focus();
		returnValue = false
	}
	return returnValue;
}

function clear_form()
{
	for (var i = 0; i < document.frmEnquiry.elements.length; i ++)
	{
		document.frmEnquiry.elements [i].value = "";
	}
	reset_form()
}

function reset_form()
{
		//document.getElementById("contactRow1").style.display = "none";
		//document.getElementById("contactRow1").style.visibility = "hidden";
		if (BrowserDetect.browser == "Firefox")
		{
			document.getElementById("courseRow1").style.display = "none";
			document.getElementById("courseRow1").style.visibility = "collapse";
		}
		else if (BrowserDetect.browser == "Explorer")
		{
			document.getElementById("courseRow1").style.display = "none";
			document.getElementById("courseRow1").style.visibility = "hidden";
		}
		//document.getElementById("courseRow2").style.display = "none";
		//document.getElementById("courseRow2").style.visibility = "hidden";
}

function display_form()
{
	reset_form();
	var reason = document.getElementById("reason").value;
	if (reason != "" || reason != null)
	{
		switch (reason)
		{
			//case "feedback":
			//	document.getElementById("contactRow1").style.display = "block";
			//	document.getElementById("contactRow1").style.visibility = "visible";
			//	break;
			//case "partnership":
			//	document.getElementById("contactRow1").style.display = "block";
			//	document.getElementById("contactRow1").style.visibility = "visible";
			//	break;
			case "course":
				if (BrowserDetect.browser == "Firefox")
					document.getElementById("courseRow1").style.display = "table-row";
				else if (BrowserDetect.browser == "Explorer")
					document.getElementById("courseRow1").style.display = "block";

					document.getElementById("courseRow1").style.visibility = "visible";
					//document.getElementById("courseRow2").style.display = "block";
					//document.getElementById("courseRow2").style.visibility = "visible";
					//document.getElementById("contactRow1").style.display = "block";
					//document.getElementById("contactRow1").style.visibility = "visible";
				break;
			//case "franchise":
				//document.getElementById("contactRow1").style.display = "block";
				//document.getElementById("contactRow1").style.visibility = "visible";
				//document.getElementById("courseRow2").style.display = "block";
				//document.getElementById("courseRow2").style.visibility = "visible";
			//	break;
			default:
				break;
		}

	}
	else
	{
		alert ("Error! Please try again later.")
	}
}

function submit_form()
{
	if (fnValid())
	{
		document.getElementById("frmEnquiry").submit()
	}
}
