// JavaScript Document
Cufon.replace('h1');
Cufon.replace('#mainHeading .wrapper .mainHeading');

$(document).ready(function() {


// CYCLE

$('#hpImages').cycle();



/*// Portfolio Cycle

$('#portWrapper').cycle({ 

    speed: 2000,

	timeout: 5000, 

	next:   '.arrow',

	fx:      'custom', 

	pause:   1,

    sync: 0, 

    cssBefore: {  

        top:  0, 

        left: 766, 

        display: 'block' 

    }, 

    animIn:  { 

        left: 0 

    }, 

    animOut: {  

        top: 500 

    }, 

    delay: -1000,

	 

	

    pager:  '#thumbs', 

    pagerAnchorBuilder: function(idx, slide) { 

        // return selector string for existing anchor 

        return '#thumbs li:eq(' + idx + ') a'; 

    } 

});

*/

/*$('#portWrapper .left').hover(

        function() { $('.instruct').fadeIn(); },

        function() { $('.instruct').fadeOut(); }

    );*/



$("a[rel^='gallery']").prettyPhoto({

		animationSpeed: 'normal', /* fast/slow/normal */

		padding: 30, /* padding for each side of the picture */

		opacity: 0.85, /* Value betwee 0 and 1 */

		showTitle: true, /* true/false */

		allowresize: true, /* true/false */

		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */

		theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */

		hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */

		modal: false, /* If set to true, only the close button will close the window */

		changepicturecallback: function(){}, /* Called everytime an item is shown/changed */

		callback: function(){} /* Called when prettyPhoto is closed */

	});









//CONTACT FORM

$('#contactForm').submit(function(){

	 var action = $(this).attr('action');



		 $.post(action, {

				 name: $('#name').val(),

				 email: $('#email').val(),

				 human: $('#human').val(),

				 comments: $('#comments').val()

		 	},



			 function(data){

			 //$('#cForm').fadeIn(1000);

			 //$('.response').fadeOut(500,function(){$(this).remove()});

			 var newdatas = data.split("|||||");

			 if(newdatas.length <= 1) {

			 	newdatas[1] = data;

				}

			 $('.response').remove()

			 $('#contactform').before('<div class="response">'+newdatas[1]+'</div>');

			 $('.response').hide();

			 $('.response').fadeIn();

				 if(newdatas[0]=='true') {

					 $('.response').remove()

					 $('#contactform').before('<div class="response">'+newdatas[1]+'</div>');

					 $('.response').hide()

					 $('.response').fadeIn()

					 $('#contactform').hide();

				 }



			 }

	 );



 return false;



 });



//REQUEST A QUOTE FORM

$('#quote').submit(function(){

	 var action = $(this).attr('action');



		 $.post(action, {

				 name: $('#name').val(),

				 email: $('#email').val(),

				 company: $('#company').val(),

				 phone: $('#phone').val(),

				 website: $('#website').val(),

				 budget: $('#budget').val(),

				 reference: $('#reference').val(),

				 human: $('#human').val(),

				 projectdetails: $('#projectdetails').val()

		 	},



			 function(data){

			 //$('#cForm').fadeIn(1000);

			 //$('.response').fadeOut(500,function(){$(this).remove()});

			 var newdatas = data.split("|||||");

			 if(newdatas.length <= 1) {

			 	newdatas[1] = data;

				}

			 $('.response').remove()

			 $('#quote').before('<div class="response">'+newdatas[1]+'</div>');

			 $('.response').hide();

			 $('.response').fadeIn();

				 if(newdatas[0]=='true') {

					 $('.response').remove()

					 $('#quote').before('<div class="response">'+newdatas[1]+'</div>');

					 $('.response').hide()

					 $('.response').fadeIn()

					 $('#quote').hide();

				 }



			 }

	 );



 return false;



 });



//REFERRAL FORM

$('#referForm').submit(function(){

	 var action = $(this).attr('action');



		 $.post(action, {

				 name: $('#name').val(),

				 email: $('#email').val(),

				 phone: $('#phone').val(),

				 paypal: $('#paypal').val(),

				 comments: $('#comments').val()

		 	},



			 function(data){

			 //$('#cForm').fadeIn(1000);

			 //$('.response').fadeOut(500,function(){$(this).remove()});

			 var newdatas = data.split("|||||");

			 if(newdatas.length <= 1) {

			 	newdatas[1] = data;

				}

			 $('.response').remove()

			 $('#referForm').before('<div class="response">'+newdatas[1]+'</div>');

			 $('.response').hide();

			 $('.response').fadeIn();

				 if(newdatas[0]=='true') {

					 $('.response').remove()

					 $('#referForm').before('<div class="response">'+newdatas[1]+'</div>');

					 $('.response').hide()

					 $('.response').fadeIn()

					 $('#referForm').hide();

				 }



			 }

	 );



 return false;



 });

 

 }); // END DOC READY



/* NEWSLETTER FORM */

function whenClicked(x) {

	if (x.value == 'Please Enter Email' || x.value == "Enter your name") {

		x.value = '';

	}

};



function offClicked(x,y) {

	if (x.value == '') { // == is equal to 

		x.value = y; // = equals 

	}

};


