$(document).ready(function() {

   var isiPad = navigator.userAgent.match(/iPad/i) != null;
   if(isiPad){
	$('.ipad').show();
    $('.noipad').hide();
	
   }else{
	$('.ipad').html('');
   }
   
   $('.div-rand').cycle({ 
    fx:     'fade', 
    speed:  'fast', 
    timeout: 0, 
    next:   '#rand-next' 

	});
   
   $('.enter-your-email').click(function() {
		var name = $(".enter-your-email").val()
		if(name == "Enter your e-mail") { $(".enter-your-email").val(''); }	
	});
	
	$('.enter-your-email').mouseover(function() {
		var name = $(".enter-your-email").val()
		if(name == "") { $(".enter-your-email").val('Enter your e-mail'); }	
	});
	
	$('.aw-input-email').click(function() {
		var name = $(".aw-input-email").val()
		if(name == "E-mail") { $(".aw-input-email").val(''); }	
	});
	
	$('.aw-input-email').mouseover(function() {
		var name = $(".aw-input-email").val()
		if(name == "") { $(".aw-input-email").val('E-mail'); }	
	});
	
	$('.aw-input-name').click(function() {
		var name = $(".aw-input-name").val()
		if(name == "Name") { $(".aw-input-name").val(''); }	
	});
	
	$('.aw-input-name').mouseover(function() {
		var name = $(".aw-input-name").val()
		if(name == "") { $(".aw-input-name").val('Name'); }	
	});
	
	
	
	$('#banner-home').cycle({ 
		fx:     'scrollLeft', 
		timeout: 10000, 
		pager:  '#nav'  
	});
	
	$('.attention-to-detail').cycle({ 
		fx:     'scrollLeft', 
		timeout: 2000
	});
	 
	$('.nav-previous a').corner("5px");
    $('.nav-next a').corner("5px");
	$('.read-more-arrow span').corner("5px");
	$('.sec').corner("5px");
$('.contact-form-button').corner("5px");	
	
	
    $('blockquote').corner("5px");
	
	$("ul.footer-tabs li a").click(function(event){

			$(".screed-div").hide();
			$("ul.footer-tabs li").removeClass("selected");
			var index = $("ul.footer-tabs li a").index(this);
			$("ul.footer-tabs li").eq(index).addClass("selected");			
			$(".footer-screeds-divs div.screed-div").eq(index).show();
			event.preventDefault();
	});
	

	 
	 	$(".home-video").fancybox({
				
		'width'				: '75%',
		'height'			: '75%',
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
	$(".home-video").click(function(event){
		event.preventDefault();
		$('div').remove('.fbuttons');
		$('#fancybox-wrap').append('<div class="fbuttons"><a href="http://www.cscscreeding.co.uk/contact/" title="Contact us" class="contact-form-button">Contact Us</a> <a href="http://www.cscscreeding.co.uk/members-area/" title="Members Area" class="contact-form-button">Members Area</a></div>');
	
	});
	
	$('a.fancybox').fancybox();
	
	$("a#play-flv-video").fancybox({
		 'scrolling': false,
         'titleShow': false,
		 'showCloseButton' : true,
         'padding'  : 0,
         'onStart'  : function() {
             $("#player").show();
             $f("player",
                     "http://www.cscscreeding.co.uk/wp-content/themes/csc/flowplayer/flowplayer-3.2.7.swf",
                     "http://www.cscscreeding.co.uk/video/vt1.flv");
         },
         'onClosed'  : function() {
             $("#player").hide();
             $f().unload();
         }
     });
	 
	 /*event.preventDefault();
		$('.screeds-table-content').hide();
		$('.screeds-table-row').removeClass('table-dark-blue');
		$('div.screeds-table-row', this).addClass('table-dark-blue');
		var content = $('div.screeds-table-content', this);
		$('div.screeds-table-content', this).show();
		var id = $(this).attr("rel");
		$(content).html('<img src="http://www.cscscreeding.co.uk/wp-content/themes/csc/images/ajax-loader.gif" alt="" /> ');
		$.post("http://www.cscscreeding.co.uk/ajax-screed-types/", { id: id},  function(data) {			
			$(content).html(data);

		});
	 });*/
	 

	 
	 $(".screeds-table-row").click(function(event){
		event.preventDefault();
		if($(this).hasClass('table-dark-blue')){
			$('.screeds-table-content').hide();
			$(this).removeClass('table-dark-blue');
			
		}else{
		
		
		$('.screeds-table-row').removeClass('table-dark-blue');
		$(this).addClass('table-dark-blue');
		$('.screeds-table-content').hide();	
		$(this).next('.screeds-table-content').show();
		var content = $(this).next('.screeds-table-content');
		var id = $(this).attr("rel");

		$('.screeds-table-content').html('<img src="http://www.cscscreeding.co.uk/wp-content/themes/csc/images/ajax-loader.gif" alt="" /> ');
		$.post("http://www.cscscreeding.co.uk/ajax-screed-types/", { id: id},  function(data) {			
			$(content).html(data);

		});
		}
	 });
  });
