	$(function() {
    // run the code in the markup!
    $('td pre code').each(
	function() {eval($(this).text());});
	});
	
	$(document).ready(function() {
	 
	//set default easing
	jQuery.easing.def = 'easeOutQuad';
	
	//set preload function
	jQuery.preloadImages = function(){
	for(var i = 0; i<arguments.length; i++)
	{jQuery("<img>").attr("src", arguments[i]);}
	};
	
	//define images to preload
	$.preloadImages("images/about-.png", "images/pricing-.png", "images/portfolio-.png", "images/contact-.png", "images/block_quote_.png", "images/block_contact_.png");
	
    $('#header_cycle').cycle({
        fx: 'fade',
		speed: 3500,
		timeout: 8500 
    });
	$('#port_cycle').cycle({
        fx: 'scrollLeft',
		speed: 2500,
		timeout: 6000 
    });
    
    $('img.blk_qt').hover(
	function() {$(this)
	.stop(true,true)
	.animate({height:"169", width:"351", margin:"4px"}, {duration: 200, easing: 'jswing'})
	.attr("src","/images/block_quote_.png");},
	function() {$(this)
	.animate({height:"177", width:"357", margin:"0px"}, {duration: 500, easing: 'easeOutBounce'})
	.attr("src","/images/block_quote.png");});
	
	$('img.blk_ct').hover(
	function() {$(this)
	.stop(true,true)
	.animate({height:"169", width:"351", margin:"4px"}, {duration: 200, easing: 'jswing'})
	.attr("src","/images/block_contact_.png");},
	function() {$(this)
	.animate({height:"177", width:"357", margin:"0px"}, {duration: 500, easing: 'easeOutBounce'})
	.attr("src","/images/block_contact.png");});
	
	$('DIV.whyusbox img').hover(
	function() {$(this)
	.stop(true,true)
	.animate({marginRight:"50px"}, {duration: 500, easing: 'easeOutElastic'});},
	function() {$(this)
	.animate({marginRight:"0px"}, {duration: 500, easing: 'easeOutBounce'});});
	
	//firefox download condtional
	if ($.browser.msie) {
	$('DIV.firefox').css("display","inline")}
	else{
	$('DIV.firefox').css("display","none")};
	
    $('DIV.firefox').toggle(
	function () {$(this).animate({left:"30%"}, {duration: 2500, easing: 'easeOutElastic'});},
	function () {$(this).animate({left:"-360px"}, {duration: 1000, easing: 'easeOutElastic'});});
	if ($.browser.msie) {
	$('DIV.firefox').click(
	function () {$('DIV.whyus').slideToggle(100, 'jswing');},
	function () {$('DIV.whyus').slideToggle(50, 'jswing');});}
	$('DIV.firefox').click(
	function () {$('DIV.firefox_bg').slideToggle(1500, 'jswing');},
	function () {$('DIV.firefox_bg').slideToggle(500, 'jswing');});
	
	$(function(){
    $('DIV.firefox div a').click(
	function(){window.open(this.href); return false;});
	});
	
	/* Why Us data */
	
	$('.whyus').toggle(
	function () {
	$('DIV.whyus')
	.css("position","absolute")
	.animate({right:"450px"}, {duration: 2000, easing: 'easeOutElastic'})
	$('DIV.whyusbox')
	.css("position","absolute")
	.animate({right:"20px"}, {duration: 2000, easing: 'easeOutElastic'})
	$('DIV.firefox_bg')
	.css({width:'500px', borderLeft:"3px solid white"})
	.slideDown(1000, 'jswing')
	$('#topcontrol').click();
	},
	
	function () {
	$('DIV.whyus')
	.css("position","fixed")
	.animate({right:"-61px"}, {duration: 1000, easing: 'easeOutElastic'})
	$('DIV.whyusbox')
	.css("position","fixed")
	.animate({right:"-480px"}, {duration: 1000, easing: 'easeOutElastic'})
	$('DIV.firefox_bg')
	.slideUp(0, 'jswing')
	.css({'width':'100%', borderLeft:""});
	});
	
	if ($.browser.msie) {
	$('.whyus').click(
	function () {$('DIV.firefox').slideToggle(100, 'jswing');},
	function () {$('DIV.firefox').slideToggle(50, 'jswing');});}
	
	/* dropdown menu animation */
    $('.menu_head_about').hoverIntent(
	function () {$('ul#_about').slideToggle(500, 'easeOutBounce');},
	function () {$('ul#_about').slideToggle("1000");});
	
	$('.menu_head_price').hoverIntent(
	function () {$('ul#_price').slideToggle(500, 'easeOutBounce');},
	function () {$('ul#_price').slideToggle(1000, 'easeOutBounce');});
	
	$('.menu_head_contact').hoverIntent(
	function () {$('ul#_contact').slideToggle(500, 'easeOutBounce');},
	function () {$('ul#_contact').slideToggle(1000, 'easeOutBounce');});
	
	/* dropdown menu dynamic layout functions */
	$("ul.menu_body li:even").addClass("alt");
	$('ul.menu_body li a').mouseover(function () {
	$(this).animate({ fontSize: "14px", paddingLeft: "20px" }, {duration: 250, easing: 'easeOutBounce'});});
	$('ul.menu_body li a').mouseout(function () {
	$(this).animate({ fontSize: "12px", paddingLeft: "10px" }, {duration: 250, easing: 'easeOutBounce'});});
	
	/* define lightbox class */
	$(function() {
        $('a.lightbox').lightBox();
    });
    
    /* Define the slider*/	
	$("#slider").easySlider({
		auto: false, 
		continuous: true
	});
	
	/* footer images change */
	$('img#neespr_logo').hover(
	function() {$(this)
	.attr("src","/images/neespr_logo_.png");},
	function() {$(this)
	.attr("src","/images/neespr_logo_gray.png");});
	
	$('img#passionate_logo').hover(
	function() {$(this)
	.attr("src","/images/passionate_logo_.png");},
	function() {$(this)
	.attr("src","/images/passionate_logo_gray.png");});
	
	$('img#business_link_logo').hover(
	function() {$(this)
	.attr("src","/images/business_link_logo.png");},
	function() {$(this)
	.attr("src","/images/business_link_logo_gray.png");});
	
		$('img#logo_design').hover(
	function() {$(this)
	.attr("src","/images/samyoul_logo_design+.png");},
	function() {$(this)
	.attr("src","/images/samyoul_logo_design.png");});
	
	$('img#web_design').hover(
	function() {$(this)
	.attr("src","/images/samyoul_web_design+.png");},
	function() {$(this)
	.attr("src","/images/samyoul_web_design.png");});
	
	$('img#e-commerce').hover(
	function() {$(this)
	.attr("src","/images/samyoul_e-commerce+.png");},
	function() {$(this)
	.attr("src","/images/samyoul_e-commerce.png");});
	
	$(function(){
    $('DIV.port_box').click(
	function(){window.open("http://samyoul.co.uk/portfolio", "_self"); return false;});
	});
	
	$('.what_we_do_arrow').hover(
	function() {$(this)
	.stop(true,true)
	.animate({marginLeft:"20px"}, {duration: 100, easing: 'jswing'});},
	function() {$(this)
	.animate({marginLeft:"0px"}, {duration: 100, easing: 'jswing'});
	});
	
    // Dock initialize
	$(function () { 
    $('#dock').Fisheye(
        {
            maxWidth: 30,
            items: 'a',
            itemsText: 'span',
            container: '.dock-container',
            itemWidth: 50,
            proximity: 60,
            alignment : 'left',
            valign: 'bottom',
            halign : 'center'
        }
    );
	});
	
	// Ecommerce Function on the Pricing Page //
	
	$('.order_now_button').click(
	function() {
	
	var cur_value = $('.order_now_hidden').attr("value");
	var add_value = $(this).attr("title");
	var cwt_value = $('.order_now_what').html();
	if(cur_value == ""){
		var new_value = add_value;
		var wht_value = add_value;
	}
	else{
		var new_value = cur_value+", "+add_value;
		var wht_value = cwt_value+"<br/>"+add_value;
	};
	
	var slctd_img = '<img src="/images/selected_image.png" class="order_now_button_selected" />';
	
	$(this)
	.fadeOut(500)
	.addClass('order_now_button_used')
	$('.order_now_form')
	.fadeOut(1)
	.fadeIn(500)
	.appendTo($(this).parent())
	$('.order_now_hidden')
	.attr("value", new_value)
	$('.order_now_what')
	.html(wht_value);});
	
	$('.order_now_cancel').click(
	function() {
	$('.order_now_form')
	.fadeOut(500, 'jswing')
	$('.order_now_button_used')
	.fadeIn(500, 'jswing')
	.removeClass('order_now_button_used')
	$('.order_now_hidden')
	.attr("value", "")
	$('.order_now_what')
	.text("")
	$("#response")
	.html("")
	$("#order_form_name")
	.attr("value", "Your Full Name")
	$("#order_form_email")
	.attr("value", "Email Address")
	$("#order_form_phone")
	.attr("value", "Telephone Number");});
	
	$("#sendmail").click(function(){
	var valid = '';
	var isr = ' is required.';
	var name = $("#order_form_name").val();
	var mail = $("#order_form_email").val();
	var phone = $("#order_form_phone").val();
	var what = $("#order_form_what").val();
	if (name.length<1) {
		valid += '<br />Name'+isr;
	}
	if (!mail.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) {
		valid += '<br />A valid Email'+isr;
	}
	if (phone.length<1) {
		valid += '<br />Your phone number'+isr;
	}
	if (what.length<1) {
		valid += '<br />Text'+isr;
	}
	if (valid!='') {
		$("#response").fadeIn("slow");
		$("#response").html("Error:"+valid);
	}
	else {
		var datastr ='order_form_name=' + name + '&order_form_email=' + mail + '&order_form_phone=' + phone + '&order_form_what=' + encodeURIComponent(what);
		$("#response").css("display", "block");
		$("#response").html("Sending message ... <img src='/images/loading.gif' alt='' title='sending' /> ");
		$("#response").fadeIn("slow");
		$(".order_now_cancel").fadeOut(500);
		setTimeout("send('"+datastr+"')",2000);
	}
	return false;
	});
	
});
function send(datastr){
	$.ajax({	
		type: "POST",
		url: "/func/order_email.php",
		data: datastr,
		cache: false,
		success: function(html){
		$("#response").fadeIn("slow");
		$("#response").html(html);
		setTimeout('$("#response").fadeOut("slow")',4000);
		setTimeout('$(".order_now_cancel").fadeIn(500)',3500);
		setTimeout('$(".order_now_cancel").click()',4000);
	}
	});
}
