jQuery(document).ready(function() {
	/* **************************************** */
	jQuery("#feedback").fancybox({
		'autoScale'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'margin'	: 0,
		'overlayShow'	: true,
		'hideOnOverlayClick'	: false,
		'centerOnScroll'	: true
	});
	jQuery("#feedback_contact").fancybox({
		'autoScale'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'margin'	: 0,
		'overlayShow'	: true,
		'hideOnOverlayClick'	: false,
		'centerOnScroll'	: true
	});
	jQuery("#rorpopup").fancybox({
		'autoScale'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'margin'	: 0,
		'overlayShow'	: true,
		'hideOnOverlayClick'	: false,
		'centerOnScroll'	: true
	});
	jQuery("#androidpopup").fancybox({
		'autoScale'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'margin'	: 0,
		'overlayShow'	: true,
		'hideOnOverlayClick'	: false,
		'centerOnScroll'	: true
	});
	jQuery("#phppopup").fancybox({
		'autoScale'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'margin'	: 0,
		'overlayShow'	: true,
		'hideOnOverlayClick'	: false,
		'centerOnScroll'	: true
	});
	jQuery("#what").fancybox({
		'autoScale'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'margin'	: 0,
		'overlayShow'	: true,
		'hideOnOverlayClick'	: false,
		'centerOnScroll'	: true
	});	
	jQuery("#rubi_rail").fancybox({
		'autoScale'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'margin'	: 0,
		'overlayShow'	: true,
		'hideOnOverlayClick'	: false,
		'centerOnScroll'	: true
	});
	jQuery("#asp_link").fancybox({
		'autoScale'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'margin'	: 0,
		'overlayShow'	: true,
		'hideOnOverlayClick'	: false,
		'centerOnScroll'	: true
	});	
	jQuery("#php_link").fancybox({
		'autoScale'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'margin'	: 0,
		'overlayShow'	: true,
		'hideOnOverlayClick'	: false,
		'centerOnScroll'	: true
	});	
	jQuery("#feedback").click(function(){
									   
		jQuery("#frmContactP input").attr('disabled', false);
		jQuery("#frmContactP input").css('color', '#000');
		jQuery("#frmContactP textarea").attr('disabled', false);
		jQuery("#frmContactP textarea").css('color', '#000');
		jQuery("#frmContactP select").attr('disabled', false);
		jQuery("#frmContactP select").css('color', '#000');
									   
		jQuery("#txt_NameP").val("");
		jQuery("#txt_EmailP").val("");
		jQuery("#txt_PhoneP").val("");
		jQuery("#txa_DescP").val("");
		jQuery("#txt_HowP").val("");
		jQuery("#codeP").val("");
		jQuery("#touch_error_message_div").css("display","none");
		jQuery("#touch_error_message_div").html("");
		try{
			//document.getElementById('img_CaptchaP').src="get_captcha.php?rnd=" + Math.random();
		}catch(e){}
		
		jQuery("#messageP").html('');
		jQuery("#resetP").show();
		jQuery("#cmd_submitP").show();
		
		jQuery("#getin_wait").hide();
		jQuery("#getin_done").hide();
		jQuery("#getin_wait").attr('disabled', '');
	});

	/* **************************************** */
	jQuery("#invoice_download").fancybox({
		'scrolling'		: 'no',
		'height'	: '600',
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'margin'	: 0,
		'overlayShow'	: true,
		'hideOnOverlayClick'	: false,
		'centerOnScroll'	: true
		});
	
	jQuery("#android_download").fancybox({
		'scrolling'		: 'no',
		'height'	: '600',
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'margin'	: 0,
		'overlayShow'	: true,
		'hideOnOverlayClick'	: false,
		'centerOnScroll'	: true
		});

	jQuery("#invoice_download").click(function(){
		jQuery("#messageI").html('');
		jQuery("#disclaimer_div").css("display","block");
		jQuery("#invoice_div").css("display","none");
		
		clear_invoice_form()
		jQuery("#reset_invoice").show();
		jQuery("#invoice_submit").show();
		
		jQuery("#invoice_wait").hide();
		jQuery("#invoice_done").hide();
		//jQuery("#invoice_wait").val("Please wait...");
		jQuery("#invoice_wait").attr('disabled', '');
	});
	
	jQuery("#android_download").click(function(){
		jQuery("#messageA").html('');
		jQuery("#android_div").css("display","block");
		jQuery("#android_invoice_div").css("display","none");
		
		clear_android_form();
		jQuery("#reset_android_invoice").show();
		jQuery("#android_invoice_submit").show();
		
		jQuery("#android_invoice_wait").hide();
		jQuery("#android_invoice_done").hide();
		//jQuery("#invoice_wait").val("Please wait...");
		jQuery("#android_invoice_wait").attr('disabled', '');
	});
	/* **************************************** */




	var loader = jQuery('<div id="loader" style="z-index:999999"><img src="images/loading.gif" alt="loading..." /></div>')
		.css({position: "absolute", top: "600px", left: "50em"})
		.appendTo("body")
		.hide();
	jQuery().ajaxStart(function() {
		loader.show();
	}).ajaxStop(function() {
		loader.hide();
	}).ajaxError(function(a, b, e) {
		throw e;i
	});

	/* ************************************************************************** */
	/* ********************* validation for Get In touch ************************ */
	jQuery('#cmd_submitP').click(function() {
		var touch_name_error = "";
		var temp_var = new Array();
		var err= false;
		

		var nameValP = jQuery("#txt_NameP").val();

		if(nameValP == '') {
			touch_name_error = '<label for="txt_Name" generated="true">Please enter '+"'Your Name'"+'.<br/></label>';
			temp_var.push("#txt_NameP");

			err = true;
		} else {
			jQuery("#txt_NameP").css("color","black");
		}

		var emailRegP = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var emailaddressValP = jQuery("#txt_EmailP").val();
		if(emailaddressValP == '') {
			touch_name_error += '<label for="txt_Email" generated="true">Please enter '+"'Email'"+'.<br/></label>';
			temp_var.push("#txt_EmailP");

			err = true;
		} 
		else if(!emailRegP.test(emailaddressValP)) {
			touch_name_error += '<label for="txt_Email" generated="true">Please enter valid '+"'Email'"+'.<br/></label>';
			temp_var.push("#txt_EmailP");

			err = true;
		} else {
			jQuery("#txt_EmailP").css("color","black");
		}
		
		var howP = jQuery("#txt_HowP").val();

		if(howP == '') {
			touch_name_error += '<label for="txt_How" generated="true">Please choose '+"'How did you hear about Andolasoft?'"+'.<br/></label>';
			temp_var.push("#txt_HowP");

			err = true;
		} else {
			jQuery("#txt_HowP").css("color","black");
		}
		
		var capImgValP = jQuery("#img_CaptchaP").html();
		var capInpValP = jQuery("#codeP").val();
		
		
		/*var codeVal = jQuery("#codeP").val();
		//alert(codeVal);
		if(codeVal == '') 
		{
			temp_var.push("#codeP"); 
			touch_name_error += '<label for="txt_CodeP" generated="true">Please enter digits as shown!<br/></label>';
			err = true;
		} else if(capImgValP != capInpValP){
			temp_var.push("#codeP"); 
			touch_name_error += '<label for="txt_CodeP" generated="true">Please enter digits as shown!<br/></label>';
			err = true;		
		} else {
			jQuery("#codeP").css("color","black");
		}*/
		jQuery(temp_var[0]).focus();
		jQuery(temp_var[0]).css("color","red");
		jQuery(temp_var[0]).blur(function(){
			jQuery(temp_var[0]).css("color","black");
		});



		if(err==true) { 
			jQuery("#touch_error_message_div").html(touch_name_error);
			jQuery("#touch_error_message_div").slideDown();
			return false; 
		}
		else{
		
			jQuery("#touch_error_message_div").html("");
			jQuery("#touch_error_message_div").slideUp();
			
			// After submitting, hide the reset button
			// Change text of submit button
			jQuery("#resetP").hide();
			jQuery("#cmd_submitP").hide();
			
			jQuery("#getin_wait").show();			
			jQuery("#getin_wait").attr('disabled', 'disabled');
			
		}

		jQuery.post("checkP.php?"+jQuery("#frmContactP").serialize(), {
		}, 
		function(response)
		{
			
			if(response == 1)
			{
				jQuery("#code_errorP").html('');
				jQuery("#messageP").html('');
				
				var succMsgP = "<font style='color:green;font-size:11px'><p>Dear "+nameValP+",<br/>Andolasoft has received your request for Consulting Services. We will get back to you within 4 to 6 hours.</p><div>We thank you in advance for your continued patronage.</div><div>info@andolasoft.com, (408) 564-9964</div></font>";
				
				jQuery("#messageP").html(succMsgP);
				
				change_captchaP();
				//clear_form();
				
				// If success, change the content of submit button
				// Don't clear the entered data
				
				
				// After clicking "Done", we will close the popup
				jQuery("#getin_wait").hide();
				jQuery("#getin_wait").attr('disabled', '');
				
				jQuery("#getin_done").show();
				
				jQuery("#frmContactP input").attr('disabled', true);
				jQuery("#frmContactP input").css('color', '#ccc');
				jQuery("#frmContactP textarea").attr('disabled', true);
				jQuery("#frmContactP textarea").css('color', '#ccc');
				jQuery("#frmContactP select").attr('disabled', true);
				jQuery("#frmContactP select").css('color', '#ccc');
				
				jQuery("#getin_done").click(function() {
					clear_form();
					jQuery("#fancybox-overlay").fadeOut();
					jQuery("#fancybox-wrap").css("display","none");
					jQuery("#messageP").html(''); // Clear the message
				});
				
				
			} 
			else 
			{
				temp_var.push("#codeP"); 
				touch_name_error += '<label for="txt_CodeP" generated="true">Characters do not match! Please try again.<br/></label>';
				change_captchaP();
				jQuery("#touch_error_message_div").html(touch_name_error);
				jQuery("#touch_error_message_div").slideDown();
				
				// If error, show the reset and the submit button
				jQuery("#resetP").show();
				jQuery("#cmd_submitP").show();
				
				jQuery("#getin_wait").hide();
				jQuery("#getin_wait").attr('disabled', '');
				jQuery("#getin_done").hide();
				
			}
		});

		return false;
	});


	var loader = jQuery('<div id="loader" style="z-index:999999"><img src="images/loading.gif" alt="loading..." /></div>')
		.css({position: "absolute", top: "400px", left: "50em"})
		.appendTo("body")
		.hide();


	// refresh captcha
	jQuery('a#refreshP').click(function() {change_captchaP();});

	function change_captchaP() 
	{
		document.getElementById('feedbkcapcha').src='get_captcha.php?'+Math.random();document.getElementById('codeP').focus()
	}
	
	

	jQuery('#resetP').click(function() {clear_form();});

	function clear_form()
	{
		jQuery("#txt_NameP").val('');
		jQuery("#txt_EmailP").val('');
		jQuery("#txt_PhoneP").val('');
		jQuery("#txa_DescP").val('');
		jQuery("#txt_HowP").val('');
		jQuery("#codeP").val('');
	}


	jQuery("a#lab1").fancybox({
		titleShow:false,
		autoScale:true
	});
	jQuery("a#lab2").fancybox({
		titleShow:false,
		autoScale:true
	});
	jQuery("a#lab3").fancybox({
		titleShow:false,
		autoScale:true
	});
	jQuery("a#lab4").fancybox({
		titleShow:false,
		autoScale:true
	});
	jQuery("a[rel=orangegigs]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) 
		{
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	jQuery("a[rel=ereminder]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) 
		{
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	jQuery("a[rel=easyagile]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) 
		{
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	jQuery("a[rel=wheelaroo]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) 
		{
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	jQuery("a[rel=starmicrowave]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) 
		{
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	jQuery("a[rel=traffic]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) 
		{
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	jQuery("a[rel=order]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) 
		{
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	jQuery("a[rel=error]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) 
		{
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	jQuery("a[rel=ops]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) 
		{
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	jQuery("a[rel=cms]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) 
		{
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	jQuery("a[rel=smt]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) 
		{
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	jQuery("a[rel=obi]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) 
		{
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	jQuery("a[rel=ihm]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) 
		{
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	jQuery("a[rel=wsd]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) 
		{
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	
	jQuery("a#portfolio8").fancybox({
		titleShow:false,
		autoScale:true
	});

	jQuery("a#portfolio11").fancybox({
		titleShow:false,
		autoScale:true
	});
	jQuery("a#portfolio12").fancybox({
		titleShow:false,
		autoScale:true
	});
	jQuery("a#portfolio13").fancybox({
		titleShow:false,
		autoScale:true
	});
	jQuery("a#portfolio14").fancybox({
		titleShow:false,
		autoScale:true
	});
    jQuery("a#portfolio15").fancybox({
		titleShow:false,
		autoScale:true
	});
	jQuery("a#portfolio16").fancybox({
		titleShow:false,
		autoScale:true
	});
	
});



/* ************************************************************************** */
/* ********************* validation for Get Invoice ************************ */

function show_invoice_form()
{
	jQuery("#disclaimer_div").hide();
	jQuery("#fancybox-wrap").hide();
	jQuery("#invoice_div").css("display","block");
	jQuery("#fancybox-wrap").slideDown("slow");
	jQuery("#invoice_error_message_div").css("display","none");
	jQuery("#invoice_error_message_div").html("");
	
}




jQuery(document).ready(function() {
	jQuery('#invoice_submit').click(function() {
		var invoice_name_error = "";
		var err= false;
		var temp_var = new Array;
		
		jQuery("#invoice_error_message_div").html('');
		jQuery("#invoice_error_message_div").css('display','none');
		jQuery("#messageI").html(''); // Clear the message
		
		var nameVal = jQuery("#txt_NameI").val();
		if(nameVal == '') {
			invoice_name_error = '<label for="txt_NameI" generated="true">Please enter Your Name!<br/></label>';

			temp_var.push("#txt_NameI"); 
			err = true;
		} else {
			//invoice_name_error = "";
			jQuery("#txt_NameI").css("color","black");
		}

		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var emailaddressVal = jQuery("#txt_EmailI").val();
		if(emailaddressVal == '') {
			invoice_name_error += '<label for="txt_EmailI" generated="true">Please enter Email!<br/></label>';
			temp_var.push("#txt_EmailI"); 
			err = true;
		} else if(!emailReg.test(emailaddressVal)) {
			temp_var.push("#txt_EmailI"); 
			invoice_name_error += '<label for="txt_Email" generated="true">Please enter valid Email!<br/></label>';
			err = true;
		} else {
			//invoice_name_error = "";
			jQuery("#txt_EmailI").css("color","black");
		}
		
		var planVal = jQuery("#txt_PlanI").val();
		if(planVal == '') {
			invoice_name_error += '<label for="txt_PlanI" generated="true">Please select Planning to start your .Net project!<br/></label>';

			temp_var.push("#txt_PlanI"); 
			err = true;
		} else {
			//invoice_name_error = "";
			jQuery("#txt_PlanI").css("color","black");
		}
		var capImgInvoice = jQuery("#img_CaptchaI").html();

		jQuery(temp_var[0]).focus();
		jQuery(temp_var[0]).css("color","red");
		jQuery(temp_var[0]).blur(function(){
			jQuery(temp_var[0]).css("color","black");
		});

		// refresh captcha
		jQuery('a#refreshI').click(function() {change_captchaI();});

		if(err==true) { 
			jQuery("#invoice_error_message_div").html(invoice_name_error);
			jQuery("#invoice_error_message_div").slideDown();
			return false; 
		}else{
		
			jQuery("#invoice_error_message_div").html("");
			jQuery("#invoice_error_message_div").slideUp();
			
			// After submitting, hide the reset button
			// Change text of submit button
			jQuery("#reset_invoice").hide();
			jQuery("#invoice_submit").hide();
			
			jQuery("#invoice_wait").show();
			jQuery("#invoice_wait").attr('disabled', 'disabled');
			
		}

		$.post("send_invoice_email.php?c=send_email&"+jQuery("#frmContactI").serialize(), {
			
		}, function(response){
			if( response == 0){
				invoice_name_error = '<label for="txt_Name" generated="true">Characters do not match! Please try again.<br/></label>';
				change_captchaI();
				jQuery("#codeI").focus();
				jQuery("#codeI").css("color","red");
				jQuery("#codeI").blur(function(){
					jQuery("#codeI").css("color","black");
				});


				jQuery("#invoice_error_message_div").html(invoice_name_error);
				jQuery("#invoice_error_message_div").slideDown();
				
				// If error, show the reset and the submit button
				jQuery("#reset_invoice").show();
				jQuery("#invoice_submit").show();
				jQuery("#invoice_wait").hide();
			}else{
				invoice_name_error = "";
				
				jQuery("#messageI").html('');
				jQuery("#messageI").html('<p style="color:green;font-size:14px">Thanks \''+ nameVal +'\', an email has been sent to your email with the link to download the Invoice Generator.</p>');
				
				//clear_invoice_form();
				// If success, close the error div 
				//jQuery("#invoice_error_message_div").html("");
				//jQuery("#invoice_error_message_div").css("display","none");
				// If success, change the content of submit button
				// Don't clear the entered data
				
				// After clicking "Done", we will close the popup
				jQuery("#invoice_done").show();
				jQuery("#invoice_wait").hide();
				jQuery("#invoice_wait").attr('disabled', '');
				jQuery("#invoice_done").click(function() {
					//clear_invoice_form();
					jQuery("#reset_invoice").show();
					jQuery("#invoice_submit").show();
					
					close_invoice_div();
					
				});
				
			}

		});
		return false;
	});
});

function change_captchaI() {
	
	document.getElementById('img_CaptchaI').src='get_captcha.php?'+Math.random();document.getElementById('codeI').focus()
}


function clear_invoice_form(){
	jQuery("#txt_NameI").val("");
	jQuery("#txt_EmailI").val("");
	jQuery("#txt_CompanyI").val("");
	jQuery("#txt_PlanI").val("");
	jQuery("#txt_PhoneI").val("");
	
	jQuery("#codeI").val("");
	try{
		//document.getElementById('img_CaptchaI').src="get_captcha.php?rnd=" + Math.random();
	}catch(E){}
	jQuery("#invoice_error_message_div").html("");
	jQuery("#invoice_error_message_div").css("display","none");
}

function close_invoice_div(){
	jQuery("#messageI").html(''); // Clear the message
	jQuery("#invoice_div").css("display","none");
	
	jQuery("#fancybox-overlay").fadeOut();
	jQuery("#fancybox-wrap").css("display","none");

	jQuery("#disclaimer_div").css("display","block");
}



/************ ANDROID DOWNLOAD **************/

function clear_android_form(){
	jQuery("#txt_NameA").val("");
	jQuery("#txt_EmailA").val("");
	jQuery("#txt_CompanyA").val("");
	jQuery("#txt_PlanA").val("");
	jQuery("#txt_PhoneA").val("");
	
	jQuery("#codeA").val("");
	try{
		//document.getElementById('img_CaptchaI').src="get_captcha.php?rnd=" + Math.random();
	}catch(E){}
	jQuery("#android_error_message_div").html("");
	jQuery("#android_error_message_div").css("display","none");
}
function close_android_div(){
	jQuery("#messageA").html(''); // Clear the message
	jQuery("#android_div").css("display","none");
	
	jQuery("#fancybox-overlay").fadeOut();
	jQuery("#fancybox-wrap").css("display","none");

	jQuery("#disclaimer_div").css("display","block");
}
function show_android_form()
{
	jQuery("#android_div").hide();
	jQuery("#fancybox-wrap").hide();
	jQuery("#android_invoice_div").css("display","block");
	jQuery("#fancybox-wrap").slideDown("slow");
	jQuery("#android_error_message_div").css("display","none");
	jQuery("#android_error_message_div").html("");
}
function change_captchaA() {
	document.getElementById('img_CaptchaA').src='get_captcha.php?'+Math.random();document.getElementById('codeA').focus()
}
jQuery(document).ready(function() {
	jQuery('#android_invoice_submit').click(function() {
		var android_name_error = "";
		var err= false;
		var temp_var = new Array;
		
		jQuery("#android_error_message_div").html('');
		jQuery("#android_error_message_div").css('display','none');
		jQuery("#messageA").html(''); // Clear the message
		
		var nameVal = jQuery("#txt_NameA").val();
		if(nameVal == '') {
			android_name_error = '<label for="txt_NameA" generated="true">Please enter Your Name!<br/></label>';

			temp_var.push("#txt_NameA"); 
			err = true;
		} else {
			//android_name_error = "";
			jQuery("#txt_NameA").css("color","black");
		}

		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var emailaddressVal = jQuery("#txt_EmailA").val();
		if(emailaddressVal == '') {
			android_name_error += '<label for="txt_EmailA" generated="true">Please enter Email!<br/></label>';
			temp_var.push("#txt_EmailA"); 
			err = true;
		} else if(!emailReg.test(emailaddressVal)) {
			temp_var.push("#txt_EmailA"); 
			android_name_error += '<label for="txt_Email" generated="true">Please enter valid Email!<br/></label>';
			err = true;
		} else {
			//android_name_error = "";
			jQuery("#txt_EmailA").css("color","black");
		}
		
		var planVal = jQuery("#txt_PlanA").val();
		if(planVal == '') {
			android_name_error += '<label for="txt_PlanA" generated="true">Please select Planning to start your .Net project!<br/></label>';

			temp_var.push("#txt_PlanA"); 
			err = true;
		} else {
			//android_name_error = "";
			jQuery("#txt_PlanA").css("color","black");
		}
		var capImgInvoice = jQuery("#img_CaptchaA").html();

		jQuery(temp_var[0]).focus();
		jQuery(temp_var[0]).css("color","red");
		jQuery(temp_var[0]).blur(function(){
			jQuery(temp_var[0]).css("color","black");
		});

		// refresh captcha
		jQuery('a#refreshA').click(function() {change_captchaA();});

		if(err==true) { 
			jQuery("#android_error_message_div").html(android_name_error);
			jQuery("#android_error_message_div").slideDown();
			return false; 
		}else{
		
			jQuery("#android_error_message_div").html("");
			jQuery("#android_error_message_div").slideUp();
			
			// After submitting, hide the reset button
			// Change text of submit button
			jQuery("#reset_android_invoice").hide();
			jQuery("#android_submit").hide();
			
			jQuery("#android_invoice_wait").show();
			jQuery("#android_invoice_wait").attr('disabled', 'disabled');
			
		}

		$.post("send_android_email.php?c=send_email&"+jQuery("#frmContactA").serialize(), {
			
		}, function(response){
			if( response == 0){
				android_name_error = '<label for="txt_Name" generated="true">Characters do not match! Please try again.<br/></label>';
				change_captchaA();
				jQuery("#codeA").focus();
				jQuery("#codeA").css("color","red");
				jQuery("#codeA").blur(function(){
					jQuery("#codeA").css("color","black");
				});


				jQuery("#android_error_message_div").html(android_name_error);
				jQuery("#android_error_message_div").slideDown();
				
				// If error, show the reset and the submit button
				jQuery("#reset_android_invoice").show();
				jQuery("#android_submit").show();
				jQuery("#android_invoice_wait").hide();
			}else{
				android_name_error = "";
				
				jQuery("#messageA").html('');
				jQuery("#messageA").html('<p style="color:green;font-size:14px">Thanks \''+ nameVal +'\', an email has been sent to your email with the link to download the Invoice Generator.</p>');
				
				//clear_android_form();
				// If success, close the error div 
				//jQuery("#android_error_message_div").html("");
				//jQuery("#android_error_message_div").css("display","none");
				// If success, change the content of submit button
				// Don't clear the entered data
				
				// After clicking "Done", we will close the popup
				jQuery("#android_invoice_done").show();
				jQuery("#android_invoice_wait").hide();
				jQuery("#android_invoice_wait").attr('disabled', '');
				jQuery("#android_invoice_done").click(function() {
					//clear_android_form();
					jQuery("#reset_android_invoice").show();
					jQuery("#android_submit").show();
					
					close_android_div();
					
				});
				
			}

		});
		return false;
	});
});
/* *************************** Get Invoice ends here ******************************** */



