var RecaptchaOptions = {
   theme : 'clean'
};

Cufon.replace('.navmenu li h2');
Cufon.replace('h1');
Cufon.replace('h2');
Cufon.replace('h4#prodinfo');
Cufon.replace('.videosubsections h4');



jQuery.fn.imgSize = function(deep,callback){

 callback = callback || deep;
 var $images = this.filter("IMG[src]");
 if(deep) $images.add( this.find("IMG[src]") );

 $images.each(function(){

  var origImg = this;
  var url = $(origImg).attr("src");

  $("<img>").load(function(){
   var $dummy = $(this), size = { width:$dummy.width(), height:$dummy.height(), fileSize:0 };
   try{ size.fileSize = parseInt($dummy.attr("fileSize")) || 0 }catch(e){};
   jQuery.isFunction(callback) && callback.apply( origImg, [size,this] );
   $dummy.remove();
  })
  // To be on the safe side, apply inline styles to prevent any css styles affecting our measurements:
  // (We use a try-catch workaround for IE7 because it raises errors when we try to set maxWidth/maxHeight)
  .css({ display:"none", width:"auto", height:"auto", minWidth:"auto", minHeight:"auto" })
  .each(function(){ try{ $(this).css({ maxWidth:"auto", maxHeight:"auto" }) }catch(e){}; })
  .addClass("imgSize-temp-img")
  .appendTo(document.body)    // The width/height would be zero if img is not added to DOM.
  .attr({ src:url });

 });

 return this;
}




$(document).ready(function(){

 $('ul.navmenu').superfish({
	 speed:       'fast',
	 autoArrows:  false,
	 dropShadows: false

 });



var orgsearchval = $("#query_string").val();
$("#query_string").focus(function(){
$("#query_string").val("");
});
$("#query_string").blur(function(){
var currentSearchValue = $("#query_string").val();
            if (currentSearchValue == ""){
$("#query_string").val(orgsearchval);
}
});

$("#tabs").tabs({
cookie: {},
selected: 0
});

projekktor("video", {
imageScaling:		'fill',
videoScaling:		'fill'
});

var startSlide = 0;
			// Get slide number if it exists
			if (window.location.hash) {
				startSlide = window.location.hash.replace('#','');
			
			}else{
			startSlide = parseInt(startSlide) + 1;
			}

var starttabc = "#nav" + (startSlide);
$(starttabc).toggleClass("activef");



		// Initialize Slides
			$('#slides').slides({
				preload: false,
				preloadImage: 'images/loading.gif',
				generatePagination: false,
				paginationClass: 'splashnav',
				start: startSlide,
				animationStart: function(current){
				$(".splashdesc").slideToggle();
				var navtabc = "#nav" + current;

				$(navtabc).toggleClass("activef");
				$("#spcontent").fadeToggle();
				if ($("#vid1").html() != null){
				projekktor("vid1").setPause(true);
				projekktor("vid1").setActiveItem("poster");
				$("#vid1Play").removeClass("pause");
				}
				if ($("#vid2").html() != null){
				projekktor("vid2").setPause(true);
				projekktor("vid2").setActiveItem("poster");
				$("#vid2Play").removeClass("pause");
				}
				if ($("#vid3").html() != null){
				projekktor("vid3").setPause(true);
				projekktor("vid3").setActiveItem("poster");
				$("#vid3Play").removeClass("pause");
				}
				if ($("#vid4").html() != null){
				projekktor("vid4").setPause(true);
				projekktor("vid4").setActiveItem("poster");
				$("#vid4Play").removeClass("pause");
				}
				if ($("#vid5").html() != null){
				projekktor("vid5").setPause(true);
				projekktor("vid5").setActiveItem("poster");
				$("#vid5Play").removeClass("pause");
				}
				if ($("#vid6").html() != null){
				projekktor("vid6").setPause(true);
				projekktor("vid6").setActiveItem("poster");
				$("#vid6Play").removeClass("pause");
				}
				if ($("#vid7").html() != null){
				projekktor("vid7").setPause(true);
				projekktor("vid7").setActiveItem("poster");
				$("#vid7Play").removeClass("pause");
				}
				},
				animationComplete: function(current){
				window.location.hash = '#' + current;
								var vidid = "#vid" + current;
				var contpage = $("#slide"+current).attr("rel");
				 var navtabn = "#nav" + current;
				$(navtabn).toggleClass("activef", 500);
								

				 
	$.ajax({
   type: "POST",
   url: contpage,
   success: function(html){
        $("#spcontent").html(html);
        $("#slide"+current+".splashdesc").slideToggle();
        $("#spcontent").fadeToggle();
       Cufon.replace('h1');
Cufon.replace('h2');
Cufon.replace('h4#prodinfo');
Cufon.replace('.videosubsections h4');
    projekktor("video", {
imageScaling:		'fill',
videoScaling:		'fill'
});
  
     }
 });
				
				}
			});
var firstslide = "#slide" + startSlide;

 $(firstslide).ready(function(){
 
 

 var contpage = $(firstslide).attr("rel");
 	$.ajax({
   type: "POST",
   url: contpage,
   success: function(html){
        $("#spcontent").html(html);
Cufon.replace('h1');
Cufon.replace('h2');
Cufon.replace('h4#prodinfo');
Cufon.replace('.videosubsections h4');
      projekktor("video", {
imageScaling:		'fill',
videoScaling:		'fill'
});

     }
 });
   //projekktor('#vid1');

 });
 
				if ($("#vid1").html() != null){
				$('#vid1Play').click(function(){
	projekktor("vid1").setPlayPause();
	var status = projekktor('vid1').getState();
	if (status == "PAUSED" || status == "IDLE"){
$("#vid1Play").removeClass("pause");
}else{
$("#vid1Play").addClass("pause");
}

	return false;
	});

				var Dimfun1 =  function(data) {
				
if (data == "PAUSED" || data == "IDLE"){
$("#dim1").fadeOut();
$("#vid1Play").removeClass("pause");
}else{
$("#dim1").fadeIn("slow");
$("#vid1Play").addClass("pause");
}

};
projekktor("vid1").addListener('state',Dimfun1);				
				}
				
				if ($("#vid2").html() != null){
				$('#vid2Play').click(function(){
	projekktor("vid2").setPlayPause();
		var status = projekktor('vid2').getState();
	if (status == "PAUSED" || status == "IDLE"){
$("#vid2Play").removeClass("pause");
}else{
$("#vid2Play").addClass("pause");
}
	return false;
	});

								var Dimfun2 =  function(data) {
if (data == "PAUSED" || data == "IDLE"){
$("#dim2").fadeOut();
$("#vid2Play").removeClass("pause");
}else{
$("#dim2").fadeIn("slow");
$("#vid2Play").addClass("pause");
}

};
projekktor("vid2").addListener('state',Dimfun2);
				
				}
				if ($("#vid3").html() != null){
				$('#vid3Play').click(function(){
	projekktor("vid3").setPlayPause();
		var status = projekktor('vid3').getState();
	if (status == "PAUSED" || status == "IDLE"){
$("#vid3Play").removeClass("pause");
}else{
$("#vid3Play").addClass("pause");
}
	return false;
	});

								var Dimfun3 =  function(data) {
if (data == "PAUSED" || data == "IDLE"){
$("#dim3").fadeOut();
$("#vid3Play").removeClass("pause");
}else{
$("#dim3").fadeIn("slow");
$("#vid3Play").addClass("pause");
}

};
projekktor("vid3").addListener('state',Dimfun3);
				
				}
				if ($("#vid4").html() != null){
				$('#vid4Play').click(function(){
	projekktor("vid4").setPlayPause();
		var status = projekktor('vid4').getState();
	if (status == "PAUSED" || status == "IDLE"){
$("#vid4Play").removeClass("pause");
}else{
$("#vid4Play").addClass("pause");
}
	return false;
	});

							var Dimfun4 =  function(data) {
if (data == "PAUSED" || data == "IDLE"){
$("#dim4").fadeOut();
$("#vid4Play").removeClass("pause");
}else{
$("#dim4").fadeIn("slow");
$("#vid4Play").addClass("pause");
}

};
projekktor("vid4").addListener('state',Dimfun4);	
				
				}
				if ($("#vid5").html() != null){
				$('#vid5Play').click(function(){
	projekktor("vid5").setPlayPause();
		var status = projekktor('vid5').getState();
	if (status == "PAUSED" || status == "IDLE"){
$("#vid5Play").removeClass("pause");
}else{
$("#vid5Play").addClass("pause");
}
	return false;
	});

								var Dimfun5 =  function(data) {
if (data == "PAUSED" || data == "IDLE"){
$("#dim5").fadeOut();
$("#vid5Play").removeClass("pause");
}else{
$("#dim5").fadeIn("slow");
$("#vid5Play").addClass("pause");
}

};
projekktor("vid5").addListener('state',Dimfun5);
				
				}
				if ($("#vid6").html() != null){
				$('#vid6Play').click(function(){
	projekktor("vid6").setPlayPause();
		var status = projekktor('vid6').getState();
	if (status == "PAUSED" || status == "IDLE"){
$("#vid6Play").removeClass("pause");
}else{
$("#vid6Play").addClass("pause");
}
	return false;
	});

								var Dimfun6 =  function(data) {
if (data == "PAUSED" || data == "IDLE"){
$("#dim6").fadeOut();
$("#vid6Play").removeClass("pause");
}else{
$("#dim6").fadeIn("slow");
$("#vid6Play").addClass("pause");
}

};
projekktor("vid6").addListener('state',Dimfun6);
				
				}
				if ($("#vid7").html() != null){
				$('#vid7Play').click(function(){
	projekktor("vid7").setPlayPause();
		var status = projekktor('vid7').getState();
	if (status == "PAUSED" || status == "IDLE"){
$("#vid7Play").removeClass("pause");
}else{
$("#vid7Play").addClass("pause");
}
	return false;
	});

							var Dimfun7 =  function(data) {
if (data == "PAUSED" || data == "IDLE"){
$("#dim7").fadeOut();
$("#vid7Play").removeClass("pause");
}else{
$("#dim7").fadeIn("slow");
$("#vid7Play").addClass("pause");
}

};
projekktor("vid7").addListener('state',Dimfun7);	
				
				}

      
$.prettyLoader({
			animation_speed: 'fast', /* fast/normal/slow/integer */
			bind_to_ajax: true, /* true/false */
			delay: false, /* false OR time in milliseconds (ms) */
			loader: 'images/prettyLoader/ajax-loader.gif', /* Path to your loader gif */
			offset_top: 13, /* integer */
			offset_left: 10 /* integer */
		});

$("select, input:checkbox, input:radio, input:file").uniform();

function catjax(){

$(".catlink").click(function(){
$("#docs").hide();
$("#docs").html("");
	catid = $(this).attr("rel");
	typeid = $("#seldoctype").val();	
	$.ajax({
   type: "POST",
   url: "catjax.php",
   data: "id=" + catid + "&typeid=" + typeid,
   success: function(html){
        $("#docs").html(html);
         $("#docs").fadeIn();
     Cufon.replace('h2');
        }
 });
     
     
    // return false;
	
	});

}

function litcatjax(){

$(".litcatlink").click(function(){
$("#docs").hide();
$("#docs").html("");
	catid = $(this).attr("rel");
	typeid = $("#seldoctype").val();	
	$.ajax({
   type: "POST",
   url: "litcatjax.php",
   data: "id=" + catid + "&typeid=" + typeid,
   success: function(html){
     $("#docs").html(html);
     $("#docs").fadeIn();
     Cufon.replace('h2');
     
     }
 });
     
     
    // return false;
	
	});

}

function msdscatjax(){

$(".msdscatlink").click(function(){
$("#docs").hide();
$("#docs").html("");
	catid = $(this).attr("rel");
	typeid = $("#seldoctype").val();	
	$.ajax({
   type: "POST",
   url: "msdscatjax.php",
   data: "id=" + catid + "&typeid=" + typeid,
   success: function(html){
     $("#docs").html(html);
     $("#docs").fadeIn();
     Cufon.replace('h2');
     
     }
 });
     
     
    // return false;
	
	});

}



	$(".doctypelink").click(function(){
	typeid = $(this).attr("rel");
	$("#doccats").hide();
		$("#docs").hide();
		$("#doccats").html("");
		$("#docs").html("");
	$.ajax({
   type: "POST",
   url: "doctypejax.php",
   data: "id=" + typeid,
   success: function(html){
     $("#doccats").html(html);
     $("#doccats").fadeIn();
     Cufon.replace('h2');
     catjax();
     }
 });
     
     
    // return false;
	
	});
	
	$(".littypelink").click(function(){
	typeid = $(this).attr("rel");
	$("#doccats").hide();
		$("#docs").hide();
		$("#doccats").html("");
		$("#docs").html("");
	$.ajax({
   type: "POST",
   url: "littypejax.php",
   data: "id=" + typeid,
   success: function(html){
     $("#doccats").html(html);
     $("#doccats").fadeIn();
     Cufon.replace('h2');
     litcatjax();
     }
 });
     
     
    // return false;
	
	});


$(".msdstypelink").click(function(){
	typeid = $(this).attr("rel");
	$("#doccats").hide();
		$("#docs").hide();
		$("#doccats").html("");
		$("#docs").html("");
	$.ajax({
   type: "POST",
   url: "msdstypejax.php",
   data: "id=" + typeid,
   success: function(html){
     $("#doccats").html(html);
     $("#doccats").fadeIn();
     Cufon.replace('h2');
     msdscatjax();
     }
 });
     
     
    // return false;
	
	});





function photojax (){
	$(".pphotogrid a").click(function(){
	photoid = $(this).attr("rel");
	     
     //return false;
	
	});
	
$(".pphotogrid a").tipTip({
maxWidth: "400px",
defaultPosition: "left"
});

	
$("#photocatselect").change(function(){
catid = $("#photocatselect").val();
window.location = "photos.php?id=" + catid;
});
	
}

photojax();



$("#videocatselect").change(function(){
catid = $("#videocatselect").val();
window.location = "videos.php?cid=" + catid;
});

$('#multiimage li img').click(function(){
$("#multiimage li").removeClass("active");
$(this).parent("li").addClass("active");
			$("#prodimages img#prodimage").attr("src", $(this).attr("src").replace("frame-", ""));
$("#prodimages img#prodimage").imgSize(function(size){
$("#prodimages img#prodimage").css("height", size.height + "px ");
});
		});		


   $("a#cartlink").hover(function () {
      var coffset = $(this).offset();
         cvertSpot = coffset.top + $(this).height();
	 var cwidthoffset = $(this).width();
                chorizSpot = (coffset.left + cwidthoffset) - 300;
      $("#cartfloat").slideDown("fast");
       $("div#cartfloat").css("top", cvertSpot);
                $("div#cartfloat").css("left", chorizSpot);

   });
   $("#cardtype").change(function(){
   var cardtypevalue = $("#cardtype").val();
   if (cardtypevalue == "American Express"){
      $("#cardmessage").html("Kaivac happily accepts American Express cards for payment. However, due to processing charges, an extra 2% will be added on to your total.");
      $("#cardmessage").slideDown();
   }else{$("#cardmessage").slideUp();$("#cardmessage").html("");}

   });

    $("#cartfloat").hover('', function () {

       $("#cartfloat").slideUp("fast");

    });

          $("a#cvvhelp").fancybox({
              'frameWidth':  800,
              'frameHeight': 600


   });

	$("a.nlsignuplink").fancybox({
		'frameWidth':   600,
		'frameHeight':  350,
		'overlayShow': false,
		'hideOnContentClick' : false
		});


	$("a.iframe").fancybox({
		'frameWidth':   800,
		'frameHeight':  500,
		'overlayShow': false,
		'hideOnContentClick' : false
		});

	$("ul.relvidlist a").fancybox({
		'frameWidth':   420,
		'frameHeight':  250,
		'overlayShow': false,
		'hideOnContentClick' : false
		});

$(".searchbox").ready(function(){
var orgSearchDesc = $(".searchbox").val();
	$(".searchbox").focus(function(){
            $(".searchbox").val("");
        });
        $(".searchbox").blur(function(){
            var currentSearchValue = $(".searchbox").val();
            if (currentSearchValue == ""){
            $(".searchbox").val(orgSearchDesc);
            }
        });
});



        $(".newslink").click(function () {
        $(this).parent().next('.newscont').toggle("fast");
	if ($(this).html().match("Hide")){$(this).html("View Full Story &raquo;");}else{
	    $(this).html("Hide Full Story &uarr;");
	}
	return false;
	});
	        $(".nextbuttona").click(function () {
        $(this).parent().prev().toggle("fast");
	if ($(this).html().match("Hide")){$(this).html("View Full Details &raquo;");}else{
	    $(this).html("Hide Details &uarr;");
	}
	return false;
	});

	 $(".catlist img").reflect({height:0.33,opacity:0.2});


	
	// $("ul.relvidlist li a").hover(function (){
	//	$("#viddesc").html(this.title);

	// });



$(".helper").tipTip({
maxWidth: "400px"
});

$("#sharing a").tipTip({
maxWidth: "150px",
defaultPosition: "bottom",
edgeOffset: 20
});



$('a').filter(function() {
    return this.hostname && this.hostname !== location.hostname;
    }).click(function (){
window.open(this.href);
return false;
});

});

function dupaddress(){
var addcheck=document.checkout.billsame.checked;
if (addcheck){
document.checkout.billname.value = document.checkout.shipname.value;
document.checkout.billaddress.value = document.checkout.shipaddress.value;
document.checkout.billaddress2.value = document.checkout.shipaddress2.value;
document.checkout.billcity.value = document.checkout.shipcity.value;
document.checkout.billstate.value = document.checkout.shipstate.value;
document.checkout.billzip.value = document.checkout.shipzip.value;
document.checkout.billcountry.value = document.checkout.shipcountry.value;
}else{
document.checkout.billname.value = '';
document.checkout.billaddress.value = '';
document.checkout.billaddress2.value = '';
document.checkout.billcity.value = '';
document.checkout.billstate.value = '';
document.checkout.billzip.value = '';
document.checkout.billcountry.value = '';
}
}

function checkform() {
if (document.checkout.shipcity.value != "" && document.checkout.shipzip.value != "" && document.checkout.shipname.value != "" && document.checkout.shipaddress.value != "" && document.checkout.phone.value != ""){allgood = 1;}else{allgood = 0;}

						if (allgood == 1){
document.checkout.submit();
}else{
alert ("Address Information is required.  Please make sure all the requested information is provided, then try again.");

}
}

function checkform2() {
if (document.checkout.email.value != "" && document.checkout.shipname.value != "" && document.checkout.shipaddress.value != "" && document.checkout.phone.value != ""){allgood = 1;}else{allgood = 0;}

						if (allgood == 1){
document.checkout.submit();
}else{
alert ("Email Address, Name, Address, Phone, and Payment Information are required.  Please make sure all the requested information is provided, then try again.");

}
}


