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 >= 750) {
			jQuery(this).remove();
			b = b-a
		}
	 }
		
	});
	
	if(jQuery.browser.msie){
		if(jQuery.browser.version.substring(0, 2) == "9.") {
			l = 954-b;	
			//alert('a');
		} else {
			l = 953-b;	
			//alert('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;
		//alert(isiPad);	
	}
	}
	jQuery('.logo').css({'width':l});
	jQuery('.header').animate({'opacity':1});
	}
	var is_iPad = navigator.userAgent.match(/iPad/i) != null;
	var is_chrome = /chrome/.test( navigator.userAgent.toLowerCase() );
	if(is_iPad == true || is_chrome || jQuery.browser.version.substring(0, 2) == "7." || jQuery.browser.version.substring(0, 2) == "8."){
		setTimeout(loadMe, 1000);
	}else if($.browser.safari) {
		setTimeout(loadMe, 1000);
	} else {
		loadMe();
	}
	
}); 
jQuery(document).ready(function() {	
	if (jQuery.browser.safari && document.readyState != "complete"){
    //console.info('ready...');
    setTimeout( arguments.callee, 1000 );
    return;
  }
	
	if ( jQuery("#wpadminbar").length == 0 ) {
		if( jQuery('.anythingSlider').length == 0 ){
			jQuery('.social').css('bottom','0px');
			if(jQuery('.noContent').length != 0) {
			jQuery('.social').css('bottom','-17px');
			}
		}else{
			
			if(jQuery.browser.msie){
			if(jQuery.browser.version.substring(0, 2) == "7.") {
				if(jQuery('.noContentS1').length != 0) {
				jQuery('.anythingControls').css('bottom', '80px');
				jQuery('.social').css('bottom','12px');
				}
			}
		} else {
 			jQuery('.anythingControls').css('bottom', '60px');
			jQuery('.social').css('bottom','0px');
		}
		}
	}
	if ( jQuery('.center-bar-blog').length ){
		jQuery('.anythingControls').css({'bottom':10});
		//jQuery('.cs-buttons').css({'bottom':50});
	}
	
	function footerMenu(){
		jQuery('#menu-bottom').fadeIn('slow');	
	}
	setTimeout(footerMenu, 2000);
	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('.left-bar').fadeIn('slow');
			jQuery('.center-bar').fadeIn('slow');
			jQuery('.right-bar').fadeIn('slow');
			jQuery('.tooltipGo').each(function() {
		data = jQuery(this).attr('title');
		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);

	
	
  
$('[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() {
  $(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' });
	
	logoW = 700 - jQuery('.logo').outerWidth(true);
	menuW = 0;
	jQuery(".menuHolder  ul li").each(function() {
		jQuery('a:first', this).addClass('hoverMenu');
		jQuery('a:first', this).wrap('<div class="hoverHeight" />');
		elem = jQuery(this).parent();
		elem2 = jQuery(this);
			if(elem.is (".sub-menu")) { } else {
				// If current page is this menu item add another class
				if(elem2.is('.current-menu-item')) { jQuery('a:first', this).addClass('currentMenuA'); }
			}
	});
	
	
	
	
	
	
	jQuery('#menu-bottom li:first').addClass('first');	
	
	jQuery(".hoverHeight").each(function() {
		elem = jQuery('a', this);
		elemHeight = elem.outerHeight(true);
		marginTop = 20 - elemHeight;
		marginTop = marginTop / 2;
		elem2 = jQuery(this).parent();
		elem3 = elem2.parent();
		if(elem3.is ('.sub-menu')) {
			subHeight = elem.css('font-size')+2;
			jQuery(this).css({'height':subHeight});
			elem.css({'line-height':subHeight});
			} else {
		jQuery(this).css({'height':elemHeight, 'margin-top':marginTop});
		}
		if(elem.is('.currentMenuA')) {
		$(elem).clone().addClass('clonedActive').appendTo(this);
		} else {
		$(elem).clone().addClass('cloned').appendTo(this);
		}
	});

jQuery(".hoverHeight").hover(function() {
	elem = jQuery(this).parent();
	if(elem.is('currentMenuA')) {} else {
		$('.hoverMenu:first', this).stop(true, true).animate({'top':-20}, 300);
		$('.cloned:last', this).stop(true, true).animate({'top':0}, 300);
	}
}, function() {
		$('.hoverMenu', this).stop(true, true).animate({'top':0}, 300);
		$('.cloned', this).stop(true, true).animate({'top':20}, 300);
});

	
	
	
	
	jQuery('.menuHolder ul li').hover(function() {
		jQuery('.sub-menu:first', this).stop(true, true).fadeIn();
	}, function() {
		jQuery('.sub-menu:first', this).stop(true, true).delay(200).fadeOut();
	});
	
	
	var i = 0;
	jQuery('.widget-container').each(function() {
		i += 1;
		if(i == 3) {
			jQuery(this).addClass('last');
			i = 0;
		}
	});
	
	jQuery('.portDivider:last').remove();
	
	
	jQuery('.portfolio').each(function() {
		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 = 320-portW;
		centerW = centerW/2;
	});
 
 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();
 });

$(".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();
	});
	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() {
			fMw = jQuery('ul#menu-bottom').outerWidth(true);
	jQuery('ul#menu-bottom').css({'width':fMw+1, 'marginLeft':-fMw/2});
			
	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);
	}
	
	
	
	
	
	
	
});
