$(document).ready(function() {
 
 
// Qvolver //

(function(a){a.fn.quovolver=function(g,f){if(!g){g=500}if(!f){f=6000}var e=(g*4);if(e>(f)){f=e}var d=a(this),c=a(this).filter(":first"),h=a(this).filter(":last"),b='<div id="quote_wrap"></div>';a(this).wrapAll(b);a(this).hide();a(c).show();a(this).parent().css({height:a(c).height()});setInterval(function(){if(a(h).is(":visible")){var i=a(c);var j=a(i).height()}else{var i=a(d).filter(":visible").next();var j=a(i).height()}a(d).filter(":visible").fadeOut(g);setTimeout(function(){a(d).parent().animate({height:j},g)},g);if(a(h).is(":visible")){setTimeout(function(){a(c).fadeIn(g*2)},g*2)}else{setTimeout(function(){a(i).fadeIn(g)},g*2)}},f)}})(jQuery);

// ClearField //
	
;(function(d){function k(a){return a===undefined||a===""}function g(a){return l.apply(a,p.call(arguments,1))}function m(a){a=d(a);a.val()===""&&g(a,"").trigger("other.autoclear");return a}function h(a){a=d(a);jQuery.trim(a.val())===""?a.trigger("default.autoclear"):a.trigger("other.autoclear");return a}var p=[].slice,l=jQuery.fn.val;jQuery.fn.autoclear=function(a){var c={defaultClass:"default",otherClass:"other",defaultValue:"",useDefaultOnReset:true,clearDefaultOnSubmit:true};if(arguments.length)switch(typeof a){case "string":c.defaultClass=a;break;case "object":c=jQuery.extend(c,a)}return this.bind({"default.autoclear":function(){var b=d(this).removeClass(c.otherClass).addClass(c.defaultClass);g(b,b.data("default.autoclear"))},"other.autoclear":function(){d(this).removeClass(c.defaultClass).addClass(c.otherClass)},"focus.autoclear blur.autoclear":function(b){(b.type==="focus"?m:h)(this)}}).each(function(){var b=d(this),n=b.closest("form"),i=jQuery.trim(g(b)),e=b.attr("title");if(k(e))e=i===""?c.defaultValue:i;b.data("default.autoclear",e);n.bind("reset.autoclear",function(j){var f=j.originalEvent;setTimeout(function(){if(!(f.defaultPrevented||f.returnValue===false||f.getPreventDefault&&f.getPreventDefault())){var o;o=c.useDefaultOnReset?"":b.attr("defaultValue");b.val(o)}},0)});if(c.useDefaultOnReset||k(jQuery.trim(b.attr("defaultValue"))))b.attr("defaultValue",e).val(i);c.clearDefaultOnSubmit&&n.bind("submit.autoclear",function(j){if(!j.isDefaultPrevented()){m(b);setTimeout(function(){h(b)},0)}});h(this)})};jQuery.fn.val=function(){var a=l.apply(this,arguments),c;if(typeof a==="string"){c=this.first().data("default.autoclear");if(c!==undefined&&a===c)a=""}else this.each(function(){var b=d(this);b.data("default.autoclear")!==undefined&&b.val()===""?b.trigger("default.autoclear"):b.trigger("other.autoclear")});return a}})(jQuery);


 
 
 
 	$(function(){
	    $("#goSearchVids").click(function(){
				$('#vidRows').html('searching for girls');

					
 			 $.post("/includes/vidSearch.php", $("#searchVids").serialize(), function(data) {
			$('#vidRows').html(data);
		 }); 
	
	 return false;           
	 
	    });
	});




//Close Popups and Fade Layer
$('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
    $('#fade , .popup_block').fadeOut(function() {
        $('#fade, a.closeBox').remove();  //fade them both out
    });
    return false;
});





 $('.clearField').autoclear();
 
 $('.colLink').click(function(){	
			$('.colLink').css({backgroundColor: '#ffffff'})
			colChoose=$(this).attr('id');
			$('#colour').val(colChoose);
			$(this).css({backgroundColor: '#0b9318'})

 
 });
 
 
 function overlay() {
	el = document.getElementById("overlay");
	el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
}
 
  $('#addEmail').click(function(){	
	
	$(this).fadeOut();
	$('#emailerAdd').addClass('green');
	var emailADD=$('#emailerAdd').val();
	$('#emailerAdd').val('Added your email!');
		$.post("/includes/updater.php", {action: "emailADD", emailADD: emailADD });
	
	
 });
 
   $('#colour').change(function(){ 
   colChoose=$(this).val();
   $('.colLink').css({backgroundColor: '#ffffff'})
   thisvar='#'+colChoose;
	 $(thisvar).css({backgroundColor: '#0b9318'})
	 
   
 
  }); 	
 
 
  $('#orderSel').change(function(){ 
    var sorter=$('#orderSel').val(); 
	
			$('#page').html("<BR><BR>Re sorting...");
			
			
	$.post("/pages/inc_prods.php", {orderby: sorter},function(data) {

			$('#page').html(data);
			pager();
					 }); 	
  });
 
 
function setBasket(){
 
			  
		$('.basketArea').mouseenter(function(){
			$('.basketArea').stop();
			$('.basketArea').animate({ 
				top: "0px",
			  }, 300 );
		});
		
		
		$('.basketArea').mouseleave(function(){
				$('.basketArea').stop();
			$('.basketArea').animate({ 
				top: "-180px",
			  }, 400 );
		});

}

setBasket();



 
  
 	$("img:not([title])").each(function() {
  		if($(this).attr("alt") != '') $(this).attr("title", $(this).attr("alt"))
  		else $(this).attr("title", $(this).attr("src"))
  	})
 
$('.rightHead').hide().delay(1200).fadeIn(600);
$('h1').hide().delay(400).fadeIn(800);
$('h3').hide().delay(800).fadeIn(800);
$('#testBox').hide().delay(1400).fadeIn(600);

$('.hoverClick').click(
  function () {

    $('.dropContent').slideToggle();
	return false;
  }
);


$('#loginBut').click(
  function () {
	  $("#loginBox").slideToggle();
	  return false;
  });
	  
	  
	  
	  
	  
$('.buyButton').click(
  function () {
	  
var prodID=$("#prodID").val();
var qty=$("#quantity").val();
var colour=$("#colour").val();

currOrder=$.cookie('orderItems');

$.cookie('orderItems', currOrder+prodID+'-'+qty+'-'+colour+':', { expires: 7, path: '/' });

updatedOrder=$.cookie('orderItems');

var mySplitResult = updatedOrder.split(":");
var counter=mySplitResult.length;


popWindow();


$('#cart').load('/includes/basket.php',function(){	setBasket();});
	return false;
  }
);



		  $(".hoverFade").mouseover(function (){
					     $(this).stop();
						         $(this).fadeTo(300, 0.5 )
  							  });
				  $(".hoverFade").mouseout(function (){
					  			     $(this).stop();
						         $(this).fadeTo(200, 1 )
  							  });
							  

$('.fader').quovolver();




	    $("#commSubmit").click(function(){

		$('#commsInline').html('Posting Comment.....');
 			 $.post("/includes/commsPost.php", $("#commForm").serialize(), function(data) {
	
			$("#comment").val('');
			$('#commsInline').html(data);
		 }); 
	
	 return false;           
	 
	    });




function hideTabs(selDiv){


	 $('div.sel1_content').hide();
	 $('div.sel2_content').hide();
	 $('div.sel3_content').hide(); 
	 $('div.sel4_content').hide();
	 
	 if (selDiv!="sel4"){
	 $('div.' + selDiv+'_content').fadeIn();
	 }
	 
	 if (selDiv=="sel4"){
	 	 $('div.sel1_content').fadeIn();
		 $('#desc1').hide();
		 $('#desc2').show();
	 }	
		 if (selDiv=="sel1"){

		 $('#desc2').hide();
		 $('#desc1').show();
	 }
	 
	 
	 	$('#sel1').addClass('off');
	 	$('#sel2').addClass('off');
	 	$('#sel3').addClass('off');
	 	$('#sel4').addClass('off');
		
		var linktoChange="#"+selDiv;

		$(linktoChange).removeClass('off');
}
hideTabs('sel1');
  
$('#navTabs a').click(
  function () {
	  
	 	  selDiv=this.className;
			hideTabs(selDiv);
			return false;
	    }
		
	
);



});


