/*!
 * HTML5 Placeholder jQuery Plugin v1.7
 * @link http://github.com/mathiasbynens/Placeholder-jQuery-Plugin
 * @author Mathias Bynens <http://mathiasbynens.be/>
 */
(function(f,z){var e=z in document.createElement('input'),a=z in document.createElement('textarea');if(e&&a){f.fn.placeholder=function(){return this}}else{f.fn.placeholder=function(){return this.filter((e?'textarea':':input')+'['+z+']').bind('focus.'+z,b).bind('blur.'+z,d).trigger('blur.'+z).end()}}function c(h){var g={},i=/^jQuery\d+$/;f.each(h.attributes,function(k,j){if(j.specified&&!i.test(j.name)){g[j.name]=j.value}});return g}function b(){var g=f(this);if(g.val()===g.attr(z)&&g.hasClass(z)){if(g.data(z+'-password')){g.hide().next().show().focus()}else{g.val('').removeClass(z)}}}function d(g){var j,i=f(this);if(i.val()===''||i.val()===i.attr(z)){if(i.is(':password')){if(!i.data(z+'-textinput')){try{j=i.clone().attr({type:'text'})}catch(h){j=f('<input>').attr(f.extend(c(i[0]),{type:'text'}))}j.removeAttr('name').data(z+'-password',true).bind('focus.'+z,b);i.data(z+'-textinput',j).before(j)}i=i.hide().prev().show()}i.addClass(z).val(i.attr(z))}else{i.removeClass(z)}}f(function(){f('form').bind('submit.'+z,function(){var g=f('.'+z,this).each(b);setTimeout(function(){g.each(d)},10)})});f(window).bind('unload.'+z,function(){f('.'+z).val('')})})(jQuery,'placeholder');

// Test if the placeholder attribute is implamented
function supports_input_placeholder() {
	var i = document.createElement('input');
	return 'placeholder' in i;
}

function is_ios() {
	if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
		return true
	} else {
		return false;
	}
}

$(window).bind("load",function(){

	if ($.browser.msie) {
    	var ver = $.browser.version.substring(1,0);
	    $("html").attr("class", "ie ie-" + ver);
	}	

    // Make the HTML5 Placeholder option work in older browsers
	if (!supports_input_placeholder()) {
		$('input, textarea').placeholder();
	}
	
	// Single product page data review tabs
	if ($('#tab-reviews').length == 1) {
		$('#tab-reviews').hide();
		$("a[href='#tab-reviews']").click(function(){
			$("#tab-reviews").show();
			$("#tab-description").hide();
			$("#tab-attributes").hide();
			$("#tabs li").removeClass("active");
			$(this).parent("li").addClass("active");
			return false;
		});
		$("a[href='#tab-description']").click(function(){
			$("#tab-reviews").hide();
			$("#tab-description").show();
			$("#tab-attributes").show();
			$("#tabs li").removeClass("active");
			$(this).parent("li").addClass("active");
			return false;
		});
	}


	$('.flexslider').flexslider({
		animation: "slide",
		controlsContainer: ".flexslider-container",
		slideshow: true,
		controlNav: true,
		controlsContainer: ".flex-controls"
	});
	
	$(".flex-direction-nav, .flex-control-nav").css({
		"display" : "block",
		opacity : 0
	});
	
	if (!is_ios()) {
		$("#slides").hover(function(){
			$(".flex-direction-nav").animate({opacity: 0.3}, 200);
			$(".flex-control-nav").animate({opacity: 1}, 200);
		}, function(){
			$(".flex-direction-nav, .flex-control-nav").animate({opacity: 0}, 200);
		});
	}
	
	var footer = $("#footer"),
		footerUL = footer.find("ul"),
		footerH3 = footer.find("h3");
	
	$("#footerStar").css({
		opacity: 0.2
	});
	
	if (!is_ios()) {
		footer.hover(function(){
			footerUL.stop(true, true).slideDown(200);
			$("#footerStar").show();
			footerH3.addClass("hasBorder");
		}, function(){
			$("#footerStar").hide();
			footerUL.stop(true, true).slideUp(200);
			footerH3.removeClass("hasBorder");
		});
	}
	
	$("#footerStar").hover(function(){
		$(this).css({
			"color" : "#fff",
			opacity : 1
		});
	}, function(){
		$(this).css({
			opacity: 0.1,
			"color" : "rgb(75, 33, 35)"
		});
	});
	
	
		
	// if iOS
	if (is_ios()) {
		$("#footer h3").addClass("hasBorder");
		$("#footer ul").show();
		$(".flex-direction-nav").css({
			opacity: 0.4,
			"display" : "block"
		});
	} else {
		$("#footer h3").addClass("hasBorder");
		$("#footer").addClass("fixed");
		var footerHeight = $("#footer").height();
		$(".wrapper:last").css({
			"padding-bottom" : footerHeight + "px"
		});
		$("#footer h3").removeClass("hasBorder");
		$("#footer ul").hide();
		$("#footer").addClass("fixed");
	}

        
});
