/* JS For WorldTour */

//
$(document).ready(function () {
	//
    //
	$('.menu_item').mouseover(function() {
		//
		if ($(this).hasClass('menu_item_has_children')) {
			//
			//$(this).addClass('menu_item_has_children_hover');
			//
			$('.submenu_item').hide('slow');
			//
			$(this).addClass('menu_item_hover');
			//
			curID = $(this).attr('id');
			//
			curMID = $(this).attr('lang');
			//
			curPos = getPosition(curID);
			//
			//curWidth = $(this).css('width');
			//
			//curWidth = curWidth.substr(0, (curWidth.length-2));
			//
			//curWidth = curWidth - 8;
			//
			$('#' + curMID).css('top', curPos.y + 46);
			$('#' + curMID).css('left', curPos.x);
			$('#' + curMID).css('width', 153);
			//$('#' + curMID).css('display', 'block');
			$('#' + curMID).show('slow');
			//
		} else {
			//
			$(this).addClass('menu_item_hover');
			//
		}
		//
	});
	//
	//
	$('.menu_item').mouseout(function() {
		//
		if ($(this).hasClass('menu_item_has_children')) {
			//
			//$(this).removeClass('menu_item_has_children_hover');
			$(this).removeClass('menu_item_hover');
			//
			curMID = $(this).attr('lang');
			//
			eval ("clearTimeout(sm." + curMID + ");");
			//eval ("sm." + curMID + " = setTimeout(function() { $('#" + curMID + "').css('display', 'none'); }, 2000);");
			eval ("sm." + curMID + " = setTimeout(function() { $('#" + curMID + "').hide('slow'); }, 2000);");
			//
		} else {
			//
			$(this).removeClass('menu_item_hover');
			//
		}
		//
	});
	//
	//
	$('.submenu_item').mouseover(function() {
		//
		curSSID = $(this).attr('id');
		eval ("clearTimeout(sm." + curSSID + ");");
		//
	});
	//
	//
	$('.submenu_item').mouseout(function() {
		//
		curSSID = $(this).attr('id');
		eval ("clearTimeout(sm." + curSSID + ");");
		//eval ("sm." + curSSID + " = setTimeout(function() { $('#" + curSSID + "').css('display', 'none'); }, 2000);");
		eval ("sm." + curSSID + " = setTimeout(function() { $('#" + curSSID + "').hide('slow'); }, 2000);");
		//
	});
	//
	//
	langePosition = getPosition('lang_panel');
	//
	$('#lang_panel').css('position', 'absolute');
	$('#lang_panel').css('top', (langePosition.y - 6) + 'px');
	$('#lang_panel').css('left', (langePosition.x + 3) + 'px');
	//
	//
	//
	//
	var so = new SWFObject('imgs/logo.swf', 'LogoFlash', '377', '145', '8', '');
	so.addParam('quality', 'high');
	so.write('flash_logo_container');
	//
	var so = new SWFObject('imgs/' + headerFlash, 'HeaderFlash', '866', '145', '8', '');
	so.addParam('quality', 'high');
	so.write('flash_header_container');
	//
	//
});
//

sm = {
	
};

// Getting Position
function getPosition(el){
	e = document.getElementById(el);
    var y = 0, x = 0;
    do {
      y += e.offsetTop  || 0;
      x += e.offsetLeft || 0;
      e = e.offsetParent;
      if (e) {
        if(e.tagName.toLowerCase() == 'body') break;
        var p = $(e).position();
        if (p == 'relative' || p == 'absolute') break;
      }
    } while (e);
    return {x:x, y:y};
}
//

//
function gotoPage(urle) {
	//
	if (urle) {
		//
		try {
			//
			document.location.href(urle);
			//
		} catch(e) {
			//
			document.location = urle;
			//
		}
		//
	}
	//
}
//

function clearSearch(obj, val) {

	if (obj.value == val) {
		
		obj.value = '';
		
	}

}
