//----------------------------------Function to activate transparent menu------------------------
function init() {
			if (TransMenu.isSupported()) {
				TransMenu.initialize();

//				menu1.onactivate = function() { document.getElementById("aboutus1").className = "hover"; };
//				menu1.ondeactivate = function() { document.getElementById("aboutus1").className = ""; };

				menu1.onactivate = function() { document.getElementById('Image2').src = './images/02_about_ro.png';};
				menu1.ondeactivate = function() { document.getElementById('Image2').src = './images/02_about.png';};

				menu2.onactivate = function() { document.getElementById('Image3').src = './images/03_courses_ro.png';};
				menu2.ondeactivate = function() { document.getElementById('Image3').src = './images/03_courses.png';};

				menu3.onactivate = function() { document.getElementById('Image7').src = './images/07_join_ro.png';};
				menu3.ondeactivate = function() { document.getElementById('Image7').src = './images/07_join.png';};

				menu4.onactivate = function() { document.getElementById('Image8').src = './images/08_news_ro.png';};
				menu4.ondeactivate = function() { document.getElementById('Image8').src = './images/08_news.png';};

				menu5.onactivate = function() { document.getElementById('Image9').src = './images/09_contact_ro.png';};
				menu5.ondeactivate = function() { document.getElementById('Image9').src = './images/09_contact.png';};

		}
}


function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//-----------------------------Function to validate enquiry form--------------------------------------------
function chkenquiryform()
{
	var msg = "";
	if (document.enquiryform.name.value == "") { msg = msg + "Name\n";}
	if (document.enquiryform.email.value == "") { msg = msg + "Email\n";}
	else
	{
		var houseReegxp = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$/;
		if (houseReegxp.test(document.enquiryform.email.value) == false)
		{
			msg = msg + "Invald Email Address\n";
		}
	}
	if (document.enquiryform.mobile.value == "") { msg = msg + "Mobile\n";}
/*
	else
	{
		var digits = "0123456789";
		for (var i = 0; i < document.enquiryform.mobile.value.length; i++)
		{
			temp = document.enquiryform.mobile.value.substring(i, i+1)

			if (digits.indexOf(temp) == -1 && document.enquiryform.mobile.value != "")
			{
				msg = msg + "The Mobile No. must include only digits.\n";
				break;
			}
    	} 	
	}
*/

	if (document.enquiryform.city.value == "") { msg = msg + "City\n";}
	if (document.enquiryform.state.value == "") { msg = msg + "State\n";}
	if (document.enquiryform.country.value == "") { msg = msg + "Country\n";}
	if (document.enquiryform.pincode.value == "") { msg = msg + "Pincode\n";}
/*	
	else
	{
		var digits = "0123456789";
		for (var i = 0; i < document.enquiryform.pincode.value.length; i++)
		{
			temp = document.enquiryform.pincode.value.substring(i, i+1)

			if (digits.indexOf(temp) == -1 && document.enquiryform.pincode.value != "")
			{
				msg = msg + "The Pincode must be digits.\n";
				break;
			}
		  }
	}	

*/
	if (msg != "")
	{
		alert("Please fill in following fields-\n"+msg);
	}
	else
	{
        document.enquiryform.submit();
	}


}

//-----------Function to validate course booking form--------------------

function chkcoursebookform()
{
	var msg = "";
	if (document.coursebookform.lastname.value == "") { msg += "Last Name\n";}
	if (document.coursebookform.firstname.value == "") { msg += "First Name\n";}
	if (document.coursebookform.rank.value == "") { msg += "Rank\n";}
	if (document.coursebookform.coc.value == "") { msg += "C.O.C held\n";}
	if (document.coursebookform.phone.value == "") { msg += "Phone\n";}
	if (document.coursebookform.mobile.value == "") { msg += "Mobile\n";}
	if (document.coursebookform.email.value == "") { msg += "Email Address\n";}
	else
	{
		var houseReegxp = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$/;
		if (houseReegxp.test(document.coursebookform.email.value) == false)
		{
			msg = msg + "Invald Email Address\n";
		}
	}
	
	// validate myradiobuttons
	var myOption = -1;

	for (var i=document.coursebookform.pay_mode.length-1; i > -1; i--) 
	{
		if (document.coursebookform.pay_mode[i].checked) 
		{
			myOption = i; i = -1;
		}
	}
	if (myOption == -1) 
	{
		msg += "Payment Mode\n";
	}



	if (msg != "")
	{
		alert("Please fill in following fields\n\n"+msg);
		return false;
	}

}

//--------------------------------------------------------------------------
//Function to postion div of search by keywords of index page
//-------------------------------------------------------------------------
function layer10divpos()
{
// variables to get screen height and width of window 

var winWidth=screen.width;
var winHeight=screen.height;

// Window width minus resolution of the screen the design is designed for
// Divide by 2 to get outer space between screen border and the main table
// Add width from outer table border to start of element. 
 
 
var left = (winWidth-1024)/2+775;
var top = 363;


document.getElementById("layer10").style.left=left+'px';
document.getElementById("layer10").style.top=top+'px';
document.getElementById("layer10").style["display"]="block" ;
document.getElementById("layer10").style["visibility"]="visible" ;
}

//--------------------------------------------------------------------------
//Function to postion div of search by keywords of header page
//-------------------------------------------------------------------------
function layer11divpos()
{
// variables to get screen height and width of window 

var winWidth=screen.width;
var winHeight=screen.height;

// Window width minus resolution of the screen the design is designed for
// Divide by 2 to get outer space between screen border and the main table
// Add width from outer table border to start of element. 
 
 
var left = (winWidth-1024)/2+773;
var top = 244;


document.getElementById("layer11").style.left=left+'px';
document.getElementById("layer11").style.top=top+'px';
document.getElementById("layer11").style["display"]="block" ;
document.getElementById("layer11").style["visibility"]="visible" ;
}



//--------------------------------------------------------------------------
//Function validate inner search by keyword form
//-------------------------------------------------------------------------
function chk_innerform()
{
	if (document.searchform_inner.keyword_str.value == "")
	{
		alert('Please fill in keywords to be searched');
		return false;
	}
}

//--------------------------------------------------------------------------
//Function validate header / index search by keyword form
//--------------------------------------------------------------------------
function chk_headerform()
{
	if (document.searchform_header.keyword_str.value == "" || document.searchform_header.keyword_str.value == "Search")
	{
		alert('Please fill in keywords to be searched');
		return false;
	}
}

//--------------------------------------------------------------------------
//Reset course schedule Form
//--------------------------------------------------------------------------
function resetsearchform()
{
	document.schedulesearchform.cokeywords.value="Search by Keywords";
	document.schedulesearchform.fr_month.selectedIndex=0;
	document.schedulesearchform.fr_day.selectedIndex=0;
	document.schedulesearchform.fr_year.selectedIndex=0;
	document.schedulesearchform.to_month.selectedIndex=0;
	document.schedulesearchform.to_day.selectedIndex=0;	
	document.schedulesearchform.to_year.selectedIndex=0;
	document.schedulesearchform.category.selectedIndex=0;
}


function isNumeric(sText)
{
	var ValidChars = '0123456789.';
	var IsNumber=true;
	var Char;       
	if(sText=='') IsNumber = false;       
	for (i = 0; i < sText.length && IsNumber == true; i++)
	{           
		Char = sText.charAt(i);           
		if (ValidChars.indexOf(Char) == -1) IsNumber = false;       
	}       
	return IsNumber;    
}

function isEmail(sText)
{

	var  emailReegxp= /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$/;
	var IsEmail=true;

	if (!emailReegxp.test(sText))
	{
		IsEmail=false;
	}
	return IsEmail;
}


function chkmyform()
{
	var msg = "";
	var invalid = " "; // Invalid character is a space

	var radiook=0;
	for(var i=0;i<=document.myform.stream.length-1;i++)
	{
		if(document.myform.stream[i].checked)
		{
			radiook = 1;
			break;
		}
	}
	if (radiook == 0) { msg = msg + "Stream\n";}	


	if (document.myform.firstname)
	{	
		if (document.myform.firstname.value.length == "0") { msg = msg + "First Name\n";}
	}
	if (document.myform.lastname)
	{
		if (document.myform.lastname.value.length == "0") { msg = msg + "Last Name\n";}
	}
	if (document.myform.middlename)
	{
		if (document.myform.middlename.value.length == "0") { msg = msg + "Middle Name\n";}
	}

	if (document.myform.fr_month && document.myform.fr_day && document.myform.fr_year)
	{	
		if (document.myform.fr_month.value == "" || document.myform.fr_day.value == "" || document.myform.fr_year.value == "") { msg = msg + "DOB\n";}
	}
	if(document.myform.city)
	{
		if (document.myform.city.value.length == "0") { msg = msg + "City\n";}
	}
	if (document.myform.pincode)
	{
		if (document.myform.pincode.value == "") { msg = msg + "Pincode\n";}
		else if (!isNumeric(document.myform.pincode.value)) { msg = msg + "Invalid Pincode\n";}
	}
	if(document.myform.std && document.myform.phone)
	{
		if (document.myform.std.value == "" || document.myform.phone.value == "" ) { msg = msg + "Telephone\n";}
	}
	if (document.myform.mobile)
	{
		if (document.myform.mobile.value == "") { msg = msg + "Mobile\n";}
	}

	if (document.myform.email)
	{
		if (document.myform.email.value.length == "0") { msg = msg + "Email\n";}
		else if (!isEmail(document.myform.email.value)) { msg = msg + "Invalid Email Id\n";}
	}
	if (document.myform.tenoverpc && document.myform.tenoversc && document.myform.tenoverbu)
	{	
		if (document.myform.tenoverpc.value == "" || document.myform.tenoversc.value == "" || document.myform.tenoverbu.value == "") { msg = msg + "X th (Over all %)\n";}
	}
	var flag = 0;
	//if(document.myform.tenoverpc.value != "" || document.myform.twelveoverpc.value != "" || document.myform.twelvepcmpc.value != "" || document.myform.beoverpc.value != "")
	if(document.myform.tenoverpc.value != "")
	{
		if ((!isNumeric(document.myform.tenoverpc.value)))
		{
			flag = 1;	
		}
	}
	if(document.myform.twelveoverpc.value != "")
	{
		if((!isNumeric(document.myform.twelveoverpc.value)))
		{
			flag = 1;
		}
	}
	if(document.myform.twelvepcmpc.value != "")
	{
		if((!isNumeric(document.myform.twelvepcmpc.value)))
		{
			flag = 1;	
		}
	}
	if(document.myform.beoverpc.value != "")
	{
		if((!isNumeric(document.myform.beoverpc.value)))
		{
			flag = 1;
		}
	}
		/*if ((!isNumeric(document.myform.tenoverpc.value)) || (!isNumeric(document.myform.twelveoverpc.value)) || (!isNumeric(document.myform.twelvepcmpc.value)) || (!isNumeric(document.myform.beoverpc.value)))
		{
			msg = msg + "Percentage must be numerical value\n";
		}*/
		
	if(flag == 1)
	{
		msg = msg + "Percentage must be numerical value\n";
	}
	
	if (document.myform.centre.value == "")
	{
		msg = msg + "Examination Centre\n";
	}
	if ((document.myform.chday1.value == "" || document.myform.chmonth1.value == "") && (document.myform.chday2.value == "" || document.myform.chmonth2.value == "") && (document.myform.chday3.value == "" || document.myform.chmonth3.value == ""))
	{
		msg = msg + "Choice of Exam Date\n";
	}


	
	
	if (msg != "")
	{
		alert("Please fill in following fields \n\n"+msg);
	}
	else
	{
		document.myform.submit();
	}
}



