
/* =General
--------------------------------------------------------------------------------------------------------*/

$(document).ready(function(){
		
		$("#mainNavigation li.dropmenu").hover(function(){
			$(this).addClass("hover");
			$(this).find("div.dropmenuContainer").show();
		
		},function(){
			$(this).removeClass("hover");
			$(this).find("div.dropmenuContainer").hide();
		});
		
		$(".controlnavigation li.dropmenu").hover(function(){
			$(this).find("ul:first").show();
		
		},function(){
			$(this).find("ul:first").hide();
		});
		
		
		$(".controlnavigation li.dropmenuclick a.iconlogin").click(function(){
			$("#customerlogin").toggle();
			return false;		
		});
		
		$('#submit').click(function() {
			$('#loginform').submit();
			return false;		
		});
		
		
		var tabpanel = $('div#tabs div.tabcontainer');
		tabpanel.hide().filter(':first').show();
		
		$('div#tabs ul.tabmenu a').hover(function(){
			tabpanel.hide();
			var thisConte = "#"+$(this).attr('rel');
	
			tabpanel.filter(thisConte).show();

			$('div#tabs ul.tabmenu a').removeClass('active');
			$(this).addClass('active');
		
		
		 return false;
		})
		
		$('#loopedSlider').loopedSlider({
			autoStart: 10000,
			restart: 10000,
			containerClick:false
		});
		
		$('a:has(img)').css({ background: 'none' });
		$('a:has(img)').css({ 'padding-left': '0px'});
		

		
		
		
});

/* = Typography
---------------------------------------------*/
if($.cookie("css")) {
	$("#typography").attr("href",$.cookie("css"));	
} else {
	var lang = $("html").attr("lang")
	lang = (lang=="KO" || lang=="JP" || lang=="ZH") ? "KO" : "";
	$("#typography").attr("href","/C125705E00508423/RepositoryFile/CSS/$File/typography-medium"+lang+".css");
}

$(document).ready(function() { 
	$(".fontnavigation li a").live('click',function() {
		var lang = $("html").attr("lang")
		lang = (lang=="KO" || lang=="JP" || lang=="ZH") ? "KO" : "";
		$(".fontnavigation li a").removeClass("active");
		var thisRel = "/C125705E00508423/RepositoryFile/CSS/$File/"+$(this).attr('rel')+lang+".css";
		$(this).addClass("active");
		
		$("#typography").attr("href",thisRel);
		$.cookie("css",thisRel, {expires: 365, path: '/'});
		setTimeout(function () { 
		},500);
		return false;
		
		
		
		
	});
	
	
	
		/* accordionPanel
	----------------------------------------------------------------------------------------------------*/

	$("#accordion .accordioncontain").hide();
	$("#accordion .accordioncontain:first").show();
	$(".homeHRwidecolumn #accordion .accordioncontain:first").hide();
	$("#accordion .accordionheading").hover(function(){
		$(".accordionheading").removeClass("active");	
		$(this).next(".accordioncontain").not(":animated").slideDown('normal').siblings(".accordioncontain:visible").slideUp();
		$(this).addClass("active");
		
	}, function(){
	});
	$("#accordion .accordionheading").click(function(){
											
		$(this).next(".accordioncontain").slideToggle('normal')
		.siblings(".accordioncontain:visible").slideUp();
		$(this).toggleClass("active").siblings("#accordion .accordionheading").removeClass("active");
		
	});
	$("#contentaccordion .contentaccordioncontain").hide();
	$("#contentaccordion .contentaccordionheading").click(function(){
											
		$(this).next(".contentaccordioncontain").slideToggle('normal')
		.siblings(".contentaccordioncontain:visible").slideUp();
		$(this).toggleClass("active").siblings("#contentaccordion .contentaccordionheading").removeClass("active");
		
	});
	
	/* accordionPanel 
	----------------------------------------------------------------------------------------------------*/
	
});

/* = End Typography
---------------------------------------------*/

$(document).ready(function(){
	$("#accordionListing h2").click(function() {
		$(this).next().toggle();
		return false;
	}).next().hide();
});

$(document).ready(function(){
	$('#contact_location, #contact_target').change(function(){ 
		$('.anspr_list li').filter('li').addClass('hidden');
		$('.anspr_list li').filter($('#contact_location').val()).filter($('#contact_target').val()).removeClass('hidden');	
	}); 
});

$(document).ready(function(){
		$("a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'fast', show_title:false, overlay_gallery: false, default_width: 600, default_height: 600, theme:'mahle', slideshow: false});
		$("a[rel^='prettyPhoto[gallery1]']").prettyPhoto({animationSpeed:'fast', default_width: 600, default_height: 600, theme:'mahle', slideshow: false});
		$(".testimonial a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'fast', default_width: 630, default_height: 600, theme:'mahle', slideshow: false});			
});
/* Tab */
function equalHeight(container) { 
        var maxheight = 0; 
        container.each(function() { 
          var height = $(this).height(); 
          if(height > maxheight) { 
            maxheight = height; 
          } 
        }); 
        container.height(maxheight); 
      } 

 $(document).ready (function () { 
	equalHeight($('.tabnav_container .tabnav_active,.tabnav_container .tabnav')); 
}); 


 $(document).ready (function () { 
	$("#contactlink").click(function(){
		$.cookie("contacttarget","."+$(this).attr('rel'),{path: '/'});		
	})	
});

 $(document).ready (function () { 
	$("a.contloclink").click(function(){
		$.cookie("contacttarget","."+$(this).attr('rel').split("#")[0],{path: '/'});
		$.cookie("contactlocation","."+$(this).attr('rel').split("#")[1],{path: '/'});		
	})	
});

/* =Popup
--------------------------------------------------------------------------------------------------------*/
$(document).ready(function(){
						   		   
	//When you click on a link with class of poplight and the href starts with a # 
	$('a[rel="mapPopup"]').click(function() {
		var popID = $(this).attr('rel'); //Get Popup Name
		var popURL = $(this).attr('href'); //Get Popup href to define size
				
		//Pull Query & Variables from href URL
		var query= popURL.split('&w=');
		var queryURL = query[0];
		$.get(queryURL, function(data) {
			$('#' + popID).prepend(data);
		}); 
		
		
		var popWidth = query[1]; //Gets the first query string value

		//Fade in the Popup and add close button
		$('#' + popID).fadeIn().css({ 'width': Number( popWidth )-2 }).prepend('<a href="#" class="close closepopup"></a>');
		
		//Define margin for center alignment (vertical + horizontal) - we add 80 to the height/width to accomodate for the padding + border width defined in the css
		var popMargTop = ($('#' + popID).height() + 80) / 2;
		var popMargLeft = ($('#' + popID).width() + 80) / 2;
		
		//Apply Margin to Popup
		$('#' + popID).css({ 
			'margin-top' : -popMargTop,
			'margin-left' : -popMargLeft
		});
		
		//Fade in Background
		$('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
		$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer 
		
		return false;
	});
	
	
	//Close Popups and Fade Layer
	$('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
	  	$('#fade , .popup_block').fadeOut(function() {
			$('#fade, a.close, #intMap').remove();  
	}); //fade them both out
		
		return false;
	});

	
});

/* End Popup
--------------------------------------------------------------------------------------------------------*/

