$(function() {

	var $currentsection ='';

	//hidden in css to avoid IE7 flicker
	//$("#main-nav ul ul").hide();
   
   //set in css to avoid IE7 flicker
	//$("#main-nav .sub-nav").css("position","absolute");
	$("#main-nav ul ul.selected").show();
   
   $("#username input").focus(function(){
		if ($(this).attr("value") == "Username"){
			$(this).attr("value","");
		}
   });

   $("#password input").focus(function(){
		if ($(this).attr("value") == "Password"){
			$(this).attr("value","");
		}
   }).keypress(function (e) {
      if (e.which == 13) {
        $("#mainlogin").submit('login');
      } 
    });
	

		$currentsection = $("#section-selected");
		//console.log($currentsection);
	
	
	/*
	nav-company
	nav-mounting-solutions
	nav-news
	nav-events
	
	nav-distributors
	nav-unirac-innovation
	nav-contact-us
	*/
	
	
	//if (!$("ul:first",this).hasClass("selected")){
	//$("#section-selected").
	
	if ( $("#nav-company").parent("li").text() == $($currentsection).text()){
	
		 $("#nav-company").parent("li").hover(function(){
		 	$("a",this).addClass("hover");
			$("ul:first",$currentsection).show();
		 },function(){
			$(this).removeClass("hover");
		 });
		 
	}else{
		$("#nav-company").parent("li").hover(function(){
		 	$("a",this).addClass("hover");
			//$("ul:first",this).show();
			
			$("ul:first",this).css("display","inline");
			$("ul:first",this).css("float","left");
			$("ul:first li",this).css("float","left");
			$("ul:first",$currentsection).hide();
		 },function(){
		 	$("a",this).removeClass("hover");
			$("ul:first",this).hide();
			$("ul:first",$currentsection).show();
		 });
	}
	
	
	if ( $("#nav-mounting-solutions").parent("li").text() == $($currentsection).text()){
	
		 $("#nav-mounting-solutions").parent("li").hover(function(){
		 	$("a",this).addClass("hover");
			$("ul:first",$currentsection).show();
		 },function(){
			$(this).removeClass("hover");
		 });
		 
	}else{
		$("#nav-mounting-solutions").parent("li").hover(function(){
		 	$("a",this).addClass("hover");
			$("ul:first",this).show();
			$("ul:first",$currentsection).hide();
		 },function(){
		 	$("a",this).removeClass("hover");
			$("ul:first",this).hide();
			$("ul:first",$currentsection).show();
		 });
	}
	
	if ( $("#nav-news").parent("li").text() == $($currentsection).text()){
	
		 $("#nav-news").parent("li").hover(function(){
		 	$("a",this).addClass("hover");
			$("ul:first",$currentsection).show();
		 },function(){
			$(this).removeClass("hover");
		 });
		 
	}else{
		$("#nav-news").parent("li").hover(function(){
		 	$("a",this).addClass("hover");
			$("ul:first",this).show();
			$("ul:first",$currentsection).hide();
		 },function(){
		 	$("a",this).removeClass("hover");
			$("ul:first",this).hide();
			$("ul:first",$currentsection).show();
		 });
	}
	
	if ( $("#nav-events").parent("li").text() == $($currentsection).text()){
	
		 $("#nav-events").parent("li").hover(function(){
		 	$("a",this).addClass("hover");
			$("ul:first",$currentsection).show();
		 },function(){
			$(this).removeClass("hover");
		 });
		 
	}else{
		$("#nav-events").parent("li").hover(function(){
		 	$("a",this).addClass("hover");
			$("ul:first",this).show();
			$("ul:first",$currentsection).hide();
		 },function(){
		 	$("a",this).removeClass("hover");
			$("ul:first",this).hide();
			$("ul:first",$currentsection).show();
		 });
	}
	
	
	if ( $("#nav-distributors").parent("li").text() == $($currentsection).text()){
	
		 $("#nav-distributors").parent("li").hover(function(){
		 	$("a",this).addClass("hover");
			$("ul:first",$currentsection).show();
		 },function(){
			$(this).removeClass("hover");
		 });
		 
	}else{
		$("#nav-distributors").parent("li").hover(function(){
		 	$("a",this).addClass("hover");
			$("ul:first",this).show();
			$("ul:first",$currentsection).hide();
		 },function(){
		 	$("a",this).removeClass("hover");
			$("ul:first",this).hide();
			$("ul:first",$currentsection).show();
		 });
	}
	
	if ( $("#nav-unirac-innovation").parent("li").text() == $($currentsection).text()){
	
		 $("#nav-unirac-innovation").parent("li").hover(function(){
		 	$("a",this).addClass("hover");
			$("ul:first",$currentsection).show();
		 },function(){
			$(this).removeClass("hover");
		 });
		 
	}else{
		$("#nav-unirac-innovation").parent("li").hover(function(){
		 	$("a",this).addClass("hover");
			$("ul:first",this).show();
			$("ul:first",$currentsection).hide();
		 },function(){
		 	$("a",this).removeClass("hover");
			$("ul:first",this).hide();
			$("ul:first",$currentsection).show();
		 });
	}
	
	if ( $("#nav-contact-us").parent("li").text() == $($currentsection).text()){
	
		 $("#nav-contact-us").parent("li").hover(function(){
		 	$("a",this).addClass("hover");
			$("ul:first",$currentsection).show();
		 },function(){
			$(this).removeClass("hover");
		 });
		 
	}else{
		$("#nav-contact-us").parent("li").hover(function(){
		 	$("a",this).addClass("hover");
			$("ul:first",this).show();
			$("ul:first",$currentsection).hide();
		 },function(){
		 	$("a",this).removeClass("hover");
			$("ul:first",this).hide();
			$("ul:first",$currentsection).show();
		 });
	}
	
	
	
	
 
 /*  $("a:first","#main-nav ul li:not(ul ul li)").hover(function(){
   		if (!$(this).hasClass("selected")){
			//$($currentsection).hide();
			$("#logo-panel").append("<span style='color:#fff;font-size:10px;'>selected</span>");
		}
   });
	$("a:first","#main-nav ul li:not(ul ul li)").unbind('hover');*/
 });