﻿
$(document).ready(function () {

	SetExernalLinks();
	SetPanelLinks();

	SetFontReplacement();
	SetBannerForm();

	$('.youtube').click(function () {

	    $url = $(this).attr('href');
	    $embed = '<iframe width="700" height="394" src="' + $url.replace('watch?v=', 'embed/') + '" frameborder="0" allowfullscreen></iframe>';
	    $('#youtube-overlay #video').html($embed).show();
	    $('#youtube-overlay').css("left", ($(window).width() - $('#youtube-overlay').width()) / 2 + "px").css("top", ($(window).height() - $('#youtube-overlay').height()) / 2 + "px").show();
	    $('#blackout').fadeTo(250, 0.5);
	    return false;
	});
    
	$('#youtube-close').click(function () {
	    $('#youtube-overlay').hide();
	    $('#blackout').hide();
	    return false;
	});

	$('#northAmerica').hover(function () {
	    $('#northAmericaHover').show()
	}, function () { $('#northAmericaHover').hide() });

	$('#southAmerica').hover(function () {
	    $('#southAmericaHover').show()
	}, function () { $('#southAmericaHover').hide() });

	$('#europe').hover(function () {
	    $('#europeHover').show()
	}, function () { $('#europeHover').hide() });

	$('#china').hover(function () {
	    $('#chinaHover').show()
	}, function () { $('#chinaHover').hide() });

});


function SetExernalLinks() {
	$("a[rel*='external']").attr('target', '_blank');
}

function SetPanelLinks() {
	$('.linkpanel')
		.click(function () {
			var link = $(this).find("a").eq(0);
			location.href = link.attr("href");
		})
		.mouseover(function () {
			$(this).css("cursor", "pointer");
			$(this).toggleClass("linkpanel_hover", true);
		})
		.mouseout(function () {
			$(this).css("cursor", "default");
			$(this).toggleClass("linkpanel_hover", false);
		});
}

/*function SetFontReplacement() {
	Cufon.replace('h1');
	Cufon.replace('h2');
	Cufon.replace('h3');
	Cufon.replace('h4');
	Cufon.replace('h5');
	Cufon.replace('.main-nav ul li a');
	Cufon.replace('.quick-nav ul li a');
	Cufon.replace('.page-nav a');
	Cufon.replace('.sub-nav a');
	Cufon.replace('a.btn');
	Cufon.replace('#search ul');
	Cufon.replace('.view-toggle ul li');
}*/

function SetBannerForm() {
	$("select, input:checkbox, input:radio, input:file").uniform();
}


