//alert(document.getElementById('sPageName').value);
var allFieldsName = new Array("txtName","txtEmail","slctCity","txtMobile","slctWorkExperience","slctProgrammesinterested","slctFunctionalArea","radPercentageOfMarks","slctContactTime");var frmUser=new Object(); 
function validateUser(fieldName) 
{
	var prog, perc;
	prog = document.form1.cboCourses.value;
	perc = get_radio_value();
	if (("Executive Program in Applied Finance" == prog || "Senior Management Program" == prog || "Executive Program on Supply Chain Management" == prog || "Advanced Program on Competitive Strategy" == prog || "Certificate Program in Management of Software Development" == prog || "Advanced Program in Strategic Management" == prog || 'Executive Program in Applied Finance' == prog || 'Post Graduate Certificate Program in International Business' == prog) && "below 50%" == perc && fieldName == '' )
	{
		alert("You need above 50% to apply for this program");
		return false;
	}
	if ("" == fieldName)
	{
		alertErrorMessage = "";
		var ln = allFieldsName.length;
		for(ruleCount=0; ruleCount<ln; ++ruleCount) 
		{
			validRules(allFieldsName[ruleCount]);
			flagFormSubmit=true;
		}
	}
	else validRules(fieldName);
	fieldMap["form1"]=frmUser;
	return (validation(document.forms[0]))? true : false; 
}

function validRules(fieldName) { 
 switch(fieldName){
  case "txtName":
frmUser["txtName"] = {validateFunction:[{funName:isBlank,errMsg:"Please enter your Full Name"}, {funName:nameValidation,errMsg:"Please enter your valid Full Name"}], div:"errtxtName"};
  break;
  case "txtEmail":
frmUser["txtEmail"] = {validateFunction:[{funName:isBlank,errMsg:"Please enter your Email"},{funName:emailValidation,errMsg:"Please enter your valid Email"}], div:"errtxtEmail"};
  break;
  case "slctCity":
frmUser["slctCity"] = {validateFunction:[{funName:isBlank,errMsg:"Please select your Preferred City"}], div:"errslctCity"};
  break;
//   case "txtPhoneNo":
//  frmUser["txtPhoneNo"] = {validateFunction:[{funName:phoneValidation,errMsg:"Please enter your valid Alternate Contact No"}], div:"errtxtPhoneNo"};
//    break;
  case "txtMobile":
frmUser["txtMobile"] = {validateFunction:[{funName:isBlank,errMsg:"Please enter your Mobile"},{funName:mobilenumberValidation,errMsg:"Please enter your valid Mobile"}], div:"errtxtMobile"};
  break;
  case "slctWorkExperience":
frmUser["slctWorkExperience"] = {validateFunction:[{funName:isBlank,errMsg:"Please select your Total Work Experience"}], div:"errslctWorkExperience"};
  break;
  case "slctProgrammesinterested":
frmUser["slctProgrammesinterested"] = {validateFunction:[{funName:isBlank,errMsg:"Please select your Program Name"}], div:"errslctProgrammesinterested"};
  break;
  case "slctFunctionalArea":
frmUser["slctFunctionalArea"] = {validateFunction:[{funName:isBlank,errMsg:"Please select your Functional Area"}], div:"errslctFunctionalArea"};
  break;
  case "radPercentageOfMarks":
frmUser["radPercentageOfMarks"] = {validateFunction:[{funName:isBlank,errMsg:"Please select your Graduation Percentage"}, {funName:atleastOneRadChk,errMsg:"Please enter your valid Graduation Percentage"}],  others:[ " radPercentageOfMarksper1", "radPercentageOfMarksper2"], div:"errradPercentageOfMarks"};
  break;
  case "slctContactTime":
frmUser["slctContactTime"] = {validateFunction:[{funName:isBlank,errMsg:"Please select your Preferred Call Timing"}], div:"errslctContactTime"};
  break;
// 		case "txtOther":
// 				if(document.getElementById('slctHighQualify')=='Other')
// 				{
// 					frmUser["txtOther"] = {validateFunction:[{funName:isBlank,errMsg:"Please enter your Other Qualification"},div:"errtxtOther"};}
// 					break;
// 				}
  }
}
function showOther(val)
{
	var lenCombo=document.getElementById('slctHighQualify');
	var count=0;
	for (var j=0;j<lenCombo.length;j++)
	{
		if(lenCombo.options[j].selected==true)
		{
			count=count+1;
		}
	}
	if(val=='Other')
	{
		document.getElementById('otherQualify').style.display='block';
	}
	else
	{
		document.getElementById('otherQualify').style.display='none';
	}
}

function displayprogram()
{	
	var i;
	var selectbox = document.form1.cboCourses;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		selectbox.remove(i);
	}
	var experience=document.getElementById('slctWorkExperience').value;
	option0 = new Option("--Select--","");
	document.form1.cboCourses.options[0] = option0;
// 	if(experience=='2-3')
// 	{
// 		option1 = new Option('Certificate Program in Management of Software Development','Certificate Program in Management of Software Development');
// 		document.form1.cboCourses.options[1] = option1;
// 	}
	if(experience == '0-1')
        {
            option1 = new Option('Executive Program for Future Leaders','Executive Program for Future Leaders');
            document.form1.cboCourses.options[1] = option1;
        }
        else if (experience=='0-2') {
                option1 = new Option('Advanced Program in Digital Marketing (IAMAI)','Advanced Program in Digital Marketing (IAMAI)');
                option2 = new Option('Fundamentals of Finance for Non-Finance Executives (FNFE)','Fundamentals of Finance for Non-Finance Executives (FNFE)');
                document.form1.cboCourses.options[2] = option2;
                document.form1.cboCourses.options[1] = option1;

        }
//         else if(experience == '2 years')
//         {
//             option1 = new Option('Executive Program for Future Leaders','Executive Program for Future Leaders');
//             option2 = new Option('Certificate Program in Management of Software Development','Certificate Program in Management of Software Development');
//             document.form1.cboCourses.options[1] = option1;
//             document.form1.cboCourses.options[2] = option2;
//         }
        else if ( experience=='3-5')
	{
            
            /*option1 = new Option('Executive Program for Future Leaders','Executive Program for Future Leaders');
         //   option2 = new Option('Certificate Program in Management of Software Development','Certificate Program in Management of Software Development');
            option3 = new Option('Executive Program in Applied Finance','Executive Program in Applied Finance');*/
            if(experience=='3-5')
            {
                option2 = new Option('Post Graduate Certificate Program in International Business','Post Graduate Certificate Program in International Business');
                option1 = new Option('Advanced Program in Digital Marketing (IAMAI)','Advanced Program in Digital Marketing (IAMAI)');
                option3 = new Option('Fundamentals of Finance for Non-Finance Executives (FNFE)','Fundamentals of Finance for Non-Finance Executives (FNFE)');
               
                
            }
            
                
           
	       document.form1.cboCourses.options[1] = option1;
		document.form1.cboCourses.options[2] = option2;
                 document.form1.cboCourses.options[3] = option3;
	//	document.form1.cboCourses.options[2] = option2;
		/*document.form1.cboCourses.options[2] = option3;
		document.form1.cboCourses.options[3] = option4;*/
	}
	else if(experience=='6-9' || experience=='10-12' || experience=='13-15' || experience== 'greater than 15')
	{
              //  option1 = new Option('Executive Program for Future Leaders','Executive Program for Future Leaders');
            //    option2 = new Option('Certificate Program in Management of Software Development','Certificate Program in Management of Software Development');
               // option3 = new Option('Executive Program in Applied Finance','Executive Program in Applied Finance');
		//option4 = new Option('Advanced Program in Strategic Management','Advanced Program in Strategic Management');
                option1 = new Option('Advanced Program in Digital Marketing (IAMAI)','Advanced Program in Digital Marketing (IAMAI)');
                
		 option5 = new Option('Post Graduate Certificate Program in International Business','Post Graduate Certificate Program in International Business');
                option3 = new Option('Fundamentals of Finance for Non-Finance Executives (FNFE)','Fundamentals of Finance for Non-Finance Executives (FNFE)');
		/*document.form1.cboCourses.options[1] = option1;
	//	document.form1.cboCourses.options[2] = option2;
		document.form1.cboCourses.options[2] = option3;*/
		//document.form1.cboCourses.options[4] = option4;
                document.form1.cboCourses.options[1] = option1;
		document.form1.cboCourses.options[2] = option5;
                document.form1.cboCourses.options[3] = option3;
	}
// if(valchk=='below 50%')
// {
// displayprogram2();
// }
	
}
//var vPageName=document.getElementById('sPageName').value;
var valchk='';
function displayprogram2()
{
	var i;
	var selectbox = document.form1.cboCourses;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		selectbox.remove(i);
	}
	var count=document.form1.rdGrad.length;
	for(var i=0;i<count;i++)
	{
		if(document.form1.rdGrad[i].checked==true)	
		var val=document.form1.rdGrad[i].value;
		valchk=val;
	}
	option0 = new Option("--Select--","");
	document.form1.cboCourses.options[0] = option0;
	var vPageName=document.getElementById('sPageName').value;
	switch(val)
	{
		case 'below 50%':
			if(vPageName!='/supply-management-overview-new.php' && vPageName!='/supply-management-overview-new2.php' && vPageName!='/index-about-imperia-new2.php' && vPageName!='/gallery-new2.php' && vPageName!='/testimonials-new2.php' && vPageName!='/news-new2.php' && vPageName!='/competitive-strategy-overview-new.php' && vPageName!='/competitive-strategy-overview-new3.php' && vPageName!='/index-about-imperia-new3.php' && vPageName!='/gallery-new3.php' && vPageName!='/testimonials-new3.php' && vPageName!='/news-new3.php')
			{
                               displayprogram();
//                              option1 = new Option('Executive Program for Future Leaders','Executive Program for Future Leaders');
//                              document.form1.cboCourses.options[1] = option1;
				//option1 = new Option('Executive Program in Human Resource Management','Executive Program in Human Resource Management')
				//document.form1.cboCourses.options[1] = option1;
			}
			break;
		case 'above 50%':
			if(vPageName=='/supply-management-overview-new.php' || vPageName=='/supply-management-overview-new2.php' || vPageName=='/index-about-imperia-new2.php' || vPageName=='/gallery-new2.php' || vPageName=='/testimonials-new2.php' || vPageName=='/news-new2.php')
			{
				option1 = new Option('Executive Program on Supply Chain Management','Executive Program on Supply Chain Management')
				document.form1.cboCourses.options[1] = option1;
			}
			else if(vPageName=='/competitive-strategy-overview-new.php' || vPageName=='/competitive-strategy-overview-new3.php' || vPageName=='/index-about-imperia-new3.php' || vPageName=='/gallery-new3.php' || vPageName=='/testimonials-new3.php' || vPageName=='/news-new3.php')
			{
				option1 = new Option('Advanced Program on Competitive Strategy','Advanced Program on Competitive Strategy')
				document.form1.cboCourses.options[1] = option1;			
				
			}
			else
			{	
				displayprogram();
			}
			break;
	}
}
function changeFieldName()
{
	var prog;
	prog = document.form1.cboCourses.value;
	//alert(prog);
	if ("Executive Program in Applied Finance" == prog || "Senior Management Program" == prog )
	{
		document.getElementById('percField').innerHTML = "Graduate / Post Graduate %";
	}
	else
	{
		document.getElementById('percField').innerHTML = "Graduation Percentage";
	}
}

function get_radio_value()
{
for (var i=0; i < document.form1.rdGrad.length; i++)
   {
   if (document.form1.rdGrad[i].checked)
      {
      var rad_val = document.form1.rdGrad[i].value;
      return rad_val;
      }
   }
}

// init = function () 
// {
// 	displayprogram2();
// }
// if (document.getElementById('sPageName').value == '/index.php')
// {
// 	window.onload = init ;
// }
