Cufon.replace('h1,h2,h3,h4');

$(document).ready(function() {
	$(".open").click(function(){
		$("div#panel").slideDown("slow");
	});	
	$(".close").click(function(){
		$("div#panel").slideUp("slow");	
	});		
	$("#tab a").click(function () {
		$(".toggle a").toggle();
	});		
		
});

$(document).ready(function(){
    lastBlock = $("#a1");
    maxWidth = 430;
    minWidth = 122;	

    $(".pane").hover(
      function(){
        $(lastBlock).animate(
        	{width: minWidth+"px"}, 
        	{ queue:false, duration:400 }
        );
		$(this).animate(
			{width: maxWidth+"px"}, 
			{ queue:false, duration:400}
		);
		lastBlock = this;
      }
    );
});

function mainmenu(){
$(" #nav a").removeAttr("title");
$(" #nav ul ").css({display: "none"});
$(" #nav li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).fadeIn(300);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}

$(document).ready(function(){
	mainmenu();
});

$(document).ready(function(){
	var width = 0;
	$('#nav li').each(function() {
    	width += $(this).outerWidth( false );
		});
	var pad = Math.floor((960-width)/(2*8));
	var pad2 = (((960-width)/(2*8))-pad)*8 + pad;
	var pad3 = pad2-pad;
	$('#nav li').css({padding: "0px "+ pad +"px"});
	$('#nav li:last-child').css({padding: "0px "+ pad2 + "px"});
	$('#nav li ul li ').css({padding: "0 0",margin:"0px 0px 0px -" + pad + "px"});
	$('#nav li:last-child ul li ').css({margin:"0px 0px 0px -" + pad2 + "px"});
	$('#nav li ul li ul li ').css({padding: "0 0",margin: "0px 0px 0px 22px"});
});

$(document).ready(function(){
	$('.testimonials').innerfade({
		speed: 1000,
		timeout: 5000,
		type: 'sequence',
		containerheight:'170px'
	});
});

$(function (){
	$('#consult').submit(function(){
		var action = $(this).attr('action');
		$('#submit_btn')
			.before('<img src="img/ajax-loader.gif" class="loader" />')
			.attr('disabled','disabled');
		$.post(action, { 
			name: $('#name').val(),
			email: $('#email').val(),
			phone: $('#phone').val()
		},
			function(data){
				$('#consult #submit_btn').attr('disabled','');
				$('.response').remove();
				$('#consult').before('<span class="response">'+data+'</span>');
				$('.response').slideDown();
				$('#consult img.loader').fadeOut(500,function(){$(this).remove()});
				if(data=='Thank you.  Your message has been sent.') $('#consult').slideUp();
			}
		);
		return false;	
	});
});

$(function (){ 
	$(".faq > dd").hide();  
	$(".faq > dt").click(function() {
		$(this).toggleClass("on").toggleClass("off").next().slideToggle("fast");
		});
});

//-------------------------------------------------
//		youtube playlist jquery plugin
//		Created by dan@geckonm.com
//		www.geckonewmedia.com
//
//		v1.1 - updated to allow fullscreen 
//			 - thanks Ashraf for the request
//-------------------------------------------------

jQuery.fn.ytplaylist = function(options) {
 
  // default settings
  var options = jQuery.extend( {
    holderId: 'ytvideo',
	playerHeight: '475',
	playerWidth: '588',
	addThumbs: false,
	thumbSize: 'small',
	showInline: false,
	autoPlay: true,
	showRelated: true,
	allowFullScreen: false
  },options);
 
  return this.each(function() {
							
   		var selector = $(this);
		
		var autoPlay = "";
		var showRelated = "&rel=0";
		var fullScreen = "";
		if(options.autoPlay) autoPlay = "&autoplay=1"; 
		if(options.showRelated) showRelated = "&rel=1"; 
		if(options.allowFullScreen) fullScreen = "&fs=1"; 
		
		//throw a youtube player in
		function play(id)
		{
		   var html  = '';
	
		   html += '<object height="'+options.playerHeight+'" width="'+options.playerWidth+'">';
		   html += '<param name="movie" value="http://www.youtube.com/v/'+id+autoPlay+showRelated+fullScreen+'"> </param>';
		   html += '<param name="wmode" value="transparent"> </param>';
		   if(options.allowFullScreen) { 
		   		html += '<param name="allowfullscreen" value="true"> </param>'; 
		   }
		   html += '<embed src="http://www.youtube.com/v/'+id+autoPlay+showRelated+fullScreen+'"';
		   if(options.allowFullScreen) { 
		   		html += ' allowfullscreen="true" '; 
		   	}
		   html += 'type="application/x-shockwave-flash" wmode="transparent"  height="'+options.playerHeight+'" width="'+options.playerWidth+'"></embed>';
		   html += '</object>';
			
		   return html;
		   
		};
		
		
		//grab a youtube id from a (clean, no querystring) url (thanks to http://jquery-howto.blogspot.com/2009/05/jyoutube-jquery-youtube-thumbnail.html)
		function youtubeid(url) {
			var ytid = url.match("[\\?&]v=([^&#]*)");
			ytid = ytid[1];
			return ytid;
		};
		
		
		//load inital video
		var firstVid = selector.children("li:first-child").addClass("currentvideo").children("a").attr("href");
		$("#"+options.holderId+"").html(play(youtubeid(firstVid)));
		
		//load video on request
		selector.children("li").children("a").click(function() {
			
			if(options.showInline) {
				$("li.currentvideo").removeClass("currentvideo");
				$(this).parent("li").addClass("currentvideo").html(play(youtubeid($(this).attr("href"))));
			}
			else {
				$("#"+options.holderId+"").html(play(youtubeid($(this).attr("href"))));
				$(this).parent().parent("ul").find("li.currentvideo").removeClass("currentvideo");
				$(this).parent("li").addClass("currentvideo");
			}
															 
			
			
			return false;
		});
		
		//do we want thumns with that?
		if(options.addThumbs) {
			
			selector.children().each(function(i){
											  
				var replacedText = $(this).text();
				
				if(options.thumbSize == 'small') {
					var thumbUrl = "http://img.youtube.com/vi/"+youtubeid($(this).children("a").attr("href"))+"/2.jpg";
				}
				else {
					var thumbUrl = "http://img.youtube.com/vi/"+youtubeid($(this).children("a").attr("href"))+"/0.jpg";
				}
				
				
				$(this).children("a").empty().html("<img src='"+thumbUrl+"' alt='"+replacedText+"' />"+replacedText).attr("title", replacedText);
				
			});	
			
		}
			
		
   
  });
 
};


$(document).ready(function() {	
	$("a.games1").fancybox({
		'frameHeight':		480,
		'frameWidth':		500,
		'hideOnContentClick': false
	});	
	$("a.games2").fancybox({
		'frameHeight':		500,
		'frameWidth':		360,
		'hideOnContentClick': false
	});	
	$("a.games3").fancybox({
		'frameHeight':		450,
		'frameWidth':		500,
		'hideOnContentClick': false
	});	
	$("a.games4").fancybox({
		'frameHeight':		400,
		'frameWidth':		380,
		'hideOnContentClick': false
	});
	$("a.games5").fancybox({
		'frameHeight':		540,
		'frameWidth':		450,
		'hideOnContentClick': false
	});
	$("a.games6").fancybox({
		'frameHeight':		470,
		'frameWidth':		360,
		'hideOnContentClick': false
	});	
	$("a.lightbox1").fancybox({
	});
	$("a.smile").fancybox({
		'frameHeight':		620,
		'frameWidth':		1020,
		'hideOnContentClick': false
	});
});	


