function openNewWindow(myURL) 
{        
	testwindow = window.open(myURL,'popup','height=600,width=800,status=0,menubar=0,scrollbars=0,toolbar=0,resizable=0,directories=0');
	testwindow.moveTo(100,100);
}

function openFlashTravel()
{
	var poz_x = (window.screen.width/2) - 240;
	var poz_y = (window.screen.height/2) + 90;	
	
	window.open('/static_media/flash/_travel/loader - Travel.html','Window1',
		'menubar=no,top=' + poz_y + ', left=' + poz_x +'screenX=' + poz_x + ',screenY=' + poz_y + ',width=480,height=272,toolbar=no');
}

$(document).ready(function(){
	
	// Main Menu
//	$(".toggle_country").click(function () {
//	      $("#country_choose").toggle("slow");
//    });

	// News section

	$("ul#listticker").css({'height': '24px'});
	$(".news").css({"background-image":"url(/static_media/css_lib/images/news/news_bar.gif)", "padding": "0", "border":"none"});
	var first = 0;
	var speed = 1000;
	var pause = 3000;
	
		function removeFirst(){
			first = $('ul#listticker li:first').html();
			$('ul#listticker li:first').remove();
			addLast(first);
		}
		
		function addLast(first){
			last = '<li>'+first+'</li>';
			$('ul#listticker').append(last);
		}
	
	interval = setInterval(removeFirst, pause);

	$(".populate").populate({
		color: "#999"
	});
	
	if(!$.browser.msie)
	{
		$("#sync_homepage").css({"margin-top":"10px"});
	}
	
	// Product details section
	
	$(".content_tab_name").hide();
	$(".tabs_contents>div.tab_content:not(:first)").hide();
	
	
	$("#prod_details_tabs>div:last").removeClass("tab_name");
	$("#prod_details_tabs>div:last").addClass("tab_name_active");
	$("#prod_details_tabs>div h3 a").click(function() {
 	
 		$("#prod_details_tabs>div").removeClass("tab_name_active");
 		$("#prod_details_tabs>div").addClass("tab_name");
	 	$(this).parent().parent().removeClass("tab_name");
	 	$(this).parent().parent().addClass("tab_name_active");
		
		id_name = $(this).parent().parent().attr("id").replace('tab','');
		
		$(".tabs_contents>div").hide();
		
		$(".tabs_contents>div#tab_content" + id_name).show();
		return false;
	});
	
	for(i=0; i<4;i++)
	{
		$("#tab_content" + i + ">div.tab_content_content:not(:first)").hide();
		$("#tab_content" + i + ">div.tab_content_content:not(:first)").hide();
		$("#tab_content" + i + ">h5 a:not(:first)").removeClass("collapse");
		$("#tab_content" + i + ">h5 a:not(:first)").addClass("expand");			
	}
	
	$('.tab_content>h5 a').click(function() {
 	
	 	if($(this).hasClass("collapse"))
	 	{
	 		$(this).removeClass("collapse");
	 		$(this).addClass("expand");
	 		
	 	}
	 	else
	 	{
	 		$(this).removeClass("expand");
	 		$(this).addClass("collapse");
	 	}
		
		$(this).parent().next("div.tab_content_content").toggle();

		return false;
	});
	
	// Category product select section
	
	$(".subcat_select .product_categories").css({'border':'none'});
	$(".subcat_select div#product_active").removeClass("product_categories");
	$(".subcat_select div#product_active").addClass("product_active");
	
	$("#subcat_with_products>div:not(.prod_select_active)").hide();
	
	$(".subcat_select div h4 a").click(function() {
	 	
		$('.subcat_select>div').removeClass("product_active");
		$('.subcat_select>div').removeClass("product_categories");
		$(this).parent().parent().addClass("product_active");
		$('.subcat_select>div:not(.height_spacer,.product_active)').addClass("product_categories");
		$('.subcat_select>div:not(.height_spacer)').css({'border':'none'});
		
		var href = $(this).attr('href');
		
		$("#subcat_with_products>div").hide();
		$("#subcat_with_products>div" + href + "").show();
		return false;
	});
	
	// Sync product select section
	
	$("#sync_content>li h3 a:not(:first)").removeClass("collapse");
	$("#sync_content>li h3 a:not(:first)").addClass("expand");
	$("#sync_content>li>div:not(:first)").hide();
	
	$("#sync_content>li h3 a").click(function() {
		
		if($(this).hasClass("collapse"))
	 	{
	 		$(this).removeClass("collapse");
	 		$(this).addClass("expand");
	 		
	 	}
	 	else
	 	{
	 		$(this).removeClass("expand");
	 		$(this).addClass("collapse");
	 	}
		
		$(this).parent().next("div.sync_content_details").toggle();
		
		return false;
	});
	
	$(".img_extras_section").css({'height':'362px'});
	
	// Press and about section
	
	$("ul#press_subsections .press_main_subsesctions h3 a:not(#active_press_release, #active_about)").removeClass("collapse");
	$("ul#press_subsections .press_main_subsesctions h3 a:not(#active_press_release, #active_about)").addClass("expand");
	$("ul#press_subsections .press_main_subsesctions>ul:not(#active_press_submenu, #active_about_submenu)").hide();
	
	$("ul#press_subsections .press_main_subsesctions h3 a").click(function() {
			
			if($(this).hasClass("collapse"))
		 	{
		 		$(this).removeClass("collapse");
		 		$(this).addClass("expand");
		 		
		 	}
		 	else
		 	{
		 		$(this).removeClass("expand");
		 		$(this).addClass("collapse");
		 	}
			
			$(this).parent().next("ul").toggle();
			
			return false;
		});
	
	var globHeight = 17;
	$('a span.maincat_title').each(function(){
		var elmHeight = parseInt($(this).height());
		
		if(elmHeight >= globHeight)
		{
			globHeight = elmHeight;
		}
	});
	
	$('a span.maincat_title').height(globHeight);
	
	if(!$.browser.msie)
	{
		$(".right_content").css({"margin-top":"-10px"});
	}

});

(function($){
	$.fn.populate = function ( user_options ) {
		var defaults = {}, settings = $.extend({}, defaults, user_options);
		this.each(function(){
			var $this = $(this);
			var title = this.title;
			var color = $this.css('color');
			if ( $this.val() == '' || $this.val() == title ) {
				$this.val(title);
				if ( settings.color != '' ) {
					$this.css('color', settings.color);
				}
			}
			$this.blur(function(){
				if ( $this.val() == '' ) {
					$this.val(title);
					if ( settings.color != '' ) {
						$this.css('color', settings.color);
					}
				}
			});
			$this.focus(function(){
				if ( $this.val() == title ) {
					$this.val('');
					$this.css('color', color);
				}
			});
				
		});
		
		return this;
	};
})(jQuery);