$(document).ready(function() { 

	$("#resumesh").click(function () {
		$("#resume").toggle("slow");
    });

	$("#friendsh").click(function () {
		$("#tellafriend").toggle("slow");
    });

	$("#friendc").click(function () {
		$("#tellafriend").hide("slow");
    });
	
	$(".help").mouseover(function () {
		$("#help_" + $(this).attr("id")).show("slow");
    }); 
	
	$(".help").mouseout(function () {
		$("#help_" + $(this).attr("id")).hide("slow");
    }); 

	function onSelectChange(){  
	var selected = $("#marital option:selected");        
		if(selected.val() === "Married"){  
			$("#ifmarried").show("slow");
		}
		else {
			$("#ifmarried").hide("slow");
		}
	}
    
	$("#marital").change(onSelectChange); 

	function onSelectChange_job(){  
	var selected = $("#jobtitle option:selected");        
		if(selected.val() === "Other"){  
			$("#otherjob").show();
		}
		else {
			$("#otherjob").hide();
		}
	}
        $("#jobtitle").change(onSelectChange_job); 
	
	$("#submit").click(function () {

		var selected = $("#jobtitle option:selected");        
		var other = $("#otherjobdetails").attr('value');        
		if(selected.val() === "Other" && other === ""){ 
			alert("Please Enter Other Job Details");
			return false;
		}
		
		var selected1 = $("#marital option:selected");         
		var other1 = $("#spouse_edu").attr('value'); 
		if(selected1.val() === "Married" && other1 === ""){ 
			alert("Please Enter Spouse's Level of Education and duration");
			return false;
		}
		
    }); 

	$(".prev_app_visa").change(function(){
		chkval1= $("#prev_app_visa1:checked").attr("value");
		chkval2= $("#prev_app_visa2:checked").attr("value");
		chkval3= $("#prev_app_visa3:checked").attr("value");
		if(chkval1 === "Yes" || chkval2 === "Yes" || chkval3 === "Yes") {
			$("#prev_app_visashowhide").show();
		}
		else {
			$("#prev_app_visashowhide").hide();
		}
	});

	$("#can_offer").change(function(){
		chkval= $("#can_offer").attr("value");
		if(chkval === "10") {
			$("#can_offer_sh").show();
		}
		else {
			$("#can_offer_sh").hide();
		}
	});

	$("#can_offer_pointcal").change(function(){
		chkval= $("#can_offer_pointcal").attr("value");
		if(chkval === "10") {
			$("#can_offer_sh").show();
		}
		else {
			$("#can_offer_sh").hide();
		}
	}); 
	
	$("#resumeh").click(function () {
		$("#resume").hide("slow");
    });

	$(".faq").click(function () {
		$("#faq_" + $(this).attr("id")).toggle("slow");
    });

	$("#what").click(function() {
		$("#csc").toggle("slow");
	});
	
	$("#subscription_submit").click(function(){
		var subscription_email = $("#subscription_email").val();
		var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
		//alert(pattern.test(subscription_email));		
		if(!pattern.test(subscription_email))
		{
			alert("Invalid Email");
			return false;
		}
		
		$.ajax({
			type: "POST",
			url: "subscription_process.php",
			data: "email="+subscription_email,
			error: function(response) {
				alert(response)
			},
			success: function(response){
				$("#status").html(response);
			}
		 });
	});
	
	
	$("#postcomment").click(function() {
		$("#shcomment").toggle("slow");
	});
	
});