function getData(q1,q2,position,other_value){
	
	//if(selval==""){	document.studentsearch.reset();}
	var ajaxRequest;  // The variable that makes Ajax possible!
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	
			url="http://www.seoinaustralia.net.au/SendData.php?action=stepone&q1="+q1+"&q2="+q2+"&other_value="+other_value;
			//alert(url);
			//document.write(url);
			url=url+"&sid="+Math.random();
			ajaxRequest.open("GET", url, true);
			ajaxRequest.send(null);
			
			
			ajaxRequest.onreadystatechange = function  testing(){
			if(ajaxRequest.readyState == 4){
				
				//var ajaxDisplay = document.getElementById(template_date_id+"_p_"+position);
				//ajaxDisplay.innerHTML = ajaxRequest.responseText;		
			}
	}
}

																		
function insertDataIN(str_var1,str_var22,str_var2,str_var3,other_value3,str_var4,str_var5){
	
	//if(selval==""){	document.studentsearch.reset();}
	var ajaxRequest;  // The variable that makes Ajax possible!
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	
			url="http://www.seoinaustralia.net.au/insertLeadData.php?action=stepone&str_var1="+str_var1+"&str_var22="+str_var22+"&str_var2="+str_var2+"&str_var3="+str_var3+"&other_value3="+other_value3+"&str_var4="+str_var4+"&str_var5="+str_var5;
			//alert(url);
			//document.write(url);
			url=url+"&sid="+Math.random();
			ajaxRequest.open("GET", url, true);
			ajaxRequest.send(null);
			
			
			ajaxRequest.onreadystatechange = function  testing(){
			if(ajaxRequest.readyState == 4){
				
				var ajaxDisplay = document.getElementById('abc');
				ajaxDisplay.innerHTML = ajaxRequest.responseText;		
			}
	}
}
$(function() { var str_var1; var str_var2;
													  
														//call progress bar constructor
													  $("#progress").progressbar({ change: function() {
														
														  //update amount label when value changes
														  $("#amount").text($("#progress").progressbar("option", "value") + "%");
														} });
														
														//set click handler for next button
														$("#next").click(function(e) {
														  
															//stop form submission
															e.preventDefault();
														  
															//look at each panel
														  $(".form-panel").each(function() {
															  
																//if it's not the first panel enable the back button
																($(this).attr("id") != "panel1") ? null : $("#back").attr("disabled", "");
													
																
																
																
																var error_var="";
																var error_var1="";
																										
																//if the panel is visible fade it out
																if(document.getElementById('your_name').value==""){
																alert('Please enter your name');
																($(this).attr("id") != "panel1") ? null : $("#back").attr("disabled", "disabled");
																document.getElementById('your_name').focus();
																error_var='error';
																return false;
																}
																
																if(document.getElementById('email_id').value==""){
																alert('Please enter your email id');
																($(this).attr("id") != "panel1") ? null : $("#back").attr("disabled", "disabled");
																document.getElementById('email_id').focus();
																error_var='error';
																return false;
																}else{
																	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('email_id').value)){}else{
																	alert("Invalid Email. Please enter Valid Email ID");	
																	($(this).attr("id") != "panel1") ? null : $("#back").attr("disabled", "disabled");
																	document.getElementById('email_id').focus();														
																	return false;																
																	}
																}
																
																if(document.getElementById('phone_number').value==""){
																alert('Please enter your phone number');
																($(this).attr("id") != "panel1") ? null : $("#back").attr("disabled", "disabled");
																document.getElementById('phone_number').focus();
																error_var='error';
																return false;
																}
																
																if(document.getElementById('company_name').value==""){
																alert('Please enter your company name');
																($(this).attr("id") != "panel1") ? null : $("#back").attr("disabled", "disabled");
																document.getElementById('company_name').focus();
																error_var='error';
																return false;
																}
																
																if(document.getElementById('web_site_address').value==""){
																alert('Please enter your website address');
																($(this).attr("id") != "panel1") ? null : $("#back").attr("disabled", "disabled");
																document.getElementById('web_site_address').focus();
																error_var='error';
																return false;
																}
																
																if(document.getElementById('Job_Role').value==""){
																alert('Please enter your job role');
																($(this).attr("id") != "panel1") ? null : $("#back").attr("disabled", "disabled");
																document.getElementById('Job_Role').focus();
																error_var='error';
																return false;
																}
																
																if(document.getElementById('address').value==""){
																alert('Please enter your address');
																($(this).attr("id") != "panel1") ? null : $("#back").attr("disabled", "disabled");
																document.getElementById('address').focus();
																error_var='error';
																return false;
																}
																
																if(document.getElementById('County').value==""){
																alert('Please enter your county');
																($(this).attr("id") != "panel1") ? null : $("#back").attr("disabled", "disabled");
																document.getElementById('County').focus();
																error_var='error';
																return false;
																}
																
																if(document.getElementById('post_code').value==""){
																alert('Please enter your post code');
																($(this).attr("id") != "panel1") ? null : $("#back").attr("disabled", "disabled");
																document.getElementById('post_code').focus();
																error_var='error';
																return false;																
																}
																else{
																
																//document.getElementById('next').addEventListener('onclick', yeso(), useCapture);
																//($(this).attr("id") != "panel2") ? null : $("#next").attr("onclick", yeso());

																/*document.getElementById('next').onclick=function(){																			
																					if(!document.getElementById('q21').checked && !document.getElementById('q22').checked && !document.getElementById('q23').checked ){
																					alert('Please select one option for question one');
																					error_var1='error1';																					
																					return false;
																					//stop();																																														
																					}
																					if(document.getElementById('q23').checked && document.getElementById('q2_other').value==""){
																					alert('Please enter Other _____');
																					document.getElementById('q2_other').focus();
																					error_var1='error1';
																					return false;
																					}
																					
																					if(!document.getElementById('q31').checked && !document.getElementById('q32').checked && !document.getElementById('q33').checked){
																					alert('Please select one option for question two');
																					error_var1='error1';
																					return false;
																					}																				 
																				 //return true;	
																				 }*/														
																}											
																		
																if(error_var=="" && $(this).attr("id") == "panel1"){
																str_var1='no';	
																	
																	
																																															
																	str_var22=document.getElementById('your_name').value;
																	str_var22=str_var22+'@@'+document.getElementById('email_id').value;
																	str_var22=str_var22+'@@'+document.getElementById('phone_number').value;
																	str_var22=str_var22+'@@'+document.getElementById('company_name').value;
																	str_var22=str_var22+'@@'+document.getElementById('mobile').value;
																	str_var22=str_var22+'@@'+document.getElementById('address').value;
																	str_var22=str_var22+'@@'+document.getElementById('post_code').value;
																	str_var22=str_var22+'@@'+document.getElementById('County').value;
																	str_var22=str_var22+'@@'+document.getElementById('Job_Role').value;
																	str_var22=str_var22+'@@'+document.getElementById('web_site_address').value;

																	position=$(this).attr("id");																		
																	//alert(str_var1);
																	//alert(str_var2);
																	getData(str_var1,str_var22,position);
																	
																	var ajaxDisplay = document.getElementById('next');
																	//ajaxDisplay.innerHTML = 'Next &gt;';
																	ajaxDisplay.innerHTML = '<img src="http://www.seoinaustralia.net.au/images/b_continue.jpg" />';
																																		
																	var ajaxDisplay = document.getElementById('back');																	
																	ajaxDisplay.innerHTML = '<img src="http://www.seoinaustralia.net.au/images/b_back.jpg" />';
																						
																} 													
																	
																			
															  ($(this).hasClass("ui-helper-hidden")) ? null : $(this).fadeOut("fast", function() {									  		
																  
																	//add hidden class and show the next panel
																	$(this).addClass("ui-helper-hidden").next().fadeIn("fast", function() {														
																																
																					  
																		//if it's the last panel disable the next button
																		($(this).attr("id") != "thanks") ? null : $("#next").attr("disabled", "disabled");
																		
																		
																		if($(this).attr("id") == "thanks"){																		
																		
																				str_var2='-Not Entered-';
																				if(document.getElementById('q21').checked){ str_var2=document.getElementById('q21').value;}
																				if(document.getElementById('q22').checked){ str_var2=document.getElementById('q22').value;}
																		
																		
																		other_value3='-Not Entered-';
																				str_var3='';
																				con='no';
																				if(document.getElementById('q31').checked){ str_var3=document.getElementById('q31').value;
																				con='yes';
																				}
																				if(document.getElementById('q32').checked){
																				if(con=='yes')
																				{ 
																				str_var3+='@@@';
																				}
																				else if(con=='no')
																				{
																				con='yes';
																				}
																				str_var3=str_var3+document.getElementById('q32').value;
																				
																				}
																				if(document.getElementById('q33').checked)
																				{ 
																				if(con=='yes')
																				{ 
																				str_var3+='@@@';
																				}
																				else if(con=='no')
																				{
																				con='yes';
																				}
																				str_var3=str_var3+document.getElementById('q33').value;
																				}
																				if(document.getElementById('q34').checked){ 
																				if(con=='yes')
																				{ 
																				str_var3+='@@@';
																				}
																				else if(con=='no')
																				{
																				con='yes';
																				}
																				
																				str_var3=str_var3+document.getElementById('q34').value;}
																				if(document.getElementById('q35').checked){ 
																				if(con=='yes')
																				{ 
																				str_var3+='@@@';
																				}
																				else if(con=='no')
																				{
																				con='yes';
																				}
																				
																				str_var3=str_var3+document.getElementById('q35').value;}
																																							
																				if(document.getElementById('q36').checked){ 
																				if(con=='yes')
																				{ 
																				str_var3+='@@@';
																				}
																				else if(con=='no')
																				{
																				con='yes';
																				}
																				str_var3=str_var3+document.getElementById('q36').value;}
																				
																				str_var3=(str_var3=='')?'-Not Entered-':str_var3;
																				if(document.getElementById('q3_other').value!=""){other_value3=document.getElementById('q3_other').value;}else{other_value3='0';}
																				
																				str_var4=(document.getElementById('q4').value=='')?'-Not Entered-':document.getElementById('q4').value;
																			str_var5=(document.getElementById('q5').value=='')?'-Not Entered-':document.getElementById('q5').value;
																				insertDataIN(str_var1,str_var22,str_var2,str_var3,other_value3,str_var4,str_var5);	
																				($(this).attr("id") != "thanks") ? null : $("#back").attr("disabled", "disabled");
																				
																				var ajaxDisplay = document.getElementById('next');
																				//ajaxDisplay.innerHTML = 'Next &gt;';
																				ajaxDisplay.innerHTML = '<img src="http://www.seoinaustralia.net.au/images/b_continue_dim.jpg" />';
																																								
																				var ajaxDisplay = document.getElementById('back');																	
																				ajaxDisplay.innerHTML = '<img src="http://www.seoinaustralia.net.au/images/b_back_dim.jpg" />';
																																																																							
																		}
																											
																										
																		//remove hidden class from new panel
																		$(this).removeClass("ui-helper-hidden");
																		
																		//update progress bar
																		var z= $("#progress").progressbar("option", "value");
																	if(z< 70 && z> 50)
																	{
																	z=67;
																	}
																		$("#progress").progressbar("option", "value", Math.floor(Math.ceil(z) + 33));
																	});
																});
															});
														});			
														
														//set click handler for back button
														$("#back").click(function(e) {
														  
															//stop form submission
															e.preventDefault();
															
															//look at each panel
														  $(".form-panel").each(function() {
																				
															  //if it's not the last panel enable the next button
																($(this).attr("id") != "thanks") ? null : $("#next").attr("disabled", "");
															  
																//if the panel is visible fade it out
															  ($(this).hasClass("ui-helper-hidden")) ? null : $(this).fadeOut("fast", function() {
																  
																	//add hidden class and show the next panel
																	$(this).addClass("ui-helper-hidden").prev().fadeIn("fast", function() {
																	
																	  //if it's the first panel disable the back button
																	($(this).attr("id") != "panel1") ? null : $("#back").attr("disabled", "disabled");
																				
																		//remove hidden class from new panel
																		$(this).removeClass("ui-helper-hidden");
																		
																	var z= $("#progress").progressbar("option", "value");
																	if(z< 50 && z>30)
																	{
																	z=33;
																	}
																		$("#progress").progressbar("option", "value", Math.floor(Math.ceil(z) - 33));
																	});
																});
															});
														});					
													});
