jQuery(window).load(function(){  
function loadMe(){
b = 0;
jQuery('.menuHolder li').each(function() {
elem = jQuery(this).parent();
if(elem.is (".sub-menu")) { } else {
a = jQuery(this).outerWidth(true);
b = b+a;
if(b >= 960) {
jQuery(this).remove();
b = b-a
}
}
});
jQuery('.menuHolder li .dott:last').remove();

if(jQuery.browser.msie){
if(jQuery.browser.version.substring(0, 2) == "9.") {
l = 954-b;	
jQuery('.header').animate({'opacity':1});
} else {
l = 953-b;	
if(jQuery.browser.version.substring(0, 2) == "8.") {
l = 954-b;	
}
if(jQuery.browser.version.substring(0, 2) == "7.") {
l = 955-b;	
}
}
} else {
//ipad
var is_iPad = navigator.userAgent.match(/iPad/i) != null;
l = 954-b;
//iphone
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
if (document.cookie.indexOf("iphone_redirect=false") == -1){
l = 951-b;
}
}
if(is_iPad == true){
l = 954-b;
}
jQuery('.header').animate({'opacity':1});
}
jQuery('.logo').css({'width':l});

}
var is_iPad = navigator.userAgent.match(/iPad/i) != null;
var is_chrome = /chrome/.test( navigator.userAgent.toLowerCase() );
if(is_iPad || is_chrome || jQuery.browser.version.substring(0, 2) == "7." || jQuery.browser.version.substring(0, 2) == "8."){
setTimeout(loadMe, 1000);
}else{
loadMe();
}

i=999;
jQuery('.styledSelect').each(function(){
i--;
jQuery(this).css({'z-index':i});
});


}); 

jQuery(document).ready(function() {	
if (jQuery.browser.safari && document.readyState != "complete"){
setTimeout( arguments.callee, 1000 );
return;
}

jQuery("iframe").mouseover(function () {
jQuery(this).addClass('IframeClass');
});

if(jQuery.browser.version.substring(0, 2) == "9.") {
var checkSelect = jQuery('.styledSelect').width();
if(checkSelect){
i=0;
jQuery('.styledSelect').each(function(){
i++;
if(i==1){
jQuery(this).parent().parent().css({'width':'157px', 'float':'left', 'marginRight':10, 'marginTop':10});
}else{
jQuery(this).parent().parent().css({'width':'157px', 'float':'left', 'marginRight':10, 'marginTop':0});
}
});
}
}

/** eshop styling **/
i=0;
jQuery('.styledSelect').each(function(){
i++;
salesImg = jQuery('.saleImgWrap').outerWidth();
sidebarOn = jQuery('.sidebarOn').outerWidth();
eshopbutton = jQuery('.eshopbutton').outerWidth(true);
if(sidebarOn > 0){
if(salesImg > 0){
qtySize = 638 - eshopbutton - 5;
jQuery('.styledSelect').css({'width':162});
jQuery('.qty').css({'padding-left':qtySize});
if(i==4){
jQuery(this).css({'marginRight':0});
jQuery(this).after('<div class="clearAll"></div>');
i=0;
}
}
}else{
if(salesImg > 0){
qtySize = 696 - eshopbutton - 5;
jQuery(this).css({'width':177});
jQuery('.qty').css({'padding-left':qtySize});
if(i==4){
jQuery(this).css({'marginRight':0});
jQuery(this).after('<div class="clearAll"></div>');
i=0;
}
}else{
jQuery('.styledSelect').css({'width':150, 'marginRight':10});
//moet nog
if(i==5){
jQuery(this).css({'marginRight':0});
jQuery('.qty').css({'padding-left':760});
jQuery(this).after('<div class="clearAll"></div>');
i=0;
}
}
}
});

/** select style **/
jQuery('select').styledSelect();
hasParent = jQuery('.qty').parent();
if(hasParent){
jQuery('.qty').parent().before('<span class="tdDividerDotted"></span>');
}else{
jQuery('.qty').parent().before('<span class="tdDividerDotted"></span>');
}

var is_iPad = navigator.userAgent.match(/iPad/i) != null;
if(is_iPad){
jQuery('.styledSelect').css({width:150, marginRight:30});
jQuery('.sub-menu .subTop').css({'margin-bottom':-1});
jQuery('.sub-menu li').css({'margin-bottom':-1});
jQuery('.eshopbutton').css({ 'padding':4, 'font-size': 18, 'marginTop': 6, 'float':'right'});
jQuery('#unset').css({ 'margin':0, 'marginTop': -20, 'font-size': 16, 'float':'right'});
jQuery('#update').css({ 'margin':0, 'marginLeft': 5, 'font-size': 16, 'float':'right', 'position':'relative'});
}

/** TOGGLE SHORTCODE **/
var i = 2;
jQuery(".toggle-title").live('click', function(){
if(i==2){
jQuery(this).addClass('open').next().slideDown();
i=1;
}else{
jQuery(this).removeClass('open').next().slideUp();
i=2;
}
var theIcon = jQuery(this).hasClass('open');
if(theIcon == true){
jQuery('.toggleSwitch').html('-');
}else{
jQuery('.toggleSwitch').html('+');
}
});

/** ESHOP STYLING **/
jQuery('#cartItemw').html('Item');	


/** SCROLL MENU **/
function fixedMenu(){
i=1;
jQuery(window).scroll(function () { 
var is_iPad = navigator.userAgent.match(/iPad/i) != null;
var is_chrome = /chrome/.test( navigator.userAgent.toLowerCase() );
if(is_iPad == true || is_chrome || $.browser.safari){
var showMenu = window.pageYOffset;
}else{
var showMenu = document.documentElement.scrollTop;
}

var doMenu = 130;
if (showMenu > doMenu && i==1){
if ($.browser.msie  && parseInt($.browser.version) == 7) {
jQuery('.menuContainer').css({'position':'fixed', 'marginTop':'-30px', 'marginLeft':'-959px'});
jQuery('.searchForm').css({'position':'fixed', 'marginTop':'19px', 'marginLeft':'-205px'});
}else{
jQuery('.menuContainer').css({'position':'fixed', 'marginTop':'-30px', 'marginLeft':'-8px'});
jQuery('.searchForm').css({'position':'fixed', 'marginTop':'18px', 'marginLeft':'755px'});
}
var divWidth = jQuery('#menuLogo').outerWidth();
jQuery('.slideL').animate({ 'width': divWidth }, { duration: 500 });
function animateLogoIn(){
var is_iPad = navigator.userAgent.match(/iPad/i) != null;
var is_chrome = /chrome/.test( navigator.userAgent.toLowerCase() );
if(is_iPad == true || is_chrome || $.browser.safari){
var showMenu = window.pageYOffset;
}else{
var showMenu = document.documentElement.scrollTop;
}
if(showMenu > 130){
jQuery('#menuLogo').delay(300).fadeIn(200);
}
}
setTimeout(animateLogoIn, 200);
i=2;
}
if(showMenu < 130 && i==2){
i=1;
jQuery('.menuContainer').css({'position':'relative', 'marginTop':'105px'});
if ($.browser.msie  && parseInt($.browser.version) == 7) {
jQuery('.searchForm').css({'position':'relative', 'marginTop':'154px'});
}else{
jQuery('.searchForm').css({'position':'relative', 'marginTop':'-5px'});
}
jQuery('#menuLogo').fadeOut(200);
jQuery('.slideL').delay(300).animate({ width: '0px' }, { duration: 500 });
}
});
}

fixedMenu();


if ( jQuery("#wpadminbar").length == 0 ) {
if( jQuery('.anythingSlider').length == 0 ){

}else{
jQuery('.anythingControls').css('bottom', '-5px');
}
}else{
jQuery('.header').css('top','50px');
}
if ( jQuery('.center-bar-blog').length ){
jQuery('.anythingControls').css('bottom', '-5px');
//jQuery('.cs-buttons').css({'bottom':50});
}
jQuery('.anythingControls').css('bottom', '-10px');

setTimeout(barResizer, 600);


function barResizer(){
var windowWidth = jQuery('.social').outerWidth(true);
var centerWidth = jQuery('.center-bar').outerWidth(true);
var centerWidthHalf = centerWidth / 2;
var barWidth = windowWidth / 2 - centerWidthHalf;

menuW = windowWidth - 960;
menuW = menuW / 2;


jQuery('.leftHead').width(menuW);
jQuery('.rightHead').width(menuW);

jQuery('.left-bar').width(barWidth);
jQuery('.right-bar').width(barWidth);
}

function socialBar(){
jQuery('.tooltipGo').each(function() {
data = jQuery(this).attr('id');
if(data == 'Search') {
data = jQuery(this).attr('id');
}
if(data != '') {
jQuery(this).append('<div class="tooltip"><div class="tipBottom"></div>'+data+'</div>');
tooltipW = jQuery('.tooltip', this).outerWidth(true)/2;
tooltipWW = jQuery('.tooltip', this).outerWidth(true);
jQuery('.tooltip', this).css({'marginLeft':-tooltipW});
}
});
}
setTimeout( socialBar, 800 )
jQuery(window).bind("resize", barResizer);


jQuery('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
if (input.val() == '' || input.val() == input.attr('placeholder')) {
input.addClass('placeholder');
input.val(input.attr('placeholder'));
}
}).blur().parents('form').submit(function() {
jQuery(this).find('[placeholder]').each(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
}
});
});


loadSubMenu();


jQuery('.tooltipGo').hover(function() {
jQuery('.tooltip', this).stop(true, true).fadeIn();
}, function() {
jQuery('.tooltip', this).stop(true, true).fadeOut();
});

jQuery().UItoTop({ easingType: 'easeOutQuart' });


var i = 0;
jQuery('.widget-container').each(function() {
i += 1;
if(i == 3) {
jQuery(this).addClass('last');
i = 0;
}
});

jQuery('.portDivider:last').remove();

i=1;
jQuery('.portfolio').each(function() {
if(i==4){
jQuery(this).css({'marginRight':'0px'});
i=0;
}
portW = jQuery('.portLogo', this).outerWidth(true);
portH = jQuery('.portLogo img', this).outerHeight(true);
portH = 200-portH;
portH = portH/2;
jQuery('.portLogo', this).css({'left':-portW+'px','top':portH});
centerW = 228-portW;
centerW = centerW/2;
i++;
});

jQuery('.portfolio').hover(function() {
jQuery('.portLogo', this).stop(true, true).css({'opacity':1}).animate({'left':centerW});
jQuery('.overlayImage', this).stop(true, true).fadeIn();
}, function() {
jQuery('.portLogo', this).stop(true, true).animate({'left':320}, function() { jQuery(this).css({'left':-portW+'px'}); });
jQuery('.overlayImage', this).stop(true, true).fadeOut();
});

jQuery(".myImageID").animate({"left": "+=100"},{queue:false, duration:500, easing:"bounceEaseOut"});

/* VALIDATE CONTACT FORM */
function validateContactForm() {
var ok = true;
jQuery.each(jQuery('.required-field'), function() {
if(jQuery(this).val() == '') {
ok = false;
jQuery(this).css({'border':'#c00 solid 1px'});
} else {
jQuery(this).css({'border':'0'});
}
});
if(ok) {
return true;
} else {
jQuery('#contact-error').fadeIn();
}
return false;
}
if(jQuery('#contactform').length > 0) {
jQuery('#contactform').submit(function() { return validateContactForm(); });
jQuery('.contact-submit').click(function() {
jQuery('#contactform').submit();
});
}

jQuery(".menuHolder .sub-menu .sub-menu .sub-menu").each(function() {
jQuery(this).remove();
});
if($.browser.msie){
jQuery('.menuArrow').css({'margin':0});
}
jQuery(".menuHolder .sub-menu").each(function() {
elem = jQuery(this).parent();
jQuery('.hoverMenu:first', elem).append('<span class="menuArrow" style="display: none;">&#187;</span>');
jQuery('.hoverMenu.cloned:first', elem).append('<span class="menuArrow" style="display: none;">&#187;</span>');
jQuery('.hoverMenu.clonedActive:first', elem).append('<span class="menuArrow" style="display: none;">&#187;</span>');
});
function loadSubMenu() {
setTimeout(function() {			
jQuery(".menuHolder .sub-menu").each(function() {
elem = jQuery(this).parent();
jQuery(elem).append('<div class="menuArrow">&#155;</div>');
subW = jQuery(this).outerWidth(true);
//jQuery('.sub-menu', this).css({'marginLeft':subW+10});
});
}, 1000);
}


var slI = 0;
jQuery('.saleImgWrap').each(function() {
slI += 1;
jQuery('.saleImages', this).after('<ul id="SaleNav" class="'+slI+'">').cycle({ 
fx:     'fade', 
speed:  1500, 
timeout: 0, 
pager:  '.'+slI, 
pagerAnchorBuilder: function(idx, slide) { 
return '<li><a href="#"><img src="' + slide.src + '" width="169" height="92" class="hoverMe" /></a></li>';

} 
});
});

jQuery('ul#SaleNav li:last').css({marginRight:0});

jQuery('img.hoverMe').hover(function(){
jQuery(this).animate({'opacity':0.5}, 400);
}, function(){
jQuery(this).animate({'opacity':1}, 400);
});

/*jQuery('.saleCategory:odd').addClass('odd');
jQuery('.saleCategory:even').addClass('even');
jQuery('#SaleNav > li:odd').addClass('odd');*/


/* Shortcode tabs */
jQuery('.framed-tab-set .tab-content').eq(0).show();
jQuery('.framed-tab-set .tabs li a').eq(0).addClass('current');
jQuery('.framed-tab-set .tabs li a').click(function() {
jQuery('.framed-tab-set .tabs li a').removeClass('current');
jQuery(this).addClass('current');
jQuery('.framed-tab-set .tab-content').hide();
jQuery('.framed-tab-set .tab-content').eq(jQuery('.framed-tab-set .tabs li a').index(jQuery(this))).show();
});



});

