function mainmenu(){
$(" #nav ul ").css({display: "none"}); // Opera Fix
$(" #nav li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}

function picture(){
$(" #nav ul li ul li div").css({display: "none"}); // Opera Fix
$(" #nav li li li").hover(function(){
		$(this).find('div').css({'display' : 'block'});
		},function(){
		$(this).find('div').css({'display' : 'none'});
		});
}

function clickmenu(){
$(" #nav ul ").css({display: "none"}); // Opera Fix
$(" #nav li").click(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(400);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}

function clickpicture(){
$(" #nav ul li ul li div").css({display: "none"}); // Opera Fix
$(" #nav li li li").click(function(){
		$(this).find('div').css({'display' : 'block'});
		},function(){
		$(this).find('div').css({'display' : 'none'});
		});
}

function bannerchanger(){
$(" #bannerchanger div.outerbanner").css({display: "none"}); // Opera Fix
$(" #bannerchanger div.show").css({display: "block"}); // Opera Fix

var delay = $(" #bannerchanger").attr('delay')*1000;
setInterval('rotate()',delay);

}

function rotate() {	
	//Get the first image
	var current = ($('#bannerchanger div.show')?  $('#bannerchanger div.show') : $('#bannerchanger div.outerbanner:first'));

	if ($('#bannerchanger div.outerbanner:first').next().length) {
    if ( current.length == 0 ) current = $('#bannerchanger div.outerbanner:first');

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('#bannerchanger div.show:first') :current.next()) : $('#bannerchanger div.outerbanner:first'));

	//Show next image
	next.css({'display' : 'block'}).addClass('show');
	//Hide the current image
	current.css({'display' : 'none'}).removeClass('show');
	}
};

function highlights(){
$(" #highlights img").attr('alt','');
$(" #highlights img").attr('title','');
$(" #highlights div.hlpopupbox").css({display: "none"}); // Opera Fix
$(" #highlights div div.buttonstyle").click(function(){
		$(" #highlights div.hlpopupbox").css({display: "none"}); 
		$(this).parent().find('div.hlpopupbox').css({'display' : 'block'});
		});
$(" #highlights div.hlpopupbox").click(function(){
		$(this).css({display: "none"}); 
		});
}

function searchfield(){
$(" #searchfield").focus(function(){
		$(this).attr('value','');
		$(this).css({'text-align':'left'});
	});
}
function prodpicchanger(){
$("div.popupContact").css({'display':'none'});
$(" #prodpic img").click(function(){
	var newpopid = "#newpop" + $(this).parent().attr('id');
	
	$("div.popupContact").css({'display':'none'});
	var pos = $(""+newpopid+" img ").position();
	if($(""+newpopid+" img ").parent().attr('class') == 'featureimage'){
		$(this).parent().find("div.popupContact").css({'display':'block','left':pos.left,'top':pos.top});
	}else{
		$(this).parent().find("div.popupContact").css({'display':'block','left':pos.left-5,'top':pos.top-1});
	}
});
}
function prodpiccloser(){
$(" #prodpic div.popupContact img").click(function(){
	$(this).parent().css({'display':'none'});
});
}

function countryselect(){
    $("#country").change(function(){
        var myvalue = $(this).val();
         window.location.href='http://'+myvalue+'/';
    });
}
function setselectedcountry(){
    var value = window.location.hostname;
    $("#country").val(value).attr("selected","selected");
}
$(document).ready(function(){					
	mainmenu();
	picture();
//	clickmenu();
//	clickpicture();
	highlights();
	searchfield();
	bannerchanger();
	prodpicchanger();
	prodpiccloser();
    countryselect();
    setselectedcountry();
});

