actionControllerPath = "modules/utility.php" ;

function submitContactRequest(callType,nameId,companyId,companyDescId,mailId,phoneId,addressId,territoryId)
{
	var name = $e(nameId).value ;	
	var company = $e(companyId).value ;	
	var mail = $e(mailId).value ;	
	var phone = $e(phoneId).value ;	
	var address = $e(addressId).value ;	
	if(callType == 'franchisee'){
		var territory  = $e(territoryId).value ;
	}
	else{
		var territory  = "";
	}
	var businessDesc = $e(companyDescId).value;
	
	//--------------VALIDATION ------------------------
	if(name == "" || mail == "" || company == "" || phone == ""){
		alert("Please provide complete information .");return ;
	}
	dataValidation(nameId,'is_alphanumeric','1');
	dataValidation(companyId,'is_alphanumeric','1');
	echeck(mailId,'');
	dataValidation(phoneId,'is_numeric','1');
	
	if(!flagForInvalidFormVal){
		flagForInvalidFormVal = true ;
		alert("Plz give correct values for red coloured inputs.");
		return ;
	}
	//-----------------------------------------
	
	var str='&callType='+URLEncode(callType)+'&name='+URLEncode(name)+'&company='+URLEncode(company)+'&mail='+URLEncode(mail)+'&phone='+URLEncode(phone)+'&adrs='+URLEncode(address)+'&others='+territory+'&businessDesc='+businessDesc ;
	//alert(str);
	myconn = new ajaxprocess();				
	var resultFunction = function(resultObject) 
	{ 
		var response_prev = resultObject.responseText;	
		var response = returnHTML(response_prev);	
		//alert(response);
		//if(window.firefox )console.log(response);
		//response  = trim(response);
		$e(nameId).value = "" ;	
		$e(companyId).value ="";	
		$e(mailId).value ="";	
		$e(phoneId).value ="";	
		$e(addressId).value ="" ;	
		$e(companyDescId).value ="" ;	
		if(callType == 'franchisee'){
			$e(territoryId).value = "" ;
		}
		if($e('status')) $e('status').innerHTML = "Thanks for the information , we will get back to you soon .";
		showDebug("Thanks for the information , we will get back to you soon .");	
		
	};
	myconn.ajaxclass('get',actionControllerPath+'?opCode=submitContactRequest'+str ,"null",resultFunction); 	
	return;
}

function submitWorkshopRequest(nameId,collegeId,mailId,phoneId,cityId,dateId,studentsId)
{
	var name = $e(nameId).value ;	
	var college = $e(collegeId).value ;	
	var mail = $e(mailId).value ;	
	var phone = $e(phoneId).value ;	
	var city = $e(cityId).value ;	
	var expDate = $e(dateId).value ;
	var expStudents = $e(studentsId).value ; 
	var others = expDate+'&&&&'+expStudents ;
	
	//--------------VALIDATION ------------------------
	if(name == "" || mail == "" || college == "" || phone == ""){
		alert("Please provide complete information .");return ;
	}
	dataValidation(nameId,'is_alphanumeric','1');
	dataValidation(collegeId,'is_alphanumeric','1');
	echeck(mailId,'');
	dataValidation(phoneId,'is_numeric','1');
	
	if(!flagForInvalidFormVal){
		flagForInvalidFormVal = true ;
		alert("Plz give correct values for red coloured inputs.");
		return ;
	}
	//-----------------------------------------
	
	var str='&callType=workshop&name='+URLEncode(name)+'&college='+URLEncode(college)+'&mail='+URLEncode(mail)+'&phone='+URLEncode(phone)+'&city='+URLEncode(city)+'&others='+URLEncode(others) ;
	//alert(str);
	myconn = new ajaxprocess();				
	var resultFunction = function(resultObject) 
	{ 
		var response_prev = resultObject.responseText;	
		var response = returnHTML(response_prev);	
		//alert(response);
		//if(window.firefox )console.log(response);
		//response  = trim(response);
		$e(nameId).value = "" ;	
		$e(collegeId).value ="";	
		$e(mailId).value ="";	
		$e(phoneId).value ="";	
		$e(cityId).value ="" ;	
		$e(studentsId).value ="" ;	
		$e(dateId).value ="" ;	
		
		if($e('status')) $e('status').innerHTML = "Thanks for the information , we will get back to you soon .";
		showDebug("Thanks for the information , we will get back to you soon .");	
		
	};
	myconn.ajaxclass('get',actionControllerPath+'?opCode=submitWorkshopRequest'+str ,"null",resultFunction); 	
	return;
}


function applyForWorkshop(nameId,collegeId,mailId,phoneId,dateId)
{
	var name = $e(nameId).value ;	
	var college = $e(collegeId).value ;	
	var mail = $e(mailId).value ;	
	var phone = $e(phoneId).value ;	
	var workshopDate = $e(dateId).value ;	
	
	
	//--------------VALIDATION ------------------------
	if(name == "" || mail == "" || college == "" || phone == ""){
		alert("Please provide complete information .");return ;
	}
	dataValidation(nameId,'is_alphanumeric','1');
	dataValidation(collegeId,'is_alphanumeric','1');
	echeck(mailId,'');
	dataValidation(phoneId,'is_numeric','1');
	
	if(!flagForInvalidFormVal){
		flagForInvalidFormVal = true ;
		alert("Plz give correct values for red coloured inputs.");
		return ;
	}
	//-----------------------------------------
	
	var str='&callType=applyForWorkshop&name='+URLEncode(name)+'&college='+URLEncode(college)+'&mail='+URLEncode(mail)+'&phone='+URLEncode(phone)+
				'&date='+URLEncode(workshopDate) ;
	//alert(str);
	myconn = new ajaxprocess();				
	var resultFunction = function(resultObject) 
	{ 
		var response_prev = resultObject.responseText;	
		var response = returnHTML(response_prev);	
		//alert(response);
		//if(window.firefox )console.log(response);
		//response  = trim(response);
				
		if(response == 1){		
			$e(nameId).value = "" ;	
			$e(collegeId).value ="";	
			$e(mailId).value ="";	
			$e(phoneId).value ="";	
			if($e('status')) $e('status').innerHTML = "Your registration has been confirmed , we will get back to you soon .";
			//showDebug("Your registration has been confirmed , we will get back to you soon .");	
		}
		else{
			if($e('status')) $e('status').innerHTML = "Your registration is failed , Please try again .";
		}
	};
	myconn.ajaxclass('get',actionControllerPath+'?opCode=applyForWorkshop'+str ,"null",resultFunction); 	
	return;
}

function openFormToContact(customerType,auxInfo)
{
	var str = "<div id='info_forBusiness' >"+
					"<table style=\"border:0px;width:100%;\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" >"+
						"<tr style=\"height:25px;width:100%;\">"+
							"<td colspan=\"3\">"+
								"<label  style=\"color:#2177AD;\">Personal Information </label>"+
							"</td>"+
						"</tr>"+
						"<tr style=\"height:50px;width:100%;\">"+	
							"<td colspan=\"1\">"+
								"<label style=\"color:#000000;\">Your Name</label>"+
							"</td>"+
							"<td colspan=\"2\">"+
								"<input id=\"name\" type=\"textbox\" style=\"color:#2177AD;\" size=\"50\"></input>"+
								
							"</td>"+
						"</tr>"+
						"<tr style=\"height:50px;width:100%;\">"+	
							"<td colspan=\"1\">"+
								"<label   style=\"color:#000000;\">Company / Buisness Name :</label>"+
							"</td>"+
							"<td colspan=\"2\">"+
								"<input id=\"company\" type=\"textbox\" style=\"color:#2177AD;\" size=\"50\"></input>"+
								
							"</td>"+
						"</tr>"+
						'<tr style="height:50px;width:100%;">	'+
							'<td colspan="1">'+
								'<label style="color:#000000;">Buisness Description :</label>'+
							'</td>'+
							'<td colspan="2">'+
								'<textarea id=\'buisness_desc\' rows=\'3\' cols=\'38\' style="color:#2177AD;" ></textarea>'+
							'</td>'+
						'</tr>'+
						"<tr style=\"height:50px;width:100%;\">"+	
							"<td colspan=\"1\">"+
								"<label  style=\"color:#000000;\">Email Address :</label>"+
							"</td>"+
							"<td colspan=\"2\">"+
								"<input id=\"mail\" type=\"textbox\" style=\"color:#2177AD;\" size=\"50\"></input>"+
								
							"</td>"+
						"</tr>"+
						"<tr style=\"height:50px;width:100%;\">"+	
							"<td colspan=\"1\">"+
								"<label style=\"color:#000000;\">Phone No :</label>"+
							"</td>"+
							"<td colspan=\"2\">"+
								"<input id=\"phone\" type=\"textbox\" style=\"color:#2177AD;\" size=\"50\"></input>"+
								
							"</td>"+
						"</tr>"+
						"<tr style=\"height:50px;width:100%;\">"+	
							"<td colspan=\"1\">"+
								"<label style=\"color:#000000;\">Address :</label>"+
							"</td>"+
							"<td colspan=\"2\">"+
								"<textarea id='address' rows='3' cols='38' style=\"color:#2177AD;\" ></textarea>"+
							"</td>"+
						"</tr>"+											
						"<tr style=\"height:50px;width:100%;\">"+	
							"<td colspan=\"3\" style=\"text-align:center;\">"+
								"<img src=\"imgs/submit button.jpg\" onClick=\"submitContactRequest('business','name','company','buisness_desc','mail','phone','address')\"></img>"+
							"</td>"+
						"</tr>"+		
						'<tr style="height:50px;width:100%;">'+	
							'<td colspan="3" style="text-align:center;">'+
								'<div style="color:red;" id="status"></div>'+
							'</td>'+
						'</tr>'+		
					"</table>"+
				"</div>" ;
				
	var str1 = '<div id=\'info_beAFranchisee\' >'+
					'<table style="border:0px;width:100%;" cellspacing="0" cellpadding="0" border="0" >'+
						'<tr style="height:25px;width:100%;">'+
							'<td colspan="3">'+
								'<label  style="color:#2177AD;">Personal Information to become a franchisee</label>'+
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">'+	
							'<td colspan="1">'+
								'<label style="color:#000000;">Your Name</label>'+
							'</td>'+
							'<td colspan="2">'+
								'<input id="fr_name" type="textbox" style="color:#2177AD;" size="50"></input>'+
								
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">'+	
							'<td colspan="1">'+
								'<label   style="color:#000000;">Company / Buisness Name :</label>'+
							'</td>'+
							'<td colspan="2">'+
								'<input id="fr_company" type="textbox" style="color:#2177AD;" size="50"></input>'+
								
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">	'+
							'<td colspan="1">'+
								'<label style="color:#000000;">Buisness Description :</label>'+
							'</td>'+
							'<td colspan="2">'+
								'<textarea id=\'fr_Buisness_desc\' rows=\'3\' cols=\'38\' style="color:#2177AD;" ></textarea>'+
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">	'+
							'<td colspan="1">'+
								'<label  style="color:#000000;">Email Address :</label>'+
							'</td>'+
							'<td colspan="2">'+
								'<input id="fr_mail" type="textbox" style="color:#2177AD;" size="50"></input>'+
								
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">'+	
							'<td colspan="1">'+
								'<label style="color:#000000;">Phone No :</label>'+
							'</td>'+
							'<td colspan="2">'+
								'<input id="fr_phone" type="textbox" style="color:#2177AD;" size="50"></input>'+
								
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">	'+
							'<td colspan="1">'+
								'<label style="color:#000000;">Address :</label>'+
							'</td>'+
							'<td colspan="2">'+
								'<textarea id=\'fr_address\' rows=\'3\' cols=\'38\' style="color:#2177AD;" ></textarea>'+
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">'+	
							'<td colspan="1">'+
								'<label style="color:#000000;">Preferred Territory for franchisee:</label>'+
							'</td>'+
							'<td colspan="2">'+
								'<input id="fr_territory" type="textbox" style="color:#2177AD;" size="50"></input>'+
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">'+	
							'<td colspan="3" style="text-align:center;">'+
								'<img src="imgs/submit button.jpg" onClick="submitContactRequest(\'franchisee\',\'fr_name\',\'fr_company\',\'fr_Buisness_desc\',\'fr_mail\',\'fr_phone\',\'fr_address\',\'fr_territory\')"></img>'+
							'</td>'+
						'</tr>'+		
						'<tr style="height:50px;width:100%;">'+	
							'<td colspan="3" style="text-align:center;">'+
								'<div style="color:red;" id="status"></div>'+
							'</td>'+
						'</tr>'+	
					'</table>'+
				'</div>' ;
				
		var str2 = '<div id=\'info_organizeWorkshop\' >'+
					'<table style="border:0px;width:100%;" cellspacing="0" cellpadding="0" border="0" >'+
						'<tr style="height:25px;width:100%;">'+
							'<td colspan="3">'+
								'<label  style="color:#2177AD;">Information to organize a workshop</label>'+
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">'+	
							'<td colspan="1">'+
								'<label style="color:#000000;">Your Name </label>'+
							'</td>'+
							'<td colspan="2">'+
								'<input id="wrk_name" type="textbox" style="color:#2177AD;" size="50"></input>'+
								
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">'+	
							'<td colspan="1">'+
								'<label   style="color:#000000;">College Name </label>'+
							'</td>'+
							'<td colspan="2">'+
								'<input id="wrk_college" type="textbox" style="color:#2177AD;" size="50"></input>'+
								
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">	'+
							'<td colspan="1">'+
								'<label style="color:#000000;">City </label>'+
							'</td>'+
							'<td colspan="2">'+
								'<input id="wrk_city" type="textbox" style="color:#2177AD;" size="50"></input>'+
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">	'+
							'<td colspan="1">'+
								'<label  style="color:#000000;">Email Address </label>'+
							'</td>'+
							'<td colspan="2">'+
								'<input id="wrk_mail" type="textbox" style="color:#2177AD;" size="50"></input>'+
								
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">'+	
							'<td colspan="1">'+
								'<label style="color:#000000;">Phone No </label>'+
							'</td>'+
							'<td colspan="2">'+
								'<input id="wrk_phone" type="textbox" style="color:#2177AD;" size="50"></input>'+
								
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">	'+
							'<td colspan="1">'+
								'<label style="color:#000000;">Expected Date For Workshop </label>'+
							'</td>'+
							'<td colspan="2">'+
								'<input id="wrk-date" type="textbox" style="color:#2177AD;" size="50"></input>'+
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">'+	
							'<td colspan="1">'+
								'<label style="color:#000000;">Expected no. of students </label>'+
							'</td>'+
							'<td colspan="2">'+
								'<input id="wrk_students" type="textbox" style="color:#2177AD;" size="50"></input>'+
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">'+	
							'<td colspan="3" style="text-align:center;">'+
								'<img src="imgs/submit button.jpg" onClick="submitWorkshopRequest(\'wrk_name\',\'wrk_college\',\'wrk_mail\',\'wrk_phone\',\'wrk_city\',\'wrk-date\',\'wrk_students\');"></img>'+
							'</td>'+
						'</tr>'+		
						'<tr style="height:50px;width:100%;">'+	
							'<td colspan="3" style="text-align:center;">'+
								'<div style="color:red;" id="status"></div>'+
							'</td>'+
						'</tr>'+	
					'</table>'+
				'</div>' ;
				
		var str3 = '<div id=\'info_applyWorkshop\' >'+
					'<table style="border:0px;width:100%;" cellspacing="0" cellpadding="0" border="0" >'+
						'<tr style="height:25px;width:100%;">'+
							'<td colspan="3">'+
								'<label  style="color:#2177AD;">Information to apply for a workshop</label>'+
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">'+	
							'<td colspan="1">'+
								'<label style="color:#000000;">Your Name </label>'+
							'</td>'+
							'<td colspan="2">'+
								'<input id="wrk_name" type="textbox" style="color:#2177AD;" size="50"></input>'+
								
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">'+	
							'<td colspan="1">'+
								'<label   style="color:#000000;">College Name </label>'+
							'</td>'+
							'<td colspan="2">'+
								'<input id="wrk_college" type="textbox" style="color:#2177AD;" size="50"></input>'+
								
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">	'+
							'<td colspan="1">'+
								'<label  style="color:#000000;">Email Address </label>'+
							'</td>'+
							'<td colspan="2">'+
								'<input id="wrk_mail" type="textbox" style="color:#2177AD;" size="50"></input>'+
								
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">'+	
							'<td colspan="1">'+
								'<label style="color:#000000;">Phone No </label>'+
							'</td>'+
							'<td colspan="2">'+
								'<input id="wrk_phone" type="textbox" style="color:#2177AD;" size="50"></input>'+
								
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">'+	
							'<td colspan="3">'+
								'<label id="wrk_date" style="display:none;color:#000000;"></label>'+
							'</td>'+
						'</tr>'+
						'<tr style="height:50px;width:100%;">'+	
							'<td colspan="3" style="text-align:center;">'+
								'<img src="imgs/submit button.jpg" onClick="applyForWorkshop(\'wrk_name\',\'wrk_college\',\'wrk_mail\',\'wrk_phone\',\'wrk_date\');"></img>'+
							'</td>'+
						'</tr>'+		
						'<tr style="height:50px;width:100%;">'+	
							'<td colspan="3" style="text-align:center;">'+
								'<div style="color:red;" id="status"></div>'+
							'</td>'+
						'</tr>'+	
					'</table>'+
				'</div>' ;		
									
	switch(customerType)
	{
		case 'dealer' :
		case 'distributor' :
				//alert(str);
				displayStaticMessage(str,false,600,500,'');	
				break ;
		case 'franchisee' :
				//alert(str1);
				displayStaticMessage(str1,false,600,550,'');
				break ;
		case 'workshop' :
				displayStaticMessage(str2,false,600,500,'');
				break ;
		case 'applyWorkshop' :
				displayStaticMessage(str3,false,600,500,'');
				document.getElementById('wrk_date').value = auxInfo ;
				break ;
	}
	
	
}
