/*
Bones Scripts File
Author: Benny Jien
*/

// Modernizr.load loading the right scripts only if you need them
Modernizr.load([
	{
    // Let's see if we need to load selectivizr
    test : Modernizr.borderradius,
    // Modernizr.load loads selectivizr for IE6-8
    nope : ['selectivizr-min.js']
	}
]);


/* imgsizer (flexible images for fluid sites) */
var imgSizer={Config:{imgCache:[],spacer:"/path/to/your/spacer.gif"},collate:function(aScope){var isOldIE=(document.all&&!window.opera&&!window.XDomainRequest)?1:0;if(isOldIE&&document.getElementsByTagName){var c=imgSizer;var imgCache=c.Config.imgCache;var images=(aScope&&aScope.length)?aScope:document.getElementsByTagName("img");for(var i=0;i<images.length;i++){images[i].origWidth=images[i].offsetWidth;images[i].origHeight=images[i].offsetHeight;imgCache.push(images[i]);c.ieAlpha(images[i]);images[i].style.width="100%";}
if(imgCache.length){c.resize(function(){for(var i=0;i<imgCache.length;i++){var ratio=(imgCache[i].offsetWidth/imgCache[i].origWidth);imgCache[i].style.height=(imgCache[i].origHeight*ratio)+"px";}});}}},ieAlpha:function(img){var c=imgSizer;if(img.oldSrc){img.src=img.oldSrc;}
var src=img.src;img.style.width=img.offsetWidth+"px";img.style.height=img.offsetHeight+"px";img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='scale')"
img.oldSrc=src;img.src=c.Config.spacer;},resize:function(func){var oldonresize=window.onresize;if(typeof window.onresize!='function'){window.onresize=func;}else{window.onresize=function(){if(oldonresize){oldonresize();}
func();}}}}


/* LETTERING.JS STARTS */
jQuery(function($){
function injector(t, splitter, klass, after) {
var a = t.text().split(splitter), inject = '';
if (a.length) {
$(a).each(function(i, item) {
inject += '<span class="'+klass+(i+1)+'">'+item+'</span>'+after;
});
t.empty().append(inject);
}
}

var methods = {
init : function() {

return this.each(function() {
injector($(this), '', 'char', '');
});

},

words : function() {

return this.each(function() {
injector($(this), ' ', 'word', ' ');
});

},

lines : function() {

return this.each(function() {
var r = "eefec303079ad17405c889e092e105b0";
// Because it's hard to split a <br/> tag consistently across browsers,
// (*ahem* IE *ahem*), we replaces all <br/> instances with an md5 hash
// (of the word "split"). If you're trying to use this plugin on that
// md5 hash string, it will fail because you're being ridiculous.
injector($(this).children("br").replaceWith(r).end(), r, 'line', '');
});

}
};

$.fn.lettering = function( method ) {
// Method calling logic
if ( method && methods[method] ) {
return methods[ method ].apply( this, [].slice.call( arguments, 1 ));
} else if ( method === 'letters' || ! method ) {
return methods.init.apply( this, [].slice.call( arguments, 0 ) ); // always pass an array
}
$.error( 'Method ' + method + ' does not exist on jQuery.lettering' );
return this;
};

});


/* Custom Scripts */
jQuery(document).ready(function($) {

	
	$(".produk-starblok li").lettering('words');
	$(".produk-starblok .word1").lettering();

	/* Equalizing starblok height */
	var maxHeight = 0;
	
	$(".produk-starblok").find("li").each(function(){
	   if ($(this).height() > maxHeight) { maxHeight = $(this).height(); }
	   if ($(this).height() > 55) { maxHeight = 55; }
	});
	
	$(".produk-starblok").find("li").height(maxHeight);
});
jQuery(document).ready(function($) {
        
	var dipencet=0;	 
   	$(".suppfact-container").click(function(){
		$(".suppfact-img").slideToggle("fast");
		$("html").animate({ scrollTop: $(".suppfact-container").offset().top-50 }, 1000);
		if (dipencet == 0) {
		  dipencet=1;
		  $('.suppfact').html('Tutup Supplement Facts');
		}
		else
		if (dipencet == 1) {
		  dipencet=0;
		  $('.suppfact').html('Cek Supplement Facts');
		}
		return false;
	});

		
	$(".daftarsms").click(function(){
		$("#smscenter").submit();
	});
	$(".close-banner").click(function(){
		$("#login-banner").fadeOut();
	});
	$(".widget_wpsc_shopping_cart .widgettitle").click(function(){
		
		return false;		
	});

       var tinggidiv = 0;
	$(window).scroll(function(){
		tinggidiv = $('html').scrollTop();
		$(".tinggi").css("color","#fff").html(tinggidiv);
		if (tinggidiv > 110) {
			$("#sidebar").css("position","fixed");
			$("#sidebar").css("padding-top","0px");
			$("#sidebar").css("z-index","2");
			$("#main").css("padding-left","220px");
			$(".widget_wpsc_shopping_cart").css("border-radius","0 0 15px 15px");				
		} else
		{
			$("#sidebar").css("position","relative");
			$("#sidebar").css("padding-top","110px");
			$("#main").css("padding-left","20px");
			$(".widget_wpsc_shopping_cart").css("border-radius","0 15px 0 0");	
		}
	});
	
	
	
	//// begin of Register Form Modified
	 $('#aweber_checkbox').parent('p').next('br').remove();
	 $('#ws-plugin--s2member-custom-reg-field-user-pass1').siblings('br').remove();
	 $('#aweber_checkbox').parent('p').appendTo($('#register').prev('p'));
	 $('#ws-plugin--s2member-custom-reg-field-user-pass1').attr('placeholder','Type Password');
	 $('#ws-plugin--s2member-custom-reg-field-user-pass2').attr('placeholder','Type Password again');
	 $('#ws-plugin--s2member-custom-reg-field-user-pass1').prev('span').remove();
	 $('#aweber_checkbox').attr('checked','checked');
	 $('#register-form #user_login').attr('tabIndex',1);
	 $('#register-form #user_email').attr('tabIndex',2);
	 $('#ws-plugin--s2member-custom-reg-field-user-pass1').attr('tabIndex',3);
	 $('#ws-plugin--s2member-custom-reg-field-user-pass2').attr('tabIndex',4);
	 $('#aweber_checkbox').attr('tabIndex',5);
	 $('#register').attr('tabIndex',6);
	 $('#form-login #user_login').attr('tabIndex',7);
	 $('#form-login #user_pass').attr('tabIndex',8);
	 $('#rememberme').attr('tabIndex',9);
	 $('#login').attr('tabIndex',10);
	//// end of Register Form Modified
	
	$('.toTop a').click(function(e){
	    e.preventDefault();
	    if (dipencet == 1) {$('.suppfact-container').click();}
	    //$(window).animate({ scrollTop: $("#menu-top-navigation").offset().top }, 1000);
	    $(window).scrollTop(50);
	 });	
});
