function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  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;
}

var myIEversion =  getInternetExplorerVersion();

if (myIEversion==6|myIEversion==5){
	//LEFT, TOP, WIDTH, HEIGHT
	new ypSlideOutMenu('menu1', 'down', 27, 116, 202, 136);
	new ypSlideOutMenu('menu2', 'down', 97, 116, 202, 136);
	new ypSlideOutMenu('menu3', 'down', 169, 116, 202, 192);
	new ypSlideOutMenu('menu4', 'down', 235, 116, 202, 109);
	new ypSlideOutMenu('menu5', 'down', 313, 116, 202, 109);
	new ypSlideOutMenu('menu6', 'down', 414, 116, 202, 55);
	new ypSlideOutMenu('menu7', 'down', 482, 116, 202, 163);
} else {
	//LEFT, TOP, WIDTH, HEIGHT
	new ypSlideOutMenu('menu1', 'down', 27, 116, 202, 126);
	new ypSlideOutMenu('menu2', 'down', 97, 116, 202, 126);
	new ypSlideOutMenu('menu3', 'down', 169, 116, 202, 176);
	new ypSlideOutMenu('menu4', 'down', 235, 116, 202, 101);
	new ypSlideOutMenu('menu5', 'down', 313, 116, 202, 101);
	new ypSlideOutMenu('menu6', 'down', 414, 116, 202, 52);
	new ypSlideOutMenu('menu7', 'down', 482, 116, 202, 151);
};

ypSlideOutMenu.writeCSS();

$().ready(function() {

	$.ifixpng('/images/pixel.gif'); 
	$('#menubox, .mainpage_halfbox_right_scrollable, .mainpage_halfbox_left, #searchfieldbg, #tab_register_img, #tab_language_img, #register .inputdiv').ifixpng();
	
	// JQUERY IMAGE PRELOADER
	jQuery.preloadImages = function()
	{
	  for(var i = 0; i<arguments.length; i++)
	  {
		jQuery("<img>").attr("src", arguments[i]);
	  }
	}
	//$.preloadImages("/site_assets/images/mainmenu/careers_on.gif","/site_assets/images/mainmenu/company_on.gif","/site_assets/images/mainmenu/customers_on.gif","/site_assets/images/mainmenu/investors_on.gif","/site_assets/images/mainmenu/news_on.gif","/site_assets/images/mainmenu/partners_on.gif","/site_assets/images/mainmenu/products_on.gif","/site_assets/images/mainmenu/solutions_on.gif","/site_assets/images/mainmenu/support_on.gif");
	$.preloadImages("/site_assets/images/mainmenu_05-06-2011/company_on.gif","/site_assets/images/mainmenu_05-06-2011/solutions_on.gif","/site_assets/images/mainmenu_05-06-2011/products_on.gif","/site_assets/images/mainmenu_05-06-2011/news_on.gif","/site_assets/images/mainmenu_05-06-2011/partners_on.gif","/site_assets/images/mainmenu_05-06-2011/investors_on.gif","/site_assets/images/mainmenu_05-06-2011/support_on.gif","/site_assets/images/mainmenu_05-06-2011/youtube_on.gif","/site_assets/images/mainmenu_05-06-2011/twitter_on.gif","/site_assets/images/mainmenu_05-06-2011/facebook_on.gif","/site_assets/images/mainmenu_05-06-2011/blogbutton_on.gif","/site_assets/images/mainmenu_05-06-2011/rssbutton_on.gif");
	// END JQUERY IMAGE PRELOADER
		
	$('#mainflash').flash({  
		swf: '/site_assets/flash/main/main.flash.swf',
		height: 256,
		width: 960,
		params: {play:true, loop:true, menu:false, quality:"best", wmode:"transparent", bgcolor: "#CED7CE", seamlesstabbing:"true", swliveconnect:"false", allowfullscreen:"false", allowscriptaccess:"sameDomain"}
	});
	
	$('#mainflash').css("visibility","visible");   
	
	$(document).bind('click', function(e) {
		var $clicked=$(e.target); // get the element clicked
		if($clicked.is('#button_register') || $clicked.parents().is('#tab_register_droppanel') || $clicked.parents().is('#tab_language_droppanel')) { 
		// if the element clicked is the one we're looking for or if the element has a parent that we're looking for then we clicked the right place !
        	null;
                } else { // we're outside the error paragraph, no matter where but we're outside !
					if ($('#tab_register_droppanel').is(':visible')){
						$('#tab_register_img').attr("src","/site_assets/images/tab.register.png");
						$('#tab_register_img').ifixpng();
						$('#tab_register_droppanel').slideUp('slow');
					}
					if ($('#tab_language_droppanel').is(':visible')){
						$('#tab_language_img').attr("src","/site_assets/images/tab.language.png");
						$('#tab_language_img').ifixpng();
						$('#tab_language_droppanel').slideUp('slow');
						return false;
					}
				}
	});
	
	$('#closeregpanel').click(function(){
		if ($('#tab_register_droppanel').is(':visible')){
			$('#tab_register_droppanel').slideUp('slow');
		}
	});

	$('#tab_register').click(function(){
		if ($('#tab_register_droppanel').is(':hidden')){
			$('#tab_language_img').attr("src","/site_assets/images/tab.language.png");
			$('#tab_language_img').ifixpng();
			$('#tab_language_droppanel').slideUp('slow');
			$('#tab_register_droppanel').slideDown(350);
			$('#tab_register_img').attr("src","/site_assets/images/tab.hide.png");
			$('#tab_register_img').ifixpng();
			return false;
		}
		else{
			$('#tab_register_droppanel').slideUp('slow');
			$('#tab_register_img').attr("src","/site_assets/images/tab.register.png");
			$('#tab_register_img').ifixpng();
		}
	});
	
	$('#tab_language').click(function(){
		if ($('#tab_language_droppanel').is(':hidden')){
			$('#tab_register_img').attr("src","/site_assets/images/tab.register.png");
			$('#tab_register_img').ifixpng();
			$('#tab_register_droppanel').slideUp('slow');
			$('#tab_language_droppanel').slideDown(350);
			$('#tab_language_img').attr("src","/site_assets/images/tab.hide.png");
			$('#tab_language_img').ifixpng();
			return false;
		}
		else{
			$('#tab_language_droppanel').slideUp('slow');
			$('#tab_language_img').attr("src","/site_assets/images/tab.language.png");
			$('#tab_language_img').ifixpng();
		}
	});
	
	$(".menutext").hover(
		function(){
			$(this).children('a').css('color','black');
			var myURL = $(this).children('a').get(0).href;
			window.status = myURL;
		},
		function(){
			$(this).children('a').css('color','white');
		}
	);
	
	$(".topmenuitem").hover(
		function(){
			var menuImg = $(this).children('img').get();
			 $(menuImg).get(0).src = $(menuImg).get(0).src.replace("_off","_on");
	 	},
		function(){
			var menuImg = $(this).children('img').get();
			 $(menuImg).get(0).src = $(menuImg).get(0).src.replace("_on","_off");
	 	}
	);

	$("#mainmenu_company img").hover(
 		function()
		 {
		  ypSlideOutMenu.showMenu('menu1');
		 },
	    function()
		 {
		  ypSlideOutMenu.hideMenu('menu1');
		 }
	);
	
	$("#menu1Content").hover(
 		function()
		 {
			$("#mainmenu_company img").attr("src",$("#mainmenu_company img").attr("src").replace("_off","_on"));
		 },
	    function()
		 {
			$("#mainmenu_company img").attr("src",$("#mainmenu_company img").attr("src").replace("_on","_off"));
		 }
	);
	
	$("#mainmenu_solutions img").hover(
 		function()
		 {
		  ypSlideOutMenu.showMenu('menu2');
		 },
	    function()
		 {
		  ypSlideOutMenu.hideMenu('menu2');
		 }
	);
	
	$("#menu2Content").hover(
 		function()
		 {
			$("#mainmenu_solutions img").attr("src",$("#mainmenu_solutions img").attr("src").replace("_off","_on"));
		 },
	    function()
		 {
			$("#mainmenu_solutions img").attr("src",$("#mainmenu_solutions img").attr("src").replace("_on","_off"));
		 }
	);
	
	$("#mainmenu_products img").hover(
 		function()
		 {
		  ypSlideOutMenu.showMenu('menu3');
		 },
	    function()
		 {
		  ypSlideOutMenu.hideMenu('menu3');
		 }
	);
	
	$("#menu3Content").hover(
 		function()
		 {
			$("#mainmenu_products img").attr("src",$("#mainmenu_products img").attr("src").replace("_off","_on"));
		 },
	    function()
		 {
			$("#mainmenu_products img").attr("src",$("#mainmenu_products img").attr("src").replace("_on","_off"));
		 }
	);
	
	$("#mainmenu_customers img").hover(
 		function()
		 {
		  ypSlideOutMenu.showMenu('menu4');
		 },
	    function()
		 {
		  ypSlideOutMenu.hideMenu('menu4');
		 }
	);
	
	$("#menu4Content").hover(
 		function()
		 {
			$("#mainmenu_customers img").attr("src",$("#mainmenu_customers img").attr("src").replace("_off","_on"));
		 },
	    function()
		 {
			$("#mainmenu_customers img").attr("src",$("#mainmenu_customers img").attr("src").replace("_on","_off"));
		 }
	);

	$("#mainmenu_news img").hover(
 		function()
		 {
		  ypSlideOutMenu.showMenu('menu5');
		 },
	    function()
		 {
		  ypSlideOutMenu.hideMenu('menu5');
		 }
	);
	
	$("#menu5Content").hover(
 		function()
		 {
			$("#mainmenu_news img").attr("src",$("#mainmenu_news img").attr("src").replace("_off","_on"));
		 },
	    function()
		 {
			$("#mainmenu_news img").attr("src",$("#mainmenu_news img").attr("src").replace("_on","_off"));
		 }
	);
	
//	$("#mainmenu_partners img").hover(
// 		function()
//		 {
//		  ypSlideOutMenu.hideAll();
//		 },
//	    function()
//		 {
//		 }
//	);
	
//	$("#mainmenu_careers img").hover(
// 		function()
//		 {
//		  ypSlideOutMenu.hideAll();
//		 },
//	    function()
//		 {
//		 }
//	);
	
	$("#mainmenu_partners img").hover(
 		function()
		 {
		  ypSlideOutMenu.showMenu('menu6');
		 },
	    function()
		 {
		  ypSlideOutMenu.hideMenu('menu6');
		 }
	);
	
	$("#menu6Content").hover(
 		function()
		 {
			$("#mainmenu_partners img").attr("src",$("#mainmenu_partners img").attr("src").replace("_off","_on"));
		 },
	    function()
		 {
			$("#mainmenu_partners img").attr("src",$("#mainmenu_partners img").attr("src").replace("_on","_off"));
		 }
	);
	
	$("#mainmenu_investors img").hover(
 		function()
		 {
		  ypSlideOutMenu.showMenu('menu7');
		 },
	    function()
		 {
		  ypSlideOutMenu.hideMenu('menu7');
		 }
	);
	
	$("#menu7Content").hover(
 		function()
		 {
			$("#mainmenu_investors img").attr("src",$("#mainmenu_investors img").attr("src").replace("_off","_on"));
		 },
	    function()
		 {
			$("#mainmenu_investors img").attr("src",$("#mainmenu_investors img").attr("src").replace("_on","_off"));
		 }
	);	
	
	$("#mainmenu_support img").hover(
 		function()
		 {
		  ypSlideOutMenu.hideAll();
		 },
	    function()
		 {
		 }
	);
	
	$("#first_name").watermark("First Name");
	$("#last_name").watermark("Last Name");
	$("#email").watermark("Email Address");
	$("#searchfield").watermark("Search...");
	
	$('.boxMenu ul').kwicks({max: 468, duration: 300, easing: 'easeOutQuad'});
	
	$(document).konami(function(){
		//alert('Konami Code Activated');
		//Adjust height of overlay to fill screen when page loads
	   $("#fuzzy").css("height", $(document).height());
	
	   //When the link that triggers the message is clicked fade in overlay/msgbox
	  // $(".alert").click(function(){
		  $("#fuzzy").fadeIn();
		  return false;
	   //});
	});
	
   //When the message box is closed, fade out
   $(".eggclose").click(function(){
	  $("#fuzzy").fadeOut();
	  return false;
   });
   
   $("div.scrollable").scrollable({ 
	vertical:true,  
	size: 3 
         
    // use mousewheel plugin 
    }).mousewheel();
   
   //POPUP WINDOW PLUGIN and PROFILES
   var profiles =
	{
		window800:
		{
			height:800,
			width:800,
			status:1
		},
	
		window200:
		{
			height:200,
			width:200,
			status:1,
			resizable:0
		},
	
		windowCenter:
		{
			height:300,
			width:400,
			center:1
		},
		
		windowNotNew:
		{
			height:300,
			width:400,
			center:1,
			createnew:0
		}
	};
	
	$("#verticalticker").totemticker({
		row_height	:	'55px',
		interval    :   5000,
		mousestop	:	true
	});
	
	
	$(function()
	{
		$(".popupwindow").popupwindow(profiles);
	});
	
	$(".languagewrapper").click(
	function()
	{
		window.location = $(this).attr("title");
		return false;
	});

	
});
