/* this file stores js only for front page */

$(document).ready(function() {	

			   
	/* Homepage Slider */	
	jQuery('#coda-slider-1').codaSlider({
		autoSlide: true, 
		autoSlideInterval: 10000,
		slideEaseDuration: 2000, 
		slideEaseFunction: 'easeInOutExpo', 
		dynamicTabsAlign: 'right',
		dynamicArrows: false, 
		crossLinking: false
	});		
	
});



$(function () { 
	// Stack initialize
	var openspeed = 300;
	var closespeed = 300;
	$('.stack>img').toggle(function(){
		var vertical = 0;
		var horizontal = 0;
		var $el=$(this);
		$el.next().children().each(function(){
			$(this).animate({top: '-' + vertical + 'px', left: horizontal + 'px'}, openspeed);
			vertical = vertical + 55;
			horizontal = (horizontal+.01)*1.35;
		});
		$el.next().animate({top: '-50px', left: '10px'}, openspeed).addClass('openStack')
		   .find('li a>img').animate({width: '50px', marginLeft: '9px'}, openspeed);
		$el.animate({paddingTop: '0'});
		$('#testies1').animate({opacity:0.3},1000);
		$('#testies2').animate({opacity:0.3},1000);
	}, function(){
		//reverse above
		var $el=$(this);
		$el.next().removeClass('openStack').children('li').animate({top: '55px', left: '-10px'}, closespeed);
		$el.next().find('li a>img').animate({width: '79px', marginLeft: '0'}, closespeed);
		$el.animate({paddingTop: '35px'});
		$('#testies1').animate({opacity:1},1000);
		$('#testies2').animate({opacity:1},1000);
	});
	
	// Stacks additional animation
	$('.stack li a').hover(function(){
		$("img",this).animate({width: '56px'}, 100);
		$("span",this).animate({marginRight: '30px'});
	},function(){
		$("img",this).animate({width: '50px'}, 100);
		$("span",this).animate({marginRight: '0'});
	});
});


/* This file stores JS that is used in Packages Page */

jQuery(document).ready(function() {
	jQuery('#priceTable .priceHolder').width((parseInt(jQuery('#priceTable .priceMask').width()+30) * jQuery('#priceTable .tabContent').length));
	
	jQuery('#priceTable .tabContent').width(jQuery('#priceTable .priceMask').width());
				
	jQuery('#priceTable .priceMask').height(jQuery('#pack1').height());
	
	jQuery('#priceTable .priceTabs li').click(function () {
		//Get the height of the sub-panel  
		var panelheight = $($(this).find('a').attr('href')).height();  
		
		//Set class for the selected item  
		jQuery('#priceTable .priceTabs li').removeClass('active');  
		jQuery(this).addClass('active');  
		
		//Resize the height  
		jQuery('#priceTable .priceMask').animate({'height':panelheight},{queue:false, duration:500});           
		
		//Scroll to the correct panel, the panel id is grabbed from the href attribute of the anchor  
		jQuery('#priceTable .priceMask').scrollTo(jQuery(this).find('a').attr('href'), 800);
		
		//Discard the link default behavior  
		return false;  	
	});
	
});





jQuery(document).ready(function() {
	jQuery('#orderTable .orderHolder').width((parseInt(jQuery('#orderTable .orderMask').width()+30) * jQuery('#orderTable .tabContent').length));
	
	jQuery('#orderTable .tabContent').width(jQuery('#orderTable .orderMask').width());
				
	jQuery('#orderTable .orderMask').height(jQuery('#pack1').height());
	
	jQuery('#orderTable .orderTabs li').click(function () {
		//Get the height of the sub-panel  
		var panelheight = $($(this).find('a').attr('href')).height();  
		
		//Set class for the selected item  
		jQuery('#orderTable .orderTabs li').removeClass('active');  
		jQuery(this).addClass('active');  
		
		//Resize the height  
		jQuery('#orderTable .orderMask').animate({'height':panelheight},{queue:false, duration:500});           
		
		//Scroll to the correct panel, the panel id is grabbed from the href attribute of the anchor  
		jQuery('#orderTable .orderMask').scrollTo(jQuery(this).find('a').attr('href'), 800);
		
		//Discard the link default behavior  
		return false;  	
	});
	
});






/* This file stores JS that is used in all pages */

jQuery(document).ready(function() {		
	
	/* Add play buttons on class .videoThumb */	
	jQuery('.videoThumb').prepend('<span></span>');
	
	/* Add ribbons on class .winner */	
	jQuery('.winner').prepend('<span></span>');
	
	/* Fix Contact Form Textarea Focus */
	jQuery(".textarea textarea")
		.focus(function() {jQuery(this).parents('.textarea').addClass("focus");})
		.blur(function() {jQuery(this).parents('.textarea').removeClass("focus");});
	
	/* Remove the scrolbars from textarea in Opeara  */	
	jQuery.each(jQuery.browser, function(i) {
		if($.browser.opera) $("textarea").css("overflow","hidden");
	});
		
	/* Start Portofolio Carousel */
	jQuery("#portofolioSlider .carousel").jcarousel({
		scroll: 4,
		animation: 1500,
		easing: 'easeOutExpo',
		initCallback:  portofolioCarouselInit,
		buttonNextCallback: portofolioCarouselNext,
		buttonPrevCallback: portofolioCarouselPrev,
		itemLoadCallback: {onAfterAnimation: portofolioCarouselCounter}
	});
	
	/* Start Bronze Portofolio Carousel */
	jQuery("#portofolioSliderBronze .carousel").jcarousel({
		scroll: 4,
		animation: 1500,
		easing: 'easeOutExpo',
		initCallback:  portofolioCarouselInit1,
		buttonNextCallback: portofolioCarouselNext1,
		buttonPrevCallback: portofolioCarouselPrev1,
		itemLoadCallback: {onAfterAnimation: portofolioCarouselCounter1}
	});
	
	/* Start BronzeSmall Portofolio Carousel */
	jQuery("#portofolioSliderBronzeSmall .carousel").jcarousel({
		scroll: 3,
		animation: 1500,
		easing: 'easeOutExpo',
		initCallback:  portofolioCarouselInit5,
		buttonNextCallback: portofolioCarouselNext5,
		buttonPrevCallback: portofolioCarouselPrev5,
		itemLoadCallback: {onAfterAnimation: portofolioCarouselCounter5}
	});
	
	/* Start Silver Portofolio Carousel */
	jQuery("#portofolioSliderSilver .carousel").jcarousel({
		scroll: 4,
		animation: 1500,
		easing: 'easeOutExpo',
		initCallback:  portofolioCarouselInit2,
		buttonNextCallback: portofolioCarouselNext2,
		buttonPrevCallback: portofolioCarouselPrev2,
		itemLoadCallback: {onAfterAnimation: portofolioCarouselCounter2}
	});
	
	/* Start SilverSmall Portofolio Carousel */
	jQuery("#portofolioSliderSilverSmall .carousel").jcarousel({
		scroll: 3,
		animation: 1500,
		easing: 'easeOutExpo',
		initCallback:  portofolioCarouselInit6,
		buttonNextCallback: portofolioCarouselNext6,
		buttonPrevCallback: portofolioCarouselPrev6,
		itemLoadCallback: {onAfterAnimation: portofolioCarouselCounter6}
	});
	
	/* Start Gold Portofolio Carousel */
	jQuery("#portofolioSliderGold .carousel").jcarousel({
		scroll: 4,
		animation: 1500,
		easing: 'easeOutExpo',
		initCallback:  portofolioCarouselInit3,
		buttonNextCallback: portofolioCarouselNext3,
		buttonPrevCallback: portofolioCarouselPrev3,
		itemLoadCallback: {onAfterAnimation: portofolioCarouselCounter3}
	});
	
	/* Start GoldSmall Portofolio Carousel */
	jQuery("#portofolioSliderGoldSmall .carousel").jcarousel({
		scroll: 3,
		animation: 1500,
		easing: 'easeOutExpo',
		initCallback:  portofolioCarouselInit7,
		buttonNextCallback: portofolioCarouselNext7,
		buttonPrevCallback: portofolioCarouselPrev7,
		itemLoadCallback: {onAfterAnimation: portofolioCarouselCounter7}
	});
	
	/* Start Platinum Portofolio Carousel */
	jQuery("#portofolioSliderPlatinum .carousel").jcarousel({
		scroll: 4,
		animation: 1500,
		easing: 'easeOutExpo',
		initCallback:  portofolioCarouselInit4,
		buttonNextCallback: portofolioCarouselNext4,
		buttonPrevCallback: portofolioCarouselPrev4,
		itemLoadCallback: {onAfterAnimation: portofolioCarouselCounter4}
	});
});




/* Portofolio Carousel Callback Functions */
var itemP, itemN;
function portofolioCarouselInit(carousel) {
	jQuery('#portofolioSlider .jcarousel-next').bind('click', function() {
		carousel.next();
		return false;
	});	
	jQuery('#portofolioSlider .jcarousel-prev').bind('click', function() {
		carousel.prev();
		return false;
	});
};
function portofolioCarouselNext(carousel, button, enabled) {
	enabled ? jQuery('#portofolioSlider .jcarousel-next').removeClass("disabled") : jQuery('#portofolioSlider .jcarousel-next').addClass("disabled");
};
function portofolioCarouselPrev(carousel, button, enabled) {
	enabled ? jQuery('#portofolioSlider .jcarousel-prev').removeClass("disabled") : jQuery('#portofolioSlider .jcarousel-prev').addClass("disabled");
}; 
function portofolioCarouselCounter(carousel, state) {
	if(state == "init") {
			itemN = jQuery("#portofolioSlider .carousel ul li").size();
			itemN < 4 ? itemP = itemN : itemP = 4;
			jQuery("#portofolioSlider .counter").text(itemP+"/"+itemN);	
	}
	if(state == "next") {
		if(!jQuery(this).hasClass("disabled")){
			if(itemP + 4 > itemN) itemP += itemN-itemP;
			else itemP += 4;
			jQuery("#portofolioSlider .counter").text(itemP+"/"+itemN);	
		}
	}
	if(state == "prev") {
		if(!jQuery(this).hasClass("disabled")){
			if(itemP - 4 < 4) itemP -= itemP-4;
			else itemP -= 4;
			jQuery("#portofolioSlider .counter").text(itemP+"/"+itemN);	
		}
	}
}


/* Bronze Portofolio Carousel Callback Functions */
var itemP, itemN;
function portofolioCarouselInit1(carousel) {
	jQuery('#portofolioSliderBronze .jcarousel-next').bind('click', function() {
		carousel.next();
		return false;
	});	
	jQuery('#portofolioSliderBronze .jcarousel-prev').bind('click', function() {
		carousel.prev();
		return false;
	});
};
function portofolioCarouselNext1(carousel, button, enabled) {
	enabled ? jQuery('#portofolioSliderBronze .jcarousel-next').removeClass("disabled") : jQuery('#portofolioSliderBronze .jcarousel-next').addClass("disabled");
};
function portofolioCarouselPrev1(carousel, button, enabled) {
	enabled ? jQuery('#portofolioSliderBronze .jcarousel-prev').removeClass("disabled") : jQuery('#portofolioSliderBronze .jcarousel-prev').addClass("disabled");
}; 
function portofolioCarouselCounter1(carousel, state) {
	if(state == "init") {
			itemN = jQuery("#portofolioSliderBronze .carousel ul li").size();
			itemN < 4 ? itemP = itemN : itemP = 4;
			jQuery("#portofolioSliderBronze .counter").text(itemP+"/"+itemN);	
	}
	if(state == "next") {
		if(!jQuery(this).hasClass("disabled")){
			if(itemP + 4 > itemN) itemP += itemN-itemP;
			else itemP += 4;
			jQuery("#portofolioSliderBronze .counter").text(itemP+"/"+itemN);	
		}
	}
	if(state == "prev") {
		if(!jQuery(this).hasClass("disabled")){
			if(itemP - 4 < 4) itemP -= itemP-4;
			else itemP -= 4;
			jQuery("#portofolioSliderBronze .counter").text(itemP+"/"+itemN);	
		}
	}
}

/* BronzeSmall Portofolio Carousel Callback Functions */
var itemP, itemN;
function portofolioCarouselInit5(carousel) {
	jQuery('#portofolioSliderBronzeSmall .jcarousel-next').bind('click', function() {
		carousel.next();
		return false;
	});	
	jQuery('#portofolioSliderBronzeSmall .jcarousel-prev').bind('click', function() {
		carousel.prev();
		return false;
	});
};
function portofolioCarouselNext5(carousel, button, enabled) {
	enabled ? jQuery('#portofolioSliderBronzeSmall .jcarousel-next').removeClass("disabled") : jQuery('#portofolioSliderBronzeSmall .jcarousel-next').addClass("disabled");
};
function portofolioCarouselPrev5(carousel, button, enabled) {
	enabled ? jQuery('#portofolioSliderBronzeSmall .jcarousel-prev').removeClass("disabled") : jQuery('#portofolioSliderBronzeSmall .jcarousel-prev').addClass("disabled");
}; 
function portofolioCarouselCounter5(carousel, state) {
	if(state == "init") {
			itemN = jQuery("#portofolioSliderBronzeSmall .carousel ul li").size();
			itemN < 3 ? itemP = itemN : itemP = 3;
			jQuery("#portofolioSliderBronzeSmall .counter").text(itemP+"/"+itemN);	
	}
	if(state == "next") {
		if(!jQuery(this).hasClass("disabled")){
			if(itemP + 3 > itemN) itemP += itemN-itemP;
			else itemP += 3;
			jQuery("#portofolioSliderBronzeSmall .counter").text(itemP+"/"+itemN);	
		}
	}
	if(state == "prev") {
		if(!jQuery(this).hasClass("disabled")){
			if(itemP - 3 < 3) itemP -= itemP-3;
			else itemP -= 3;
			jQuery("#portofolioSliderBronzeSmall .counter").text(itemP+"/"+itemN);	
		}
	}
}


/* Silver Portofolio Carousel Callback Functions */
var itemP, itemN;
function portofolioCarouselInit2(carousel) {
	jQuery('#portofolioSliderSilver .jcarousel-next').bind('click', function() {
		carousel.next();
		return false;
	});	
	jQuery('#portofolioSliderSilver .jcarousel-prev').bind('click', function() {
		carousel.prev();
		return false;
	});
};
function portofolioCarouselNext2(carousel, button, enabled) {
	enabled ? jQuery('#portofolioSliderSilver .jcarousel-next').removeClass("disabled") : jQuery('#portofolioSliderSilver .jcarousel-next').addClass("disabled");
};
function portofolioCarouselPrev2(carousel, button, enabled) {
	enabled ? jQuery('#portofolioSliderSilver .jcarousel-prev').removeClass("disabled") : jQuery('#portofolioSliderSilver .jcarousel-prev').addClass("disabled");
}; 
function portofolioCarouselCounter2(carousel, state) {
	if(state == "init") {
			itemN = jQuery("#portofolioSliderSilver .carousel ul li").size();
			itemN < 4 ? itemP = itemN : itemP = 4;
			jQuery("#portofolioSliderSilver .counter").text(itemP+"/"+itemN);	
	}
	if(state == "next") {
		if(!jQuery(this).hasClass("disabled")){
			if(itemP + 4 > itemN) itemP += itemN-itemP;
			else itemP += 4;
			jQuery("#portofolioSliderSilver .counter").text(itemP+"/"+itemN);	
		}
	}
	if(state == "prev") {
		if(!jQuery(this).hasClass("disabled")){
			if(itemP - 4 < 4) itemP -= itemP-4;
			else itemP -= 4;
			jQuery("#portofolioSliderSilver .counter").text(itemP+"/"+itemN);	
		}
	}
}


/* SilverSmall Portofolio Carousel Callback Functions */
var itemP, itemN;
function portofolioCarouselInit6(carousel) {
	jQuery('#portofolioSliderSilverSmall .jcarousel-next').bind('click', function() {
		carousel.next();
		return false;
	});	
	jQuery('#portofolioSliderSilverSmall .jcarousel-prev').bind('click', function() {
		carousel.prev();
		return false;
	});
};
function portofolioCarouselNext6(carousel, button, enabled) {
	enabled ? jQuery('#portofolioSliderSilverSmall .jcarousel-next').removeClass("disabled") : jQuery('#portofolioSliderSilverSmall .jcarousel-next').addClass("disabled");
};
function portofolioCarouselPrev6(carousel, button, enabled) {
	enabled ? jQuery('#portofolioSliderSilverSmall .jcarousel-prev').removeClass("disabled") : jQuery('#portofolioSliderSilverSmall .jcarousel-prev').addClass("disabled");
}; 
function portofolioCarouselCounter6(carousel, state) {
	if(state == "init") {
			itemN = jQuery("#portofolioSliderSilverSmall .carousel ul li").size();
			itemN < 3 ? itemP = itemN : itemP = 3;
			jQuery("#portofolioSliderSilverSmall .counter").text(itemP+"/"+itemN);	
	}
	if(state == "next") {
		if(!jQuery(this).hasClass("disabled")){
			if(itemP + 3 > itemN) itemP += itemN-itemP;
			else itemP += 3;
			jQuery("#portofolioSliderSilverSmall .counter").text(itemP+"/"+itemN);	
		}
	}
	if(state == "prev") {
		if(!jQuery(this).hasClass("disabled")){
			if(itemP - 3 < 3) itemP -= itemP-3;
			else itemP -= 3;
			jQuery("#portofolioSliderSilverSmall .counter").text(itemP+"/"+itemN);	
		}
	}
}



/* Gold Portofolio Carousel Callback Functions */
var itemP, itemN;
function portofolioCarouselInit3(carousel) {
	jQuery('#portofolioSliderGold .jcarousel-next').bind('click', function() {
		carousel.next();
		return false;
	});	
	jQuery('#portofolioSliderGold .jcarousel-prev').bind('click', function() {
		carousel.prev();
		return false;
	});
};
function portofolioCarouselNext3(carousel, button, enabled) {
	enabled ? jQuery('#portofolioSliderGold .jcarousel-next').removeClass("disabled") : jQuery('#portofolioSliderGold .jcarousel-next').addClass("disabled");
};
function portofolioCarouselPrev3(carousel, button, enabled) {
	enabled ? jQuery('#portofolioSliderGold .jcarousel-prev').removeClass("disabled") : jQuery('#portofolioSliderGold .jcarousel-prev').addClass("disabled");
}; 
function portofolioCarouselCounter3(carousel, state) {
	if(state == "init") {
			itemN = jQuery("#portofolioSliderGold .carousel ul li").size();
			itemN < 4 ? itemP = itemN : itemP = 4;
			jQuery("#portofolioSliderGold .counter").text(itemP+"/"+itemN);	
	}
	if(state == "next") {
		if(!jQuery(this).hasClass("disabled")){
			if(itemP + 4 > itemN) itemP += itemN-itemP;
			else itemP += 4;
			jQuery("#portofolioSliderGold .counter").text(itemP+"/"+itemN);	
		}
	}
	if(state == "prev") {
		if(!jQuery(this).hasClass("disabled")){
			if(itemP - 4 < 4) itemP -= itemP-4;
			else itemP -= 4;
			jQuery("#portofolioSliderGold .counter").text(itemP+"/"+itemN);	
		}
	}
}


/* GoldSmall Portofolio Carousel Callback Functions */
var itemP, itemN;
function portofolioCarouselInit7(carousel) {
	jQuery('#portofolioSliderGoldSmall .jcarousel-next').bind('click', function() {
		carousel.next();
		return false;
	});	
	jQuery('#portofolioSliderGoldSmall .jcarousel-prev').bind('click', function() {
		carousel.prev();
		return false;
	});
};
function portofolioCarouselNext7(carousel, button, enabled) {
	enabled ? jQuery('#portofolioSliderGoldSmall .jcarousel-next').removeClass("disabled") : jQuery('#portofolioSliderGoldSmall .jcarousel-next').addClass("disabled");
};
function portofolioCarouselPrev7(carousel, button, enabled) {
	enabled ? jQuery('#portofolioSliderGoldSmall .jcarousel-prev').removeClass("disabled") : jQuery('#portofolioSliderGoldSmall .jcarousel-prev').addClass("disabled");
}; 
function portofolioCarouselCounter7(carousel, state) {
	if(state == "init") {
			itemN = jQuery("#portofolioSliderGoldSmall .carousel ul li").size();
			itemN < 3 ? itemP = itemN : itemP = 3;
			jQuery("#portofolioSliderGoldSmall .counter").text(itemP+"/"+itemN);	
	}
	if(state == "next") {
		if(!jQuery(this).hasClass("disabled")){
			if(itemP + 3 > itemN) itemP += itemN-itemP;
			else itemP += 3;
			jQuery("#portofolioSliderGoldSmall .counter").text(itemP+"/"+itemN);	
		}
	}
	if(state == "prev") {
		if(!jQuery(this).hasClass("disabled")){
			if(itemP - 3 < 3) itemP -= itemP-3;
			else itemP -= 3;
			jQuery("#portofolioSliderGoldSmall .counter").text(itemP+"/"+itemN);	
		}
	}
}




/* Platinum Portofolio Carousel Callback Functions */
var itemP, itemN;
function portofolioCarouselInit4(carousel) {
	jQuery('#portofolioSliderPlatinum .jcarousel-next').bind('click', function() {
		carousel.next();
		return false;
	});	
	jQuery('#portofolioSliderPlatinum .jcarousel-prev').bind('click', function() {
		carousel.prev();
		return false;
	});
};
function portofolioCarouselNext4(carousel, button, enabled) {
	enabled ? jQuery('#portofolioSliderPlatinum .jcarousel-next').removeClass("disabled") : jQuery('#portofolioSliderPlatinum .jcarousel-next').addClass("disabled");
};
function portofolioCarouselPrev4(carousel, button, enabled) {
	enabled ? jQuery('#portofolioSliderPlatinum .jcarousel-prev').removeClass("disabled") : jQuery('#portofolioSliderPlatinum .jcarousel-prev').addClass("disabled");
}; 
function portofolioCarouselCounter4(carousel, state) {
	if(state == "init") {
			itemN = jQuery("#portofolioSliderPlatinum .carousel ul li").size();
			itemN < 4 ? itemP = itemN : itemP = 4;
			jQuery("#portofolioSliderPlatinum .counter").text(itemP+"/"+itemN);	
	}
	if(state == "next") {
		if(!jQuery(this).hasClass("disabled")){
			if(itemP + 4 > itemN) itemP += itemN-itemP;
			else itemP += 4;
			jQuery("#portofolioSliderPlatinum .counter").text(itemP+"/"+itemN);	
		}
	}
	if(state == "prev") {
		if(!jQuery(this).hasClass("disabled")){
			if(itemP - 4 < 4) itemP -= itemP-4;
			else itemP -= 4;
			jQuery("#portofolioSliderPlatinum .counter").text(itemP+"/"+itemN);	
		}
	}
}



/* Start jQuery.ScrollTo Plugin  */
/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
/* End jQuery.ScrollTo Plugin  */

/* Make the tabbed menu */
jQuery(document).ready(function() {
	jQuery('#tabContainer .tabContent .viewAll').hide();
	jQuery('#tabNav').show();
	jQuery('#tabNav .jcarouselPrev2, #tabNav .jcarouselNext2').hide();

	jQuery('#tabHolder').width((parseInt(jQuery('#tabMask').width()+30) * jQuery('#tabContainer .tabContent').length));
	
	jQuery('#tabContainer .tabContent').width(jQuery('#tabMask').width());
			
	jQuery("#tabNav .viewAll").append(jQuery(jQuery('#tabs li.active').find('a').attr('href')).find('.viewAll').html());	
	
	jQuery('#tabMask').height($('#tab1').find('li').outerHeight()*4.1);
	
	jQuery('#tabMenu #tab1 .jcarousel-clip').height(jQuery('#tab1').find('li').outerHeight()*4.1);
	jQuery('#tabMenu #tab2 .jcarousel-clip').height(jQuery('#tab2').find('li').outerHeight()*3.1);

	jQuery('#tabs li').click(function () {
		if(jQuery(this).find('a').attr('href') == "#tab1") {
			var panelheight = $($(this).find('a').attr('href')).find('li').outerHeight()*4.1;
			jQuery('#tabNav .jcarouselPrev2, #tabNav .jcarouselNext2').hide();
			jQuery('#tabNav .jcarouselPrev1, #tabNav .jcarouselNext1').show();

		} else {
			var panelheight = jQuery($(this).find('a').attr('href')).find('li').outerHeight()*3.1;
			jQuery('#tabNav .jcarouselPrev1, #tabNav .jcarouselNext1').hide();
			jQuery('#tabNav .jcarouselPrev2, #tabNav .jcarouselNext2').show();
		}
				
		jQuery('#tabs li').removeClass('active');
		jQuery(this).addClass('active');
		
		jQuery('#tabMask').animate({'height':panelheight},{queue:false, duration:800});	
		jQuery('#tabMask .jcarousel-clip').animate({'height':panelheight},{queue:false, duration:800});	
		
		jQuery('#tabMask').scrollTo($(this).find('a').attr('href'), 800);
		
		jQuery("#tabNav .viewAll").empty().append(jQuery(jQuery(this).find('a').attr('href')).find('.viewAll').html());	
				
		return false;		
	});
	
	jQuery('#tab1').jcarousel({
        scroll: 4,
		vertical: true,
		animation: 1500,
		easing: 'easeOutExpo',
		initCallback:  tab1CarouselInit,
		buttonNextCallback: tab1CarouselNext,
		buttonPrevCallback: tab1CarouselPrev
    });	
	
	jQuery('#tab2').jcarousel({
        scroll: 4,
		vertical: true,
		animation: 1500,
		easing: 'easeOutExpo',
		initCallback:  tab2CarouselInit,
		buttonNextCallback: tab2CarouselNext,
		buttonPrevCallback: tab2CarouselPrev
    });	

});

function tab1CarouselInit(carousel) {
	jQuery('#tabNav .jcarouselNext1').bind('click', function() {
		carousel.next();
		return false;
	});	
	jQuery('#tabNav .jcarouselPrev1').bind('click', function() {
		carousel.prev();
		return false;
	});
};
function tab1CarouselNext(carousel, button, enabled) {
	enabled ? jQuery('#tabNav .jcarouselNext1').removeClass("disabled") : jQuery('#tabMenu .jcarouselNext1').addClass("disabled");
};
function tab1CarouselPrev(carousel, button, enabled) {
	enabled ? jQuery('#tabNav .jcarouselPrev1').removeClass("disabled") : jQuery('#tabMenu .jcarouselPrev1').addClass("disabled");
};

function tab2CarouselInit(carousel) {
	jQuery('#tabNav .jcarouselNext2').bind('click', function() {
		carousel.next();
		return false;
	});	
	jQuery('#tabNav .jcarouselPrev2').bind('click', function() {
		carousel.prev();
		return false;
	});
};
function tab2CarouselNext(carousel, button, enabled) {
	enabled ? jQuery('#tabNav .jcarouselNext2').removeClass("disabled") : jQuery('#tabMenu .jcarouselNext2').addClass("disabled");
};
function tab2CarouselPrev(carousel, button, enabled) {
	enabled ? jQuery('#tabNav .jcarouselPrev2').removeClass("disabled") : jQuery('#tabMenu .jcarouselPrev2').addClass("disabled");
};








/* Make the tabbed menu */
/*jQuery(document).ready(function() {
	jQuery('#ordertabContainer .ordertabContent .viewAll').hide();
	jQuery('#ordertabNav').show();
	jQuery('#ordertabNav .jcarouselPrev2, #ordertabNav .jcarouselNext2').hide();

	jQuery('#ordertabHolder').width((parseInt(jQuery('#ordertabMask').width()+30) * jQuery('#ordertabContainer .ordertabContent').length));
	
	jQuery('#ordertabContainer .ordertabContent').width(jQuery('#ordertabMask').width());
			
	jQuery("#ordertabNav .viewAll").append(jQuery(jQuery('#ordertabs li.active').find('a').attr('href')).find('.viewAll').html());	
	
	jQuery('#ordertabMask').height($('#ordertab1').find('li').outerHeight()*4.1);
	
	jQuery('#ordertabMenu #ordertab1 .jcarousel-clip').height(jQuery('#ordertab1').find('li').outerHeight()*4.1);
	jQuery('#ordertabMenu #ordertab2 .jcarousel-clip').height(jQuery('#ordertab2').find('li').outerHeight()*3.1);

	jQuery('#ordertabs li').click(function () {
		if(jQuery(this).find('a').attr('href') == "#ordertab1") {
			var panelheight = $($(this).find('a').attr('href')).find('li').outerHeight()*4.1;
			jQuery('#ordertabNav .jcarouselPrev2, #ordertabNav .jcarouselNext2').hide();
			jQuery('#ordertabNav .jcarouselPrev1, #ordertabNav .jcarouselNext1').show();

		} else {
			var panelheight = jQuery($(this).find('a').attr('href')).find('li').outerHeight()*3.1;
			jQuery('#ordertabNav .jcarouselPrev1, #ordertabNav .jcarouselNext1').hide();
			jQuery('#ordertabNav .jcarouselPrev2, #ordertabNav .jcarouselNext2').show();
		}
				
		jQuery('#ordertabs li').removeClass('active');
		jQuery(this).addClass('active');
		
		jQuery('#ordertabMask').animate({'height':panelheight},{queue:false, duration:800});	
		jQuery('#ordertabMask .jcarousel-clip').animate({'height':panelheight},{queue:false, duration:800});	
		
		jQuery('#ordertabMask').scrollTo($(this).find('a').attr('href'), 800);
		
		jQuery("#ordertabNav .viewAll").empty().append(jQuery(jQuery(this).find('a').attr('href')).find('.viewAll').html());	
				
		return false;		
	});
	
	jQuery('#ordertab1').jcarousel({
        scroll: 4,
		vertical: true,
		animation: 1500,
		easing: 'easeOutExpo',
		initCallback:  tab1CarouselInit,
		buttonNextCallback: tab1CarouselNext,
		buttonPrevCallback: tab1CarouselPrev
    });	
	
	jQuery('#ordertab2').jcarousel({
        scroll: 4,
		vertical: true,
		animation: 1500,
		easing: 'easeOutExpo',
		initCallback:  tab2CarouselInit,
		buttonNextCallback: tab2CarouselNext,
		buttonPrevCallback: tab2CarouselPrev
    });	
	
	

});

function tab1CarouselInit(carousel) {
	jQuery('#ordertabNav .jcarouselNext1').bind('click', function() {
		carousel.next();
		return false;
	});	
	jQuery('#ordertabNav .jcarouselPrev1').bind('click', function() {
		carousel.prev();
		return false;
	});
};
function tab1CarouselNext(carousel, button, enabled) {
	enabled ? jQuery('#ordertabNav .jcarouselNext1').removeClass("disabled") : jQuery('#ordertabMenu .jcarouselNext1').addClass("disabled");
};
function tab1CarouselPrev(carousel, button, enabled) {
	enabled ? jQuery('#ordertabNav .jcarouselPrev1').removeClass("disabled") : jQuery('#ordertabMenu .jcarouselPrev1').addClass("disabled");
};

function tab2CarouselInit(carousel) {
	jQuery('#ordertabNav .jcarouselNext2').bind('click', function() {
		carousel.next();
		return false;
	});	
	jQuery('#ordertabNav .jcarouselPrev2').bind('click', function() {
		carousel.prev();
		return false;
	});
};
function tab2CarouselNext(carousel, button, enabled) {
	enabled ? jQuery('#ordertabNav .jcarouselNext2').removeClass("disabled") : jQuery('#ordertabMenu .jcarouselNext2').addClass("disabled");
};
function tab2CarouselPrev(carousel, button, enabled) {
	enabled ? jQuery('#ordertabNav .jcarouselPrev2').removeClass("disabled") : jQuery('#ordertabMenu .jcarouselPrev2').addClass("disabled");
};
*/





/* Start ToggleVal Plugin  */
/* -------------------------------------------------- *
 * ToggleVal 2.1
 * Updated: 1/16/09
 * -------------------------------------------------- *
 * Author: Aaron Kuzemchak
 * URL: http://aaronkuzemchak.com/
 * Copyright: 2008-2009 Aaron Kuzemchak
 * License: MIT License
** -------------------------------------------------- */
(function(jQuery){jQuery.fn.toggleVal=function(theOptions){if(!theOptions||typeof(theOptions)=="object"){theOptions=jQuery.extend({focusClass:"tv-focused",changedClass:"tv-changed",populateFrom:"default",text:null,removeLabels:false},theOptions)}else if(typeof(theOptions)=="string"&&theOptions.toLowerCase()=="destroy"){var destroy=true}return this.each(function(){if(destroy){jQuery(this).unbind("focus.toggleval").unbind("blur.toggleval").removeData("defText");return false}var defText="";switch(theOptions.populateFrom){case"alt":defText=jQuery(this).attr("alt");jQuery(this).val(defText);break;case"label":defText=jQuery("label[for='"+jQuery(this).attr("id")+"']").text();jQuery(this).val(defText);break;case"custom":defText=theOptions.text;jQuery(this).val(defText);break;default:defText=jQuery(this).val()}jQuery(this).addClass("toggleval").data("defText",defText);if(theOptions.removeLabels==true){jQuery("label[for='"+jQuery(this).attr("id")+"']").remove()}jQuery(this).bind("focus.toggleval",function(){if(jQuery(this).val()==jQuery(this).data("defText")){jQuery(this).val("")}jQuery(this).addClass(theOptions.focusClass).removeClass(theOptions.changedClass)}).bind("blur.toggleval",function(){if(jQuery(this).val()==""){jQuery(this).val(jQuery(this).data("defText"))}jQuery(this).removeClass(theOptions.focusClass);if(jQuery(this).val()!=jQuery(this).data("defText")){jQuery(this).addClass(theOptions.changedClass)}else{jQuery(this).removeClass(theOptions.changedClass)}})})}})(jQuery);
/* End ToggleVal Plugin  */

/* Start customInput() Plugin  */
/*-------------------------------------------------------------------- 
 * jQuery plugin: customInput()
 * by Maggie Wachs and Scott Jehl, http://www.filamentgroup.com
 * Copyright (c) 2009 Filament Group
 * Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses.
 * Article: http://www.filamentgroup.com/lab/accessible_custom_designed_checkbox_radio_button_inputs_styled_css_jquery/  
--------------------------------------------------------------------*/
jQuery.fn.customInput=function(){jQuery(this).each(function(i){if(jQuery(this).is('[type=checkbox],[type=radio]')){var input=jQuery(this);var label=jQuery('label[for='+input.attr('id')+']');var inputType=(input.is('[type=checkbox]'))?'checkbox':'radio';jQuery('<div class="custom-'+inputType+'"></div>').insertBefore(input).append(input,label);var allInputs=jQuery('input[name='+input.attr('name')+']');label.hover(function(){jQuery(this).addClass('hover');if(inputType=='checkbox'&&input.is(':checked')){jQuery(this).addClass('checkedHover');}},function(){jQuery(this).removeClass('hover checkedHover');});input.bind('updateState',function(){if(input.is(':checked')){if(input.is(':radio')){allInputs.each(function(){jQuery('label[for='+jQuery(this).attr('id')+']').removeClass('checked');});};label.addClass('checked');}
else{label.removeClass('checked checkedHover checkedFocus');}}).trigger('updateState').click(function(){jQuery(this).trigger('updateState');}).focus(function(){label.addClass('focus');if(inputType=='checkbox'&&input.is(':checked')){jQuery(this).addClass('checkedFocus');}}).blur(function(){label.removeClass('focus checkedFocus');});}});};
/* End customInput() Plugin  */

jQuery(document).ready(function() {		
	/* Add a class for all the input fields that need a custom look */
	jQuery('.customRadioHere').addClass('customRadio');
	jQuery('.customCheckboxHere').addClass('customCheckbox');
	
	/* Using  customInput plugin make a custom looking radio and checkbox */
	jQuery('input').customInput();
	
	/* Hide the default looking radio and checkbox */
	jQuery('.customCheckboxHere input, .customRadioHere input').css({'left':'-9999px'});
	
	/* Lightbox Settings */		
	jQuery.nyroModalSettings({
		minWidth: 340,
		closeButton: '<a href="#" class="nyroModalClose" id="closeBut" title="close window">close window</a>',
		showBackground: function (elts, settings, callback) {
			elts.bg.css({opacity:0}).fadeTo(500, 0.5, callback);
		}
	});

	/* Login Lightbox */
	jQuery('.loginLightbox').nyroModal({
		width:340,
		endShowContent: function (elts, settings, callback) {			
			sIFR.replace(myriadPro, {
				selector: '#login h2',
				wmode: 'transparent',
				css: ['.sIFR-root {color:#464646;}']
			});
		}
	});
	
	/* Google Lightbox */
	jQuery('.boltonLightbox').nyroModal({
		width:700,
		endShowContent: function (elts, settings, callback) {			
			sIFR.replace(myriadPro, {
				selector: '#bolton h2',
				wmode: 'transparent',
				css: ['.sIFR-root {color:#464646;}']
			});
		}
	});
	
	/* Video Lightbox */
	jQuery('.videoLightbox').nyroModal({
		width:700,
		endShowContent: function (elts, settings, callback) {			
			sIFR.replace(myriadPro, {
				selector: '#google h2',
				wmode: 'transparent',
				css: ['.sIFR-root {color:#464646;}']
			});
		}
	});
	
	
	/* Image 1 Lightbox */
	jQuery('.themeLightbox').nyroModal({
		width:700,
		endShowContent: function (elts, settings, callback) {			
			sIFR.replace(myriadPro, {
				selector: '#theme h2',
				wmode: 'transparent',
				css: ['.sIFR-root {color:#464646;}']
			});
		}
	});
	
	
	/* T n C Lightbox */
	jQuery('.tcLightbox').nyroModal({
		width:750,
		endShowContent: function (elts, settings, callback) {			
			sIFR.replace(myriadPro, {
				selector: '#tc h2',
				wmode: 'transparent',
				css: ['.sIFR-root {color:#464646;}']
			});
		}
	});
	
	
	
	
	/* Image Lightbox */
	jQuery('.imageLightbox').nyroModal({});
	
	
	
	
	/* Footer Contact Form Settings */
	var contactForm = $("#footerForm");  
	var inputName = contactForm.find(".name"); 
	var inputEmail = contactForm.find(".email");
	var inputPhone = contactForm.find(".phone");  
	var inputMessage = contactForm.find(".message");
	var loadingImage = contactForm.find('.loadingImage');	
	var responseText = contactForm.find(".responseText");

	// On Submitting  	
	contactForm.bind("submit", function(e){
		if(validateName(e, inputName) & validateEmail(e, inputEmail) & validatePhone(e, inputPhone) & validateMessage(e, inputMessage)) { 
			ajaxSend(contactForm, responseText, loadingImage);
		};
		return false;
	});
		
	// On key press  
	inputName.bind("keyup", function(e){
		validateName(e,  inputName);
	});
	inputEmail.bind("keyup", function(e){
		validateEmail(e,  inputEmail);
	});
	inputPhone.bind("keyup", function(e){
		validatePhone(e,  inputPhone);
	});
	inputMessage.bind("keyup", function(e){
		validateMessage(e,  inputMessage);
	});
	
	/* Using ToggleVal Plugin to make the text in textInput forms toggle */
	jQuery(".textInput").toggleVal();
});

/* Functions requierd by the contact forms */
function validateName(event, input){  
	if(input.val().length < 4 || input.val() == "your name"){
		if(event.type != "keyup") {
			input.addClass("error"); 
			input.parent().find('.errorText').slideDown(); 
		}
		return false;
	}else{input.removeClass("error"); input.parent().find('.errorText').slideUp(); return true;}  
}
function validateEmail(event, input){
	var a = input.val();
	var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;
	
	if(filter.test(a)){
		input.removeClass("error"); 
		input.parent().find('.errorText').slideUp(); 
		return true;
	}else{
		if(event.type != "keyup") {
			input.addClass("error"); 
			input.parent().find('.errorText').slideDown(); 
		}
		return false;
	}
} 
function validatePhone(event, input){  
	if(input.val().length < 11 || input.val() == "your phone number"){
		if(event.type != "keyup") {
			input.addClass("error"); 
			input.parent().find('.errorText').slideDown(); 
		}
		return false;
	}else{input.removeClass("error"); input.parent().find('.errorText').slideUp(); return true;}  
}
function validateMessage(event, input){  
	if(input.val().length < 10 || input.val() == "your message"){
		if(event.type != "keyup") {
			input.parent().addClass("error"); 
			input.parent().find('.errorText').slideDown(); 
		}
		return false;
	}else{input.parent().removeClass("error"); input.parent().find('.errorText').slideUp(); return true;}  
} 
function ajaxSend(form, response, loading){	
	loading.show();
	response.slideUp().animate({X:""} , 200, "linear", function(){
		response.html('<small class="grey">Please wait, your message is being processed.</small><br />').slideDown();		
	});
	
	// Make AJAX request 		
	$.post('contactScript.php', form.serialize(), function(data){
		loading.hide(200);
		response.slideUp().animate({X:""} , 200, "linear", function(){response.html(data).slideDown();});
	});

	//Cancel default action
	return false;
};


/// CURVY CORNERS ON IMAGES FOR FIREFOX //////////////////////////

 	   

	
$(document).ready(function() {	
	
	$('.content_left img').bloooming_roundPic();
	$('.content_right img').bloooming_roundPic();
	$('.products').bloooming_shop();



	/// CUFON ////////////////////////////////////////////
 
    Cufon.replace('h1');
	Cufon.replace('h2');
	Cufon.replace('h3');
	Cufon.replace('.price');
	


	
	/// SHOP FUNCTIONS //////////////////////////////////

//	$('.products').bloooming_shop();	


	/// GALLERIES FUNCTIONS //////////////////////////////////

	$('.zoom').colorbox({
		opacity:0.6
	});	
	

	$('.videozoom').colorbox({
		iframe:true, innerWidth:425, innerHeight:344,opacity:0.6
	});	
	
	$('.zoom').bloooming_picHover();
	$('.videozoom').bloooming_picHover();
	
});


/*
$(document).ready(function() {
	$("#formElem").validationEngine()
});

*/
