// JavaScript Document
function sendContact() {
			var name = $("input#posName").val();
			var email = $("input#posEmail").val();
			var posRegard = $("input#posRegard").val();
			var phone = $("input#posphone").val();
			var posloc = $("input#posloc").val();
			var comments = $("textarea#posText").val();
			if(name==null || name==""){
				alert("Please Enter your Name");
				$("input#posName").focus();
				return false;
			}
			if(posRegard==null || posRegard==""){
				alert("Please Enter Institution you belong to");
				$("input#posRegard").focus();
				return false;
			}
			if(posloc==null || posloc==""){
				alert("Please Enter Location");
				$("input#posloc").focus();
				return false;
			}
			if(phone==null || phone==""){
				alert("Please Enter your phone no");
				$("input#posphone").focus();
				return false;
			}
			if ((email==null)||(email=="")){
				alert("Please Enter your Email ID");
				$("input#email").focus();
				return false;
			}
			if (echeck(email)==false){
				email="";
				$("input#email").focus();
				return false;
			}
			
			if ((comments==null)||(comments=="")){
				alert("Please Comments");
				$("textarea#posText").focus();
				return false;
			}
			var isCheck = 'No';
			if($("#selfCC").is(':checked')){
				isCheck = 'Yes';
			}

			$.ajax({
			   type: "POST",
			   url: "postContact.php",
			   data: "name=" + encodeURIComponent(name) + "&email=" + encodeURIComponent(email)+"&posphone="+encodeURIComponent(phone)+ "&posloc="+encodeURIComponent(posloc)+ "&posRegard="+encodeURIComponent(posRegard) + "&comments="+encodeURIComponent(comments)+ "&selfCC="+encodeURIComponent(isCheck),	
			   success: function (res) {
				   if(res ==1){
					   	$("input#posName").val('');
						$("input#posEmail").val('');
						$("input#posRegard").val('');
						$("input#posphone").val('');
						$("input#posloc").val('');
						$("textarea#posText").val('');
			   			alert("Your request has been forwarded to us. We shall get back to you shortly.");
				   }
			   }
			 });
		}
		
		function echeck(str) {

			var at="@"
			var dot="."
			var lat=str.indexOf(at)
			var lstr=str.length
			var ldot=str.indexOf(dot)
			if (str.indexOf(at)==-1){
			   alert("Invalid E-mail ID")
			   return false
			}
	
			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			   alert("Invalid E-mail ID")
			   return false
			}
	
			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
				alert("Invalid E-mail ID")
				return false
			}
	
			 if (str.indexOf(at,(lat+1))!=-1){
				alert("Invalid E-mail ID")
				return false
			 }
	
			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
				alert("Invalid E-mail ID")
				return false
			 }
	
			 if (str.indexOf(dot,(lat+2))==-1){
				alert("Invalid E-mail ID")
				return false
			 }
			
			 if (str.indexOf(" ")!=-1){
				alert("Invalid E-mail ID")
				return false
			 }
	
			 return true					
		}


function resetContact_form() {
	document.getElementById('cForm').reset();
}


function sendrfp() {
			var isSubmit = true;
			var email = $("input#email").val();
			var contact_name = $("input#contact_name").val();
			var project_delivery_date = $("input#project-delivery-date").val();
			var phone = $("input#posphone").val();
			var posloc = $("input#posloc").val();
			var comments = $("textarea#posText").val();
			
			if((contact_name==null || contact_name=="") &&  isSubmit == true){
				alert("Please Enter Contact Name");
				$("input#posRegard").focus();
				isSubmit = false;
			}
			if ((email==null || email=="") &&  isSubmit == true){
				alert("Please Enter your Email ID");
				$("input#email").focus();
				isSubmit = false;
			}
			if(isSubmit == true) {
				if ((echeck(email)==false)){
					email="";
					$("input#email").focus();
					isSubmit = false;
				}
			}
			if((project_delivery_date==null || project_delivery_date=="") &&  isSubmit == true){
				alert("Please Enter Project Delivery Date");
				$("input#posloc").focus();
				isSubmit = false;
			}
			/*if(phone==null || phone==""){
				alert("Please Enter your phone no");
				$("input#posphone").focus();
				isSubmit = false;
			}
			if ((email==null)||(email=="")){
				alert("Please Enter your Email ID");
				$("input#email").focus();
				isSubmit = false;
			}
			if (echeck(email)==false){
				email="";
				$("input#email").focus();
				isSubmit = false;
			}
			
			if ((comments==null)||(comments=="")){
				alert("Please Comments");
				$("textarea#posText").focus();
				isSubmit = false;
			}*/
			if(isSubmit == true){
				document.cForm.submit();
			}

			
		}
		function open_rfp_form(id) {
			if($('#'+id).is(':hidden') == false){
				$('#'+id+'_h3').removeClass("rfp_open");
				$('#'+id+'_h3').addClass("rfp_hide");
			}else{
				$('#'+id+'_h3').removeClass("rfp_hide");
				$('#'+id+'_h3').addClass("rfp_open");
			}
		}
		function solution_desc(id) {
			var max_i = 0;
			var min_i = 0;
			if(id <= 7) {
				min_i = 1;
				max_i = 7;	
			}else if(id <= 11) { 
				min_i = 8;
				max_i = 11;	
			}
			
			for(var i = min_i; i <= max_i; i++) {
				if(i == id) {
					//alert('solution_title_'+i);
					$('#solution_desc_'+i).removeClass('accordion_sub_content_hide');
					$('#solution_desc_'+i).addClass('accordion_sub_content_open');	
					$('#solution_title_'+i).removeClass('accordion_sub_title_hide');
					$('#solution_title_'+i).addClass('accordion_sub_title_open');	
					$('#accordion_li_'+i).addClass('accordion_li_active');	
				}else{
					//alert('solution_title_'+i);
					$('#solution_desc_'+i).removeClass('accordion_sub_content_open');
					$('#solution_desc_'+i).addClass('accordion_sub_content_hide');
					$('#solution_title_'+i).removeClass('accordion_sub_title_open');
					$('#solution_title_'+i).addClass('accordion_sub_title_hide');
					$('#accordion_li_'+i).removeClass('accordion_li_active');
				}
				
			}
			//$(this).addClass('accordion_sub_content_open');
		}
		
		function secondary_page(node) {
			//alert(node);
			var str = '<div class="loading_img">&nbsp;</div>';
			$('#solution_sub_content').html(str);
			$('#solution_sub_title').html('');
			$('#solution_sub_title').show('');
			$.ajax({	
				  type:"POST",
				  url:"ax_sub_content.php",
				  data:"node="+node,
				  success:function (res) {
					 var res_array = res.split("|#^#|");
					$('#solution_sub_title').html(res_array[0]);
					$('#solution_sub_content').html('<p>'+res_array[1]+'</p>');
					
				  }
			});	
		 // alert("ok");
		  return false;
		}
		
		function set_font_size(font_class){
			//alert(font_class);
			$('#right_sub_div').height('auto');
			$('#left_sub_div').height('auto');
			$.ajax({
			   type: "POST",
			   url: "setfont.php",
			   data: "font_class=" + font_class,	
			   success: function (res) {
					  $('#body').removeClass("normal");
					  $('#body').removeClass("middle");
					  $('#body').removeClass("large");
					  $('#body').addClass(font_class);
					  if($('#left_sub_div').height() >= $('#right_sub_div').height()){
						$('#right_sub_div').height($('#left_sub_div').height()+'px');
					}else{
						$('#left_sub_div').height($('#right_sub_div').height()+'px');
					}
			   }
			 });
		}
		function redirect_new_page(url_link) {	
			window.location = url_link;
		}
		
		function checkCapcha() {
		//alert($("#code").val());
		
		$.ajax({
		url: 'capcha/success.php',
		type: 'POST',
		data: 'code='+$("#code").val(),
		dateType: 'text',
		timeout: 50000,
		error: function(){
			alert('Error loading ');
		},
		success: function(res){
			if(res == 1){
				document.forms["cForm"].submit();
				return true;
			}else{

				capcha_imgare_create();
				return false;
			}
		}
	});
	return false;
	}
	
	
	function capcha_imgare_create(){
		//alert("ok");
		$.ajax({
			url: 'capcha/capcha_img.php',
			type: 'POST',
			data: 'code='+$("#code").val(),
			dateType: 'text',
			timeout: 50000,
			error: function(){
				alert('Error loading ');
			},
			success: function(res){
				//alert(res);
				$("#capcha").html(res);
				$("#code").val('');
			}
		});
	}
