var $ = jQuery.noConflict();

/* ------------------------------------------------------------------------
Main Navigation
 * ------------------------------------------------------------------------- */
jQuery(document).ready(function(){initScrollTop()});function initNav(){var nav=jQuery("#menu-main-nav");var duration=260;jQuery(nav).find(".sub-menu").css({left:0});jQuery(nav).find("> li").each(function(){var height=jQuery(this).find("> .drop").height();jQuery(this).find("> .drop").css({display:"none",height:0,overflow:"hidden"});jQuery(this).find(".drop li > .drop").css({display:"none",width:0});if(!$.browser.msie){jQuery(this).find("> .drop").css({"opacity":0});jQuery(this).find(".drop li > .drop").css({"opacity":0})}jQuery(this).mouseenter(function(){jQuery(this).addClass("hover");var drop=jQuery(this).find("> .drop");if($.browser.msie){jQuery(drop).css({display:"block"}).stop().animate({"height":height},duration,function(){jQuery(this).css({"overflow":"visible"})})}else{jQuery(drop).css({display:"block"}).stop().animate({"height":height,"opacity":1},duration,function(){jQuery(this).css({"overflow":"visible"})})}}).mouseleave(function(){var _this=jQuery(this);if($.browser.msie){jQuery(this).find("> .drop").stop().css({"overflow":"hidden"}).animate({"height":0},duration,function(){jQuery(_this).removeClass("hover")})}else{jQuery(this).find("> .drop").stop().css({"overflow":"hidden"}).animate({"height":0,"opacity":0},duration,function(){jQuery(_this).removeClass("hover")})}});jQuery(this).find(".drop ul > li ").mouseenter(function(){jQuery(this).addClass("hover");var pageW=getPageSize()[2];if(pageW<jQuery(this).offset().left+236*2){jQuery(this).find("> .drop").css({left:'auto',right:236})}if($.browser.msie){jQuery(this).find("> .drop").css({display:'block'}).stop().animate({"width":236},duration,function(){jQuery(this).css({overflow:'visible'})})}else{jQuery(this).find("> .drop").css({display:'block'}).stop().animate({"width":236,"opacity":1},duration,function(){jQuery(this).css({overflow:'visible'})})}}).mouseleave(function(){jQuery(this).removeClass("hover");if($.browser.msie){jQuery(this).find("> .drop").stop().css({overflow:'hidden'}).animate({width:0},duration,function(){jQuery(this).css({display:'none'})})}else{jQuery(this).find("> .drop").stop().css({overflow:'hidden'}).animate({width:0,"opacity":0},duration,function(){jQuery(this).css({display:'none'})})}})})}

(function(B){B(document).ready(function(){var mainNav=B('#menu-main-nav');var lis=mainNav.find('li');var shownav=jQuery("#menu-main-nav");lis.children('ul').wrap('<div class="c" / >');var cElems=B('.c');cElems.wrap('<div class="drop" / >');cElems.before('<div class="t"></div>');cElems.after('<div class="b"></div>');jQuery(shownav).find(".sub-menu").css({display:"block"});initNav()})})(jQuery);(function(C){C(document).ready(function(){jQuery("#menu-main-nav li:has(ul)").addClass("parent")})})(jQuery);

function getPageSize(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=document.body.scrollWidth;yScroll=window.innerHeight+window.scrollMaxY}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight}else if(document.documentElement&&document.documentElement.scrollHeight>document.documentElement.offsetHeight){xScroll=document.documentElement.scrollWidth;yScroll=document.documentElement.scrollHeight}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight}var windowWidth,windowHeight;if(self.innerHeight){windowWidth=self.innerWidth;windowHeight=self.innerHeight}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight}if(yScroll<windowHeight){pageHeight=windowHeight}else{pageHeight=yScroll}if(xScroll<windowWidth){pageWidth=windowWidth}else{pageWidth=xScroll}return[pageWidth,pageHeight,windowWidth,windowHeight]}

/* ------------------------------------------------------------------------
Scroll to Top
 * ------------------------------------------------------------------------- */
function initScrollTop(){var change_speed=1200;jQuery('a.link-top').click(function(){if(!$.browser.opera){jQuery('body').animate({scrollTop:0},{queue:false,duration:change_speed})}jQuery('html').animate({scrollTop:0},{queue:false,duration:change_speed});return false})}

/* ------------------------------------------------------------------------
	-_-!
 * ------------------------------------------------------------------------- */
 /**
 * Jquery KaMe Plugin		
 **/
(function($){  
	/**
	 * Jquery: KaMe Scrool Plugin
	 * @version: 0.2
	 **/
	$.fn.kScroll = function( selector ) {  			
	var KameJs={};
	$(selector+" a").click(function(){		
		$('html, body').animate({scrollTop:0}, 'slow');
		return false;		
	});
	$(window).scroll(function() {		
		if($(window).scrollTop()>=150){
			if(!KameJs.showingTopClicker){
				KameJs.showingTopClicker=true;
				$(selector).fadeIn();
				$("#footer").animate({marginBottom:"0"})
			}
		} else {
			if(KameJs.showingTopClicker){
				KameJs.showingTopClicker=false;
				$(selector).fadeOut();
			}
		}
	});
  };  
})(jQuery);			
$("#header").kScroll('#back-to-top');
/* ------------------------------------------------------------------------
	-_-!
 * ------------------------------------------------------------------------- */			
