/* initilization and common routines */

$(document).ready(function() {

	// Add shadows
	$(".shadow").wrap("<div class='s1'><div class='s2'><div class='s3'></div></div></div>");

	// initilize the nav bar
    $('ul#nav').superfish({
        delay:       800,                            // 1000 = one second delay on mouseout
        animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation
        speed:       'fast',                          // faster animation speed
        autoArrows:  true,                           // disable generation of arrow mark-up
        dropShadows: false                            // disable drop shadows
    });


// Product page tabs
	$('a.tabs').each(function(i) {
		$this = $(this);
		$(this).bind('click',function(){
			$(this).addClass('active').siblings().removeClass('active');
			$('div.tab_contents').eq(i).addClass('active').siblings().removeClass('active');
			return false;
		});
	});

	$("#youtube_wrapper").show();

	if ($("#number_slideshow").length) {
		$("#number_slideshow").number_slideshow({
			slideshow_autoplay: 'enable',//enable disable
			slideshow_time_interval: '3000',
			slideshow_window_background_color: "transparent",
			slideshow_window_padding: '0',
			slideshow_window_width: '506',
			slideshow_window_height: '230',
			slideshow_border_size: '0',
			slideshow_border_color: 'black',
			slideshow_show_button: 'enable',//enable disable
			slideshow_button_text_color: '#fff',
			slideshow_button_background_color: '#C77816',
			slideshow_button_current_background_color: '#4D271E',
			slideshow_button_border_color: '#DFDDD4',
			slideshow_button_border_size: '1'
		});
	}
});

/*
$('div#head_nav').mouseover(function(){
	$('ul.sf-menu li.current').hideSuperfishUl();
});

$(document.body).click(function(){
	$('ul.sf-menu li.current').hideSuperfishUl();
});
*/

$(window).unload(function(){
	$('ul.sf-menu li.current').hideSuperfishUl();
});


/**** common functions *****/

function addLoadListener(fn) {
	if (typeof window.addEventListener != "undefined"){
		window.addEventListener("load", fn, false);
	} else if (typeof document.addEventListener != "undefined") {
		document.addEventListener("load", fn, false);
	} else if (typeof window.attachEvent != "undefined") {
		window.attachEvent("onload", fn);
	} else {
		var oldfn=window.onload;
		if (typeof window.onload != "function") window.onload = fn; else window.onload = function() { oldfn(); fn();}
	}
}

function obj_exists(id){
    try {
        var x = document.getElementById(id).id;
        return true;
    } catch(err) {
        return false;
    }
}

