function getInternetExplorerVersion() {
    var rv = -1; // Return value assumes failure.
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) != null)
            rv = parseFloat(RegExp.$1);
    }
    return rv;
}

$(document).ready(function() {
	if(!('v'=='\v') || getInternetExplorerVersion() >= 8.0) {//if not ie
		$("#menus > li.parent > ul").css("overflow", "hidden");
		$("#menus > li.parent > ul").css("margin-top", "12px");
	} else {
		$("#menus > li.parent > ul > li").css("display","inline-block");	
	}
	var widthArray = new Array();
	widthArray[0] = 263;
	widthArray[1] = 263;
	widthArray[2] = 170;
	widthArray[3] = 203;
	widthArray[4] = 180;
	widthArray[5] = 147;
	widthArray[6] = 103;
	
   $("#menus > li.parent").mouseenter(function(){
			$(this).addClass("top-li-me");
			Cufon.replace($('a:first', this), {color: '#123939'});
			if($("ul > li:last-child", this).width() == $("ul > li:first-child", this).width() && !('v'=='\v')) {
				return;
			}
			var max = 0;
			$("ul > li > a:only-child", this).each(function(index) {
				if(max < $(this).width()) max = $(this).width();
			});
			
			if('v'=='\v' && parseInt(jQuery.browser.version) != 8) max = widthArray[$("#menus > li.parent").index(this)];
			if(getInternetExplorerVersion() != 8) {
				$("ul > li > a:only-child", this).width(max);
				$("ul:only-child", this).width(max);
			}
			
			
   });

   $("#menus > li.parent").mouseleave(function(){
		$(this).removeClass("top-li-me");
		Cufon.replace($('a:first', this), {  color: '#fff'});
   });
   
    $("#menus > li.parent > ul > li").mouseenter(function(){
		$(this).addClass("top-li-child-active");
   });
   
   $("#menus > li.parent > ul > li").mouseleave(function(){
		$(this).removeClass("top-li-child-active");
   });
   
	$("#menus > li.parent").hover(
		function() { $("ul", this).css("display", "block"); $("ul", this).css("left", "auto"); },
		function() { $("ul", this).css("display", "none"); $("ul", this).css("left", "0"); });

});

function deleteAllCookies() {
	var mydate = new Date();
	mydate.setTime(mydate.getTime() - 1);
	
	var cookies = document.cookie.split(";");

    for (var i = 0; i < cookies.length; i++) {
        var cookie = cookies[i];
        var eqPos = cookie.indexOf("=");
        var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
        document.cookie = name + "=;expires=" + mydate.toGMTString() +";path=/";
    }
}


$(document).ready(function() 
{
		var cntrlPressed = false;
		$(document.body).keydown(function(event) {
			//alert(event.keyCode);
			if(event.keyCode == 17 || event.keyCode == 16) {
				cntrlPressed = true;
			}
		});
		$(document.body).keyup(function(event) {
			if(event.keyCode == 17 || event.keyCode == 16) {
				cntrlPressed = false;
			}
		});
		//$( document.body ).fadeIn("slow", 0.0);
		//$( document.body ).fadeIn("slow", 0.1);
                $('a').not('a[href*="#"]').not('a[target="_blank"]').not('a[target="_new"]').click(function() {
			if(!cntrlPressed) $(document.body).fadeOut();
			//setTimeout("nav('"+this.href+"')",100);
               //return false;
       });
    });
function nav(href){
  location.href=href;
};

$(document).ready(function() {    
  
    $('a[name=modal]').click(function(e) {  
        e.preventDefault();  

        var id = $(this).attr('href');   
        var winH = $(window).height();  
        var winW = $(window).width() ;  

        $("div[name=" + id +"]").css('top',  (winH/2-$("div[name=" + id +"]").height()/2) + $(window).scrollTop());  
        $("div[name=" + id +"]").css('left', winW/2-$("div[name=" + id +"]").width()/2);  
        $("div[name=" + id +"]").fadeIn(700);   
    });  
      
    //if close button is clicked  
    $('.window .close').click(function (e) {  
        //Cancel the link behavior  
        e.preventDefault();  
        $('.window').hide();  
    });       
});


