function pageLoaded() {
	Cufon.replace('.paper p, .call p, .ico-list li a, .bottom-bar .call span, .stay-in-touch span ', { fontFamily: 'Loved by the King', hover: true} );

	Cufon.now();
};

jQuery(document).ready(function($) {
								
$('#topbar').click(function () {
   $('#topbar').slideUp('fast');
   $('#topbar-cnt').show();

});

$('#topbar-cnt').click(function () {
   $('#topbar').slideDown('slow');
   $('#topbar-cnt').hide();
});
								
							
	//if submit button is clicked
	$('#submit').click(function () {		
		
		//Get the data from all the fields
		var name = $('input[name=name]');
		var email = $('input[name=email]');
		var phone = $('input[name=phone]');


		//Simple validation to make sure user entered something
		//If error found, add hightlight class to the text field
		if (name.val()=='') {
			name.addClass('highlight');
			return false;
		} else name.removeClass('highlight');
		
		if (email.val()=='') {
			email.addClass('highlight');
			return false;
		} else email.removeClass('highlight');
		
		
		//organize the data properly
		var data = 'name=' + name.val() + '&email=' + email.val() + '&phone=' + 
		phone.val();
		
		//disabled all the text fields
		$('.text').attr('disabled','true');
		
		//show the loading sign
		$('.loading').show();
		
		//start the ajax
		$.ajax({
			url: "process.php",	
			type: "GET",		
			data: data,		
			cache: false,

			success: function (html) {				
				if (html==1) {					
					//hide the form
					$('#quickContactShow').fadeOut('fast');	
					//show the success message
					$('#success').fadeIn('fast');
					
				//if process.php returned 0/false (send mail failed)
				} else alert('Sorry, unexpected error. Please try again later.');				
			}		
		});
		
		//cancel the submit button default behaviours
		return false;
	});	
	
	//end form
								
								
	$("div#show_button").click(function(){
		$("#paperform").animate({
			width: "500px",
			height: "160px"
		})
		.animate({
			width: "520px",
			height: "160px"
		}, "fast");
		$("div.panel_button").toggle();	
		$("div.quickContact").show(200);	
	});		
   $("div#hide_button").click(function(){
		$("#paperform").animate({
			width: "113px",
			height: "113px"
		}, "fast");	
		$("div.panel_button").toggle();	
		$("div.quickContact").hide();
		$("#success").hide();
   });		
   
   $("#success a").click(function(){
		$("#paperform").animate({
			width: "113px",
			height: "113px"
		}, "fast");	
		$("div.panel_button").toggle();	
		$("div.quickContact").hide();
		$("#success").hide();
   });					
								
	$('#slideshow').cycle();
	$('ul.dropdown').superfish({
			speed:       'fast',                          // faster animation speed 
            autoArrows:  false,                           // disable generation of arrow mark-up 
            dropShadows: false
							   });

	$(window).resize(function() {
		$('.bg-left').css('height',$(document).height()+'px');
		if (!$.browser.msie && !$.browser.version.substr(0,1)<7) {
			$('#page-inner').css('height', ($(document).height()-$('#push').height())+'px');
		}
	}).resize();
	
	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		DD_belatedPNG.fix('h1#logo a, #slideshow img, #topbar-cnt, #topbar-b, .paper .ico-clip, #page, #footer-rel ');
	};
	
	
});
