/*
 * contactable 1.2.1 - jQuery Ajax contact form
 *
 * Copyright (c) 2009 Philip Beel (http://www.theodin.co.uk/)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * Revision: $Id: jquery.contactable.js 2010-01-18 $
 *
 */
 
//extend the plugin

$(document).ready(function(){
 
    $("#contactTab").toggle(function(){
    $("#quoteForm").css({"display":"none", "margin-right":"0"}),$("#contactTab").css({"display":"none", "margin-right":"937"});
    $("#quoteForm").toggle("fast"),$("#contactTab").toggle("fast");},
    function(){
    $("#quoteForm").toggle("slow"),$("#contactTab").css("margin-right","-3");}
    );
    $("#cqbutton").click(function(){
    $("#quoteForm").hide("slow");
    });
   
    $("#contactable").toggle(function(){
    $("#contactForm").css({"display":"none", "margin-left":"-4"}),$("#contactable").css({"display":"none", "margin-left":"393"});
    $("#contactForm").toggle("fast"),$("#contactable").toggle("fast");},
    function(){
    $("#contactForm").toggle("slow"),$("#contactable").css("margin-left","-3");}
    );
    $("#cfbutton").click(function(){
    $("#contactForm").hide("slow");
    });
    });
function send_quote_form() {
       			var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
			var name = $('#quoteForm_name').val();
			if(name==''){
			$("#qutote_name").css("color","red");
                        $('#qutote_name').html("Please enter your name");
                        return;}
			else {
			$("#qutote_name").css("color","white");
                        $('#qutote_name').html("Name");}
			var organisation_name = $('#quoteForm_organisation').val();
			if(organisation_name==''){
			$("#o_name").css("color","red");
                        $('#o_name').html("Please enter Organization name");
                        return;}
			else {
			$("#o_name").css("color","white");
                        $('#o_name').html("Organisation");}
			var organisation_type = $('#quoteForm_organisationtype').val();
			var housenumber = $('#quoteForm_housenumber').val();
			var town = $('#quoteForm_town').val();
			var postcode = $('#quoteForm_postcode').val();
			var tel = $('#quoteForm_telephone').val();
			var email = $('#quoteForm_email').val();
			if(email==''){
			$("#q_mail").css("color","red");
                        $('#q_mail').html("Email-id required");
                        return;}
			else if(!emailReg.test(email)) {
			$("#q_mail").css("color","red");
                        $('#q_mail').html("Email-id invalid");
                        return;}
			else {
			$("#q_mail").css("color","white");
                        $('#q_mail').html("Email");}
			var product_type = $('#quoteForm_producttype').val();
			if(product_type==''){
			$("#pr_type").css("color","red");
                        $('#pr_type').html("Enter the product type");
                        return;}
			else {
			$("#pr_type").css("color","white");
                        $('#pr_type').html("Product Type (e.g. Flyers)");}
			var paper_type = $('#quoteForm_papertype').val();
			if(paper_type==''){
			$("#p_type").css("color","red");
                        $('#p_type').html("Enter the paper type");
                        return;}
			else {
			$("#p_type").css("color","white");
                        $('#p_type').html("Paper Type (e.g. 130gsm gloss)");}
			var paper_size = $('#quoteForm_papersize').val();
			if(paper_size==''){
			$("#p_size").css("color","red");
                        $('#p_size').html("Enter the paper size");
                        return;}
			else {
			$("#p_size").css("color","white");
                        $('#p_size').html("Paper Size");}
			var quantity = $('#quoteForm_quantity').val();
			if(quantity==''){
			$("#p_quantity").css("color","red");
                        $('#p_quantity').html("Enter the quantity");
                        return;}
			else {
			$("#p_quantity").css("color","white");
                        $('#p_quantity').html("Quantity");}
			var folding = $('#quoteForm_folding').val();
			var artwork = $('#quoteForm_artwork').val();
			var delivery_date = $('#quoteForm_deliverydate').val();
			if(delivery_date==''){
			$("#d_date").css("color","red");
                        $('#d_date').html("Enter the delivery date");
                        return;}
			else {
			$("#d_date").css("color","white");
                        $('#d_date').html("When do you need it by?");}
			var rusedbefore = $('#quoteForm_usedbefore').val();
	  		var postData = { 'c_name': name,
			   'org_name': organisation_name,
			   'org_type': organisation_type, 
			   'house_no': housenumber,
			   'Town': town, 
			   'post_code': postcode,
			   'tel_no': tel, 
			   'email_id': email,
			   'producttype': product_type, 
			   'papertype': paper_type,
			   'papersize': paper_size, 
			   'Quantity': quantity,
			   'Folding': folding, 
			   'Artwork': artwork,
			   'deliverydate': delivery_date, 
			   'usedbefore': rusedbefore };
	  		   $.post( 'quotemail.php', postData, function(res){
				if(res) {
	   		 		{}}}, 'json')
			$("#qthankyou").css("display","block");

 }
function send_feedback_form() {
       			var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
			var name = $('#name').val();
			if(name==''){
			$("#fname").css("color","red");
                        $('#fname').html("Enter your name");
                        return;}
			else {
			$("#fname").css("color","white");
                        $('#fname').html("Name");}
			var email = $('#email').val(); 
			if(email==''){
			$("#femail").css("color","red");
                        $('#femail').html("Email-id required");
                        return;}
			else if(!emailReg.test(email)) {
			$("#femail").css("color","red");
                        $('#femail').html("Email-id invalid");
                        return;}
			else {
			$("#femail").css("color","white");
                        $('#femail').html("Email");}
			var comment = $('#comment').val(); 
			if(comment==''){
			$("#fcomment").css("color","red");
                        $('#fcomment').html("Enter your Comment");
                        return;}
			else {
			$("#fcomment").css("color","white");
                        $('#fcomment').html("How did you find our service and what improvements can we make?");}	
			var rating = $('#rating').val();
			if(rating==''){
			$("#f_rating").css("color","red");
                        $('#f_rating').html("Select your rating");
                        return;}
			else {
			$("#f_rating").css("color","white");
                        $('#f_rating').html("How did you rate our service out of 10?");}
	  		var postData = { 'f_name': name,
			   'emailid': email,
			   'Comment': comment, 
			   'Rating': rating };
	  		   $.post( 'customerfeedback.php', postData, function(res){
				if(res) {
	   		 		{}}}, 'json')
				$("#ftopline").css("color","lightSkyBlue");
                       		$('#ftopline').html("Thankyou for your feedback!");

 }

