var isiPad = navigator.userAgent.match(/iPad/i) != null;

// For use within iPad developer UIWebView
// Thanks to Andrew Hedges!
var ua = navigator.userAgent;
var isiPad = /iPad/i.test(ua);
var isiPod = navigator.userAgent.match(/iPod/i);
var isiPhone = navigator.userAgent.match(/iPhone/i);
if(isiPad || isiPod || isiPhone){
	
	var $jq = jQuery.noConflict();
	$jq(document).ready(function() {
		$jq("ul#topnav li .sub").css({'opacity':'0'}); //Fade sub nav to 0 opacity on default
		$jq("ul#topnav li").click( function(){
			if($jq(this).find(".sub").css("display")=="block"){
			  $jq(this).find(".sub").stop().fadeTo('fast', 0, function() { //Fade to 0 opactiy
				  $jq(this).hide();  //after fading, hide it
				  return false;
			  });
			}
			else{
				$jq(this).find(".sub").stop().fadeTo('fast', 1).show(); //Find sub and fade it in
				(function($jq) {
					//Function to calculate total width of all ul's
					jQuery.fn.calcSubWidth = function() {
						rowWidth = 0;
						$jq(this).find("ul").each(function() { //for each ul...
							rowWidth += $jq(this).width(); //Add each ul's width together
						});
					};
				})(jQuery); 
				if ( $jq(this).find(".row").length > 0 ) { //If row exists...
					var biggestRow = 0;	
					$jq(this).find(".row").each(function() {	//for each row...
						$jq(this).calcSubWidth(); //Call function to calculate width of all ul's
						//Find biggest row
						if(rowWidth > biggestRow) {
							biggestRow = rowWidth;
						}
					});
					$jq(this).find(".sub").css({'width' :biggestRow}); //Set width
					$jq(this).find(".row:last").css({'margin':'0'});  //Kill last row's margin
				} else { //If row does not exist...
					$jq(this).calcSubWidth();  //Call function to calculate width of all ul's
					//$jq(this).find(".sub").css({'width' : '150px'}); //Set Width
				}
			}
		}); //Trigger Hover intent with custom configurations
		$jq("ul#topmininav li .sub").css({'opacity':'0'}); //Fade sub nav to 0 opacity on default
		$jq("ul#topmininav li").click(function(){
			if($jq(this).find(".sub").css("display")=="block"){
			  $jq(this).find(".sub").stop().fadeTo('fast', 0, function() { //Fade to 0 opactiy
				  $jq(this).hide();  //after fading, hide it
				  return false;
			  });
			}
			else{
				$jq(this).find(".sub").stop().fadeTo('fast', 1).show(); //Find sub and fade it in
				(function($jq) {
					//Function to calculate total width of all ul's
					jQuery.fn.calcSubWidth = function() {
						rowWidth = 0;
						$jq(this).find("ul").each(function() { //for each ul...
							rowWidth += $jq(this).width(); //Add each ul's width together
						});
					};
				})(jQuery); 
				if ( $jq(this).find(".row").length > 0 ) { //If row exists...
					var biggestRow = 0;	
					$jq(this).find(".row").each(function() {	//for each row...
						$jq(this).calcSubWidth(); //Call function to calculate width of all ul's
						//Find biggest row
						if(rowWidth > biggestRow) {
							biggestRow = rowWidth;
						}
					});
					$jq(this).find(".sub").css({'width' :biggestRow}); //Set width
					$jq(this).find(".row:last").css({'margin':'0'});  //Kill last row's margin
				} else { //If row does not exist...
					$jq(this).calcSubWidth();  //Call function to calculate width of all ul's
					//$jq(this).find(".sub").css({'width' : '150px'}); //Set Width
				}
			}
		}); //Trigger Hover intent with custom configurations
	});
}else{
	
	var $jq = jQuery.noConflict();
	$jq(document).ready(function() {
		function megaHoverOver(){
		$jq(this).find(".sub").stop().fadeTo('fast', 1).show(); //Find sub and fade it in
		(function($jq) {
			//Function to calculate total width of all ul's
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				$jq(this).find("ul").each(function() { //for each ul...
					rowWidth += $jq(this).width(); //Add each ul's width together
				});
			};
		})(jQuery); 
		if ( $jq(this).find(".row").length > 0 ) { //If row exists...
			var biggestRow = 0;	
			$jq(this).find(".row").each(function() {	//for each row...
				$jq(this).calcSubWidth(); //Call function to calculate width of all ul's
				//Find biggest row
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});
			$jq(this).find(".sub").css({'width' :biggestRow}); //Set width
			$jq(this).find(".row:last").css({'margin':'0'});  //Kill last row's margin
		} else { //If row does not exist...
			$jq(this).calcSubWidth();  //Call function to calculate width of all ul's
			//$jq(this).find(".sub").css({'width' : '150px'}); //Set Width
		}
	}
	//On Hover Out
	function megaHoverOut(){
	  $jq(this).find(".sub").stop().fadeTo('fast', 0, function() { //Fade to 0 opactiy
		  $jq(this).hide();  //after fading, hide it
	  });
	}
	var config = {
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
		 interval: 100, // number = milliseconds for onMouseOver polling interval
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
		 timeout: 500, // number = milliseconds delay before onMouseOut
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)
	};
	$jq("ul#topnav li .sub").css({'opacity':'0'}); //Fade sub nav to 0 opacity on default
	$jq("ul#topnav li").hoverIntent(config); //Trigger Hover intent with custom configurations
	$jq("ul#topmininav li .sub").css({'opacity':'0'}); //Fade sub nav to 0 opacity on default
	$jq("ul#topmininav li").hoverIntent(config); //Trigger Hover intent with custom configurations
	});
}
$jq(document).ready(function() {
	$jq('.add-to-cart-button').click(function() {
	    $('html, body').animate({scrollTop: '0px'}, 800);
	})
});
/*$jq(document).ready(function() {
	$jq('.heart-red').click(function() {
	    return false;
	})
});
*/$jq(document).ready(function() {
	if($jq(window).height()>'790'){
	var nwidth =$jq(window).height()-30;
	$jq(".fullWidth-custom").css('height',nwidth+'px')
	}
	else{
	$jq(".fullWidth-custom").css('height','775px')
	}
});
$jq(window).resize(function() {
	if($jq(window).height()>'790'){
	var nwidth =$jq(window).height()-30;
	$jq(".fullWidth-custom").css('height',nwidth+'px')
	}
	else{
	$jq(".fullWidth-custom").css('height','775px')
	}
});
$jq(document).ready(function() {
	if($jq(window).height()>'790'){
	var nwidth =$jq(window).height()-100;
	$jq("#flashContent").css('height',nwidth+'px')
	}
	else{
	$jq("#flashContent").css('height','710px')
	}
});
$jq(window).resize(function() {
	if($jq(window).height()>'790'){
	var nwidth =$jq(window).height()-100;
	$jq("#flashContent").css('height',nwidth+'px')
	}
	else{
	$jq("#flashContent").css('height','710px')
	}
});
var $jq = jQuery.noConflict();
$jq(document).ready(function() {
	var nwidth =$jq(window).height()-201;
	$jq("#content-container").css('min-height',nwidth+'px')
});
$jq(window).resize(function() {
	var nwidth =$jq(window).height()-201;
	$jq("#content-container").css('min-height',nwidth+'px')
});
