/**
 *  Zajisteni sledovani pozice mysi
 */
var mouseX = 0;
var mouseY = 0;
//var messages = [{}];
var messages = new Array();

$().mousemove( function(e) {
	mouseX = e.pageX;
	mouseY = e.pageY;
});
/**
 *  ==========
 */


/**
 *  Funkce pro zobrazovani tooltipu
 */
var tooltip_element = false;

function show_tooltip(tooltip_text)
{
	show_tooltip_div(tooltip_text);
}

function hidde_tooltip()
{
	hidde_tooltip_div();
}

function show_tooltip_div(tooltip_text)
{
	var top_position 	= mouseY - 170;
	var left_position 	= mouseX + 10;

	if ( tooltip_element )
	{
		tooltip_element.style.top  = top_position+'px';
		tooltip_element.style.left	= left_position+'px'
	}
	else
	{
		paramsDiv      		= new Array();
		paramsDiv[0]      	= new Array();
		paramsDiv[0][0]   	= 'id';
		paramsDiv[0][1]   	= 'tooltip_id';

		tooltip_element   	= createNewElement( 'div',   paramsDiv, document.body, true );

		if ( tooltip_element )
		{
			tooltip_element.innerHTML	= tooltip_text;
			tooltip_element.style.top  = top_position+'px';
			tooltip_element.style.left	= left_position+'px';
		}
	}

}

function hidde_tooltip_div()
{
	if ( tooltip_element ){
		remove_element(tooltip_element);
		tooltip_element = false;
	}
}
/**
 *  ==========
 */

function lightbox_photo(image,name)
{
	if (image) {
		$('#ContentHolder').append('<a href="'+image+'" id="temp_href" style="visibiality:hidden" title="'+name+'"> </a>');

		$('#temp_href').lightBox();
		$('#temp_href').trigger('click');
	  $('#temp_href').remove();
	}
// 	alert(image);

}


/**
 * DOCUMENT READY
 */

$(document).ready(function()
{
	// SelectBoxy
		
	$("select.select01").sb();



	// MainMenu - rozbalovani submenu

	var menu_holder = $("#MainMenuHolder");
	var links = $("a.menu_item", menu_holder);

	links.mouseover(function()
	{
		var link = $(this);
		var submenu = link.next("div.MainMenuSubHolder");
		link.parent('li').css("z-index","20000");

		submenu.stop().show();
		submenu.unbind();

		submenu.mouseover(function()
		{
			$(this).stop().show();
			link.parent('li').addClass("dropped");
			link.parent('li').css("z-index","20000");
		});

		submenu.mouseout(function()
		{
			$(this).delay(200).hide();
			links.parent('li').removeClass("dropped");
			link.parent('li').css("z-index","1010");
		});
	});

	links.mouseout(function()
	{
		var link = $(this);
		var submenu = link.next("div.MainMenuSubHolder");
		link.parent('li').css("z-index","1010");

		submenu.delay(200).hide();
	});



	//toolbox v hlaviččce
	$('#ToolsBox a').mouseover(function(){
		var klasa = $(this).attr('class');
		$('.ToolInfo').hide();
		$(this).next('div').show();
	});
	$('#ToolsBox a').mouseout(function(){
		$('.ToolInfo').hide();
	});
		
	// leve menu na HP - stridani Nas obchod a Nasi lide
	$('#HPBoxPortfolioBoxHeader a').click(function(){
		var idecko = $(this).attr('id');
		$('#HPBoxPortfolioBoxHeader a').removeClass('selected');
		$(this).addClass('selected');
		// 		  alert (idecko);
		$('#HPBoxPortfolio .ToHide').hide();
		$('#HPBoxPortfolio #HPBox'+idecko+'Holder').show();
		$('#HPBoxFlashHolder .ToHide').hide();
		$('#HPBoxFlashHolder #HPBoxFlash'+idecko).show();

	$.ajax({
		global: false,
		cache: false,
		type: "GET",
		url: WEB_URL+'ajax.php',
		data:'modul=set_session_for_hp&idecko='+idecko,
		dataType: "json",
		success: function(msg) {
		}
	});


		return false;
	});


	//lightbox
	$(function() {
		$('.lightboxclass').lightBox();
	});

	//schovani prvku kdyz jede JS
	$(".inputDis").hide();

	//Zobrazeni prvku, kdyz jede JS
	$(".showIfJSon").show();

	//odkaz na tisk do PDF
	$(".out").click(function(){
		window.open($(this).attr("href"),'blank');
		return false;
	});

	/*
    //Rozcestnik - vyrazne se zjednodusili, toto neni ted potreba
    $(".RozcestnikHover").show();
    $(".RozcestnikHover").mouseenter(
                function(){
                    $("#Rozcestnik a").attr('class','');
                    $(".RozcestnikHover").show();
                    $("#aID_"+$(this).attr('id')).attr('class','hover');
                    $(this).hide();
                }
            );
    $("#Rozcestnik a").mouseleave(function(){$("#Rozcestnik a").attr('class','');$(".RozcestnikHover").show();});
    //$("#Rozcestnik a").mouseout(function(){$(".RozcestnikHover").show();});
	*/

	//nastylovani tabulek

	$('.table01').each(
		function()
		{
			$(this).attr("cellspacing","0");
			$(this).attr("cellpadding","0");
			$(this).attr("border","0");
			$(this).find('tr:first').addClass('first');
			$(this).find('tr:odd').addClass('odd');
			$(this).find('tr:even').addClass('even');
			$(this).find('tr:last').addClass('last');
/*			var tdcka = $('.first td',$(this));
			var trko = $('.last',$(this));
			var tdko = $('td',trko);
			if (tdko.length == 0) {
				trko.append('<td colspan="'+tdcka.length+'" class="noborder"></td>');
			}                                */

		}

		);

	$('.table02').each(
		function()
		{
			$(this).attr("cellspacing","0");
			$(this).attr("cellpadding","0");
			$(this).attr("border","0");
			$(this).find('tr:first').addClass('first');
			$(this).find('tr:odd').addClass('odd');
			$(this).find('tr:even').addClass('even');
			$(this).find('tr:last').addClass('last');
		}

		);

	$(".selectChange").change(
		function()
		{
     
			name  = $(this).attr('name');
			value = $(this).val();
			url = document.location.toString();

			if(gup(name)!="")
			{
				url = url.replace(name+"="+gup(name),name+"="+value);
			}
			else
			{
				sep =  (url.indexOf('?')>0) ? '&' : '?';
				url += sep+name+"="+value;
			}
			location.assign(url);
		}
		);

	$("#ContactGroup").change(
		function()
		{
            

			location.hash = $(this).val();

			location.assign(document.location);
		}
		);



	//HP
	if(document.getElementById('HPBoxInfo'))
	{
		checkPortfolioCompaniesBoxesHeight();

		$("#FlashActivationButton").click(function(){

			if((parseInt($("#HPBoxInfo").css('left'),10) == 0 && parseInt($("#HPBoxesHolder").css('top'),10)==332) || (parseInt($("#HPBoxInfo").css('left'),10) == -560 && parseInt($("#HPBoxesHolder").css('top'),10)==543))
			{
				$("#HPBoxInfo").toggleLeftHPBoxInfo(0);
			}

			if((parseInt($("#HPBoxInfo").css('left'),10) == -540))
			{
				$("#HPBoxInfo").css('left',-560);
			}

			$("#HPBoxesHolder").toggleDown();
			showHideFlashVirtualVisit();
		});

		$("#HPBoxInfoButton").click(function(){
			$("#HPBoxInfo").toggleLeftHPBoxInfo(20);
		});

		$("#HPBoxSuccessStoriesPane").jScrollPane({
			showArrows:true,
			scrollbarWidth: 10
		});
		$("#HPBoxNewsPane").jScrollPane({
			showArrows:true,
			scrollbarWidth: 10
		});
		$("#HPBoxPortfolioPane").jScrollPane({
			showArrows:true,
			scrollbarWidth: 10
		});

	}

    


	//Podstranka Typ B
	if(document.getElementById('TypeBtopBox'))
	{

		//Skryti obsahu a posleze zobrazeni flashe..
		$(".toggleContent").click(function(){
			$("#TypeBcontentBox").toggleDownLayoutTypeB();

		});

	}


	//Podstranka Typ C
	if(document.getElementById('TypeCtopBox'))
	{

		//Skryti obsahu a posleze zobrazeni flashe..
		$(".toggleContent").click(function(){
			$("#TypeCcontentBox").toggleDownLayoutTypeB();

		});

	}

	//Adresy v kontaktech
	prepareAddresses();

	//Infografiky...
 
	$(".infographic").each(function() {
        
		lang = $(this).attr('lang');

		tmp = $(this).attr('title').split(';');


		swf  = tmp[0];
		xml  = tmp[1];
		id   = tmp[2];
		width   = tmp[3];
		height   = tmp[4];


		if(swf!='' && xml!='')
		{
            
			var rand = Math.floor(Math.random()*11);

			var flashvars = {
				xmlPath: "flash/infographic/data/"+lang+"/"+xml+'?rnd='+rand
			};

			var flashparams = {
				quality: "high",
				bgcolor: "#ffffff",
				allowScriptAccess: "sameDomain",
				allowFullScreen: "false",
				allowNetworking: "all",
				scale: "noscale",
				salign: "t",
				wmode:'transparent'
			};

			var flashattributes = {
				id: 'FlashInfographic_'+id,
				name: 'FlashInfographic_'+id,
				'class': 'infographic'
			};
			swfobject.embedSWF("flash/infographic/"+swf, 'Infographic_'+id, width, height, "10.0.0", "", flashvars, flashparams, flashattributes);

		}
		

	});
    



	/*
	var SearchStringClicked = false;
	$("#SearchString").click(function(){
		if(!SearchStringClicked) {
			$("#SearchString").val('');
			SearchStringClicked=true;
		}
	});
	*/
   var SearchStringClicked = false;
   $("#SearchString").click(function(){if(!SearchStringClicked) {$("#SearchString").val('');SearchStringClicked=true;}});
   $("#SearchString").blur(function(){if($("#SearchString").val() == '' ) {$("#SearchString").val(get_message('Search'));SearchStringClicked=false;}});


    
$('.AddBookmark').click(function(){
	CreateBookmarkLink();
	return false;
});
$('.PrintPage').click(function(){
	window.print();
	return false;
});

$(".InformationAboutChanges").colorbox({
	href:WEB_URL+'ajax.php?modul=information_about_changes',
	width:'600px',
	height:'400px',
	onComplete:function(){
		validateFormInformationAboutChanges();
	}
});
$(".SendToFriend").colorbox({
	href:WEB_URL+'ajax.php?modul=send_to_friend',
	width:'600px',
	height:'500px',
	onComplete:function(){
		validateFormSendToFriend();
	}
});

$(".openVirtualVisit").colorbox({
	html:'<div style="width:888px;height:600px;"><div id="FlashVirtualVisit"></div></div>',
	innerWidth:'890px',
	innerHeight:'610px',
	onComplete:function(){
		prepareFlashVirtualVisit();
	}
});

loadMessagesFromXML();

validateFormInformationAboutChanges();
validateFormSendToFriend();
validateFormContactForm();


showFlashOurPeople();
showFlashOurBusiness();
setLinksToInvokeFlashOurPeople();
setLinksToInvokeFlashBusiness();


if(document.getElementById('FormInformationAboutChangesManagement'))
{
	var bool = true;
	$("#idSelectDeselectAll").click(function ()
	{
		$("#FormInformationAboutChangesManagement .chbox").attr('checked', bool);

		if(bool)
		{
			bool = false;
		}
		else
		{
			bool = true;
		}

		return false;
	});
}

		// MOBILNI VERZE

		$("#mobile_graf_right").click(function(){
			$("#mobile_graf_inner").animate({backgroundPosition: '-120px 0px'})
			$(this).hide();
			$("#mobile_graf_left").show();
		});
		$("#mobile_graf_left").click(function(){
			$("#mobile_graf_inner").animate({backgroundPosition: '0px 0px'})

			$(this).hide();
			$("#mobile_graf_right").show();
		});
		
		if ($("#lide_holder")) {
		  var pocet = $(".lide_selector").length;
    	$("#portrety_inner").width((pocet * 142));
    	
    	$(".lide_selector").click(function(){
				var idcko = $(this).attr('id');
				var idval = idcko.substring(3, idcko.length);

				$(".clovek_popis").hide();
				$("#popis"+idval).show();
				
				$(".lide_selector").removeClass('selected');
				$(this).addClass('selected');
			});

			$("#lide_right").click(function(){
				$('#portrety_inner').animate({
    			right: '282'
  				}, 500);

				$(this).hide();
				$("#lide_left").show();
			});
			$("#lide_left").click(function(){
				$('#portrety_inner').animate({
    			right: '0'
  				}, 500);

				$(this).hide();
				$("#lide_right").show();
			});

		}
		if ($('#mobile_historie')) {
		  $('.hist_holder').hide();
		  $('.hist_holder:first').show();
		
		  $('.hist_button').click(function(){
		    var idcko = $(this).attr('id');
		    var rok = idcko.substring(1, idcko.length);

			  $('.hist_holder').hide();
			  $('#h'+rok).show();
			  
			  var prev_rok = $('.hist_button.selected').html();
				prev_rok = prev_rok.substring(0,4);
			  $('.hist_button.selected').html(prev_rok);
			  $('.hist_button.selected').removeClass('selected');
			  
			  $(this).addClass('selected');
			  $(this).html(rok+' &raquo;');

			});



		}



    
});


// Zobrazi/skryje flash virtualni prohlidky

function showHideFlashVirtualVisit()
{
	if($("#FlashBackground").is(':hidden'))
	{
		$("#FlashBackground").show();
	}
	else
	{
		$("#FlashBackground").hide();
	}
}

//Pripravy nacteni flashe - prohlidky

function prepareFlashVirtualVisit()
{
	//return true;
  
	if(document.getElementById('FlashVirtualVisit'))
	{

		var flashvars = {
			lwImg:"",
			lwBgColor:"255,255,255,255",
			lwBarBgColor:"255,255,255,255",
			lwBarColor:"255,0,255,0",
			lwBarBounds:"198,434,594,8",
			lwlocation:"0",
			lwShowLoadingPercent:"true",
			lwTextColor:"255,0,0,0",
			iniFile:"config_ppf.bin",
			progressType:"0",
			swfFile:"",
			href:location.href
		};
      
		var flashparams = {
			quality: "high",
			bgcolor: "transparent",
			allowScriptAccess: "sameDomain",
			allowFullScreen: "true",
			wmode: "transparent",
			allowNetworking: "all",
			scale: "noscale"
		};
      
		var flashattributes = {
			id: 'FlashVirtualVisit',
			name: 'FlashVirtualVisit'
		};
		swfobject.embedSWF("flash/virtual_visit_"+LANG+"/twviewer.swf", 'FlashVirtualVisit', "888", "600", "9.0.0", "", flashvars, flashparams, flashattributes);
      
	}
  
}

/**
 * Projde stranku, najde adresy a doplni tag pro prime otevreni postovniho klienta - ochrana proti robotum
 */
function prepareAddresses()
{
	
	//vypnute
	return false;

	//Maska je address - domena 2.radu - jmeno - domena 1.radu

	$('.addressHolder').each(
		function()
		{
			
			//Naparsujem idcko
			parts = $(this).attr('id').split('-');

			address = parts[2] + '@' + parts[1] + '.' + parts[3];

			//$(this).replaceWith($('<a href="mailto:'+address+'">' + this.innerHTML + '</a>'));
			$(this).replaceWith($('<a href="mailto:'+address+'"><span>' + parts[2] + '</span><span class="sep">(at)</span><span>' + parts[1] + '.' + parts[3] + '</span></a>'));


		//alert(address);
		}
		);


}

//Nacteni jazykovych hlasek do pole

function loadMessagesFromXML()
{
	$.ajax({
		type: "GET",
		async:false,
		url: WEB_URL+"langs/"+LANG+".xml",
		dataType: "xml",
		success: function(xml) {
			$(xml).find("messages").each(function()
			{
				$(this).find("item").each(function()
				{
					messages[$(this).attr('key')] = $(this).text();
				});
			});

          
		}
	});
}

//Zobrazeni hlasky
function get_message(key)
{
    
	if(messages[key])
	{
		return messages[key];
	}
	else
	{
		return key;
	}
}



function validateFormInformationAboutChanges()
{


    

	if(document.getElementById('FormInformationAboutChanges'))
	{

		//Neco malo proti robotum..
		$(".inputDis").hide();
        
		$("#FormInformationAboutChanges").append('<input type="hidden" name="email2" id="idemail2" value="te'+'st" />');
        
		$.validator.setDefaults({
			submitHandler: function() {
				saveInformationAboutChanges();
			}
		});

		$("#FormInformationAboutChanges").validate({
			rules: {
				email: {
					required: true,
					email: true
				},
				confirm: "required"

			},
			messages: {
				email: get_message("Please, fill your e-mail address"),
				confirm: get_message("Please, fill confirmation")

			}
		});
	}
}


function validateFormSendToFriend()
{

	if(document.getElementById('FormSendToFriend'))
	{

		$(".inputDis").hide();
		$("#FormSendToFriend").append('<input type="hidden" name="email2" id="idemail2" value="te'+'st" />');
		$.validator.setDefaults({
			submitHandler: function() {
				sendToFriend();
			}
		});

		$("#FormSendToFriend").validate({
			rules: {
                            
				name: {
					required: true
				},

				email: {
					required: true,
					email: true
				},
				author_email: {
					required: true,
					email: true
				}
			},
			messages: {
				name: get_message("Please, fill your name"),
				email: get_message("Please, fill your friend e-mail address"),
				author_email: get_message("Please, fill your e-mail address")


			}
		});
	}
}

function validateFormContactForm()
{
	if(document.getElementById('FormContactForm'))
	{

		$(".inputDis").hide();
		$("#FormContactForm").append('<input type="hidden" name="email2" id="idemail2" value="te'+'st" />');
  
		$("#FormContactForm").validate({
			rules: {

				name: {
					required: true
				},

				email: {
					required: true,
					email: true
				},
				confirm: "required",
				question: "required"
			},
			messages: {
				name: get_message("Please, fill your name"),
				email: get_message("Please, fill your e-mail address"),
				confirm: get_message("Please, fill confirmation"),
				question: get_message("Please, fill your question")
			}
		});
	}
    
}

//AJAX - doporuceni stranky priteli

function sendToFriend()
{
    
    
	email = $("#idemail").val();
	name  = $("#idname").val();
	email2  = $("#idemail2").val();
	author_email  = $("#idauthoremail").val();
	personal_message  = $("#idpersonalmessage").val();

	title = document.title;
	url   = document.location;

    
	$.ajax({
		global: false,
		cache: false,
		type: "POST",
		url: WEB_URL+'ajax.php',
		data:'modul=send_to_friend_exe&email='+email+'&email2='+email2+'&name='+name+'&title='+title+'&url='+url+'&personal_message='+personal_message+'&author_email='+author_email,
		dataType: "json",
		success: function(msg2) {

          
			status2 = msg2['status'];

			if(status2 == 2)
			{
				alert(get_message('Please, fill obligatory items'));
			}
			else
			{
				if(status2 == 1) {
					alerttxt = get_message('Form was sent');
				}else{
					alerttxt = get_message('Sending error, please try it later');
				}

				$("#FormSendToFriend").html('<div><label class="error">'+alerttxt+'</label></div>');

			}

		}
	});
}


//AJAX - doporuceni stranky priteli

function saveInformationAboutChanges()
{


	email = $("#idemail").val();
	url   = document.location;
	email2  = $("#idemail2").val();



	$.ajax({
		global: false,
		cache: false,
		type: "POST",
		url: WEB_URL+'ajax.php',
		data:'modul=information_about_changes_exe&email='+email+'&email2='+email2+'&url='+url,
		dataType: "json",
		success: function(msg2) {

			status2 = msg2['status'];
 
			if(status2 == 2)
			{
				alert(get_message('Please, fill obligatory items'));
			}
			else
			{
				alerttxt = (status2 == 1) ? get_message('Form was sent') : get_message('Sending error, please try it later');

				$("#FormInformationAboutChanges").html('<div><label class="error">'+alerttxt+'</label></div>');

			}

		}
	});
}

/**
 * Funkce zjisti vysku boxu a podle ni ji dorovna do nejblizsiho nasobku
 * vysky jednoradkoveho boxu
 */


function checkPortfolioCompaniesBoxesHeight()
{
    
	var defaultPortfolioBoxHeight = 30;
	var defaultMarginTop = 2;


	$("#HPBoxPortfolio .boxItem").each(
		function()
		{

			if(( $.browser.msie && ($.browser.version == '7.0' || $.browser.version == '6.0')))
			{

				boxHeight = parseInt($(this).children(".boxItemInner").children(".forIE").height(),10);
             
			}
			else
			{
				boxHeight = parseInt($(this).height(),10);
           
			}

            
            
			if(boxHeight != defaultPortfolioBoxHeight || ( $.browser.msie || ($.browser.version == '7.0' || $.browser.version == '6.0') ))
			{
				numberofDefHeights = Math.ceil(boxHeight/defaultPortfolioBoxHeight);
				//alert(numberofDefHeights);
				newHeight = numberofDefHeights*defaultPortfolioBoxHeight;

				if(numberofDefHeights>1)
				{
					newHeight += (numberofDefHeights-1)*defaultMarginTop;
				}

               

				$(this).height(newHeight);

				$(this).children(".boxItemInner").height(newHeight);

                
              

                
				if($.browser.msie && ($.browser.version == '7.0' || $.browser.version == '6.0'))
				{
                    
					oldHeight = $(this).children(".boxItemInner").children(".forIE").height();

					$(this).children(".boxItemInner").children(".forIE").height(newHeight);

					pos = parseInt((newHeight-oldHeight)/2,10);
					$(this).children(".boxItemInner").children(".forIE").children(".forIE2").css('top',pos+'px');
				//alert(oldHeight+' ; '+ newHeight);
                    

				}
                
                
                


			}


		}
		);
}


function showFlashOurPeople()
{
	if(document.getElementById('HPBoxFlashPeople'))
	{
		var rand = Math.floor(Math.random()*11);

		var flashvars = {
			xmlPath: "flash/our_people/data/data_"+LANG+".xml?rnd="+rand
		};

		var flashparams = {
			quality: "high",
			bgcolor: "#ffffff",
			allowScriptAccess: "sameDomain",
			allowFullScreen: "false",
			allowNetworking: "all",
			scale: "showall",
			wmode:'transparent'
		};

		var flashattributes = {
			id: "HPBoxFlashPeopleFlash",
			name: "HPBoxFlashPeopleFlash"
		};

		if (swfobject.hasFlashPlayerVersion("10"))
		{
			swfobject.embedSWF("flash/our_people/ppf.swf", "HPBoxFlashPeopleContent", 720, 346, "10.0.0", "", flashvars, flashparams, flashattributes);
		}
		else
		{
			$("#HPBoxFlashPeople").addClass("withBackground");
		}
	}

}

function showFlashOurBusiness()
{
	if(document.getElementById('HPBoxFlashBusiness'))
	{
		var rand = Math.floor(Math.random()*11);

		var flashvars = {
			xmlPath: "flash/our_business/data/data_"+LANG+".xml?rnd="+rand
		};

		var flashparams = {
			quality: "high",
			bgcolor: "#ffffff",
			allowScriptAccess: "sameDomain",
			allowFullScreen: "false",
			allowNetworking: "all",
			scale: "showall",
			wmode:'transparent'
		};

		var flashattributes = {
			id: "HPBoxFlashBusinessFlash",
			name: "HPBoxFlashBusinessFlash"
		};

		if (swfobject.hasFlashPlayerVersion("10"))
		{
			swfobject.embedSWF("flash/our_business/ppf_business.swf", "HPBoxFlashBusinessContent", 750, 346, "10.0.0", "", flashvars, flashparams, flashattributes);
		}
		else
		{
			$("#HPBoxFlashBusiness").addClass("withBackground");
		}
		
	}

}

var personOpenID = 0;
function setLinksToInvokeFlashOurPeople()
{
	
	$("#HPBoxPeopleHolder .boxItem").click(function(){
	
		if ($(this).hasClass('is_mobile')) {
			return true;
		} else {
			tmp = $(this).attr('id').split('_');

			if(personOpenID == tmp[1])
				return false;

			personOpenID = 0;
			callFlashPersonOut();
			personOut();

			callFlashPersonClick(tmp[1]);
			$(this).addClass('selected');
			personOpenID = tmp[1];
			return false;
		}
		
		
	});

	$("#HPBoxPeopleHolder .boxItem").mouseover(function(){
		tmp = $(this).attr('id').split('_');
		callFlashPersonOut();
		personOut();

		callFlashPersonOver(tmp[1]);
		$(this).addClass('selected');

		return false;
	});

	$("#HPBoxPeopleHolder .boxItem").mouseout(function(){
		callFlashPersonOut();
		personOut();
		return false;
	});
}


function setLinksToInvokeFlashBusiness()
{

	$("#HPBoxBusinessHolder .boxItem").mouseover(function(){
		tmp = $(this).attr('id').split('_');
		callFlashBusinessOut();
		businessOut();
	
		callFlashBusinessOver(tmp[1]);
		$(this).addClass('selected');

		return false;
	});

	$("#HPBoxBusinessHolder .boxItem").mouseout(function(){
		callFlashBusinessOut();
		businessOut();
		return false;
	});
}

function personClick(personID)
{
	personOut();
	personOpenID = personID;
	$("#Person_" + personID).addClass('selected');
}

function personOver(personID)
{
	$("#Person_" + personID).addClass('selected');
}

function personOut()
{
	
	$("#HPBoxPeopleHolder .boxItem.selected").each(function(){
		tmpOut = $(this).attr('id').split('_');
		if(personOpenID != tmpOut[1])
			$(this).removeClass('selected');
	});
	
}

function personClose()
{
	personOpenID = 0;
	$("#HPBoxPeopleHolder .boxItem.selected").each(function(){
		tmpOut = $(this).attr('id').split('_');
		$(this).removeClass('selected');
	});

}

function businessOver(bizID)
{
	$("#Business_" + bizID).addClass('selected');
}

function businessOut()
{
	$("#HPBoxBusinessHolder .boxItem.selected").each(function(){
		$(this).removeClass('selected');
	});
}

function callFlashPersonClick(personID)
{
	flashOurPeople = getFlashMovieObject("HPBoxFlashPeopleFlash");
	//console.log('personClick');
	try
	{
		flashOurPeople.personClick(personID);
	}
	catch(err)
	{
		//console.log(err);
	}
}

function callFlashPersonOver(personID)
{
	flashOurPeople = getFlashMovieObject("HPBoxFlashPeopleFlash");
	//console.log('personOver');
	
	try
	{
		flashOurPeople.personOver(personID);
	}
	catch(err)
	{
		//console.log(err);
	}
}

function callFlashPersonOut()
{
	flashOurPeople = getFlashMovieObject("HPBoxFlashPeopleFlash");
	//console.log('personOut');
	try
	{
		flashOurPeople.personOut();
	}
	catch(err)
	{
		//console.log(err);
	}
}

function callFlashBusinessOver(bizID)
{
	flashOurBusiness = getFlashMovieObject("HPBoxFlashBusinessFlash");
	
	try
	{
		flashOurBusiness.businessOver(bizID);
	}
	catch(err)
	{
		//console.log(err);
	}
}

function callFlashBusinessOut()
{
	flashOurBusiness = getFlashMovieObject("HPBoxFlashBusinessFlash");

	try
	{
		flashOurBusiness.businessOut();
	}
	catch(err)
	{
		//console.log(err);
	}
}

function getFlashMovieObject(movieName){
    if (window.document[movieName]){
        return window.document[movieName];
    }
    if (navigator.appName.indexOf("Microsoft Internet") == -1){
		if (document.embeds && document.embeds[movieName])
			return document.embeds[movieName];
	}
    else
    {
        return document.getElementById(movieName);
    }
	return false;
}


/**
 * Specialni pro JQUERY
 *--------------------------------------
 *
 */

jQuery.fn.toggleLeftHPBoxInfo = function ($pixelsToView) {

	$reserve = -1*(this.outerWidth() - $pixelsToView);

  
	this.animate({
		left: parseInt(this.css('left'),10) == 0 ?
		$reserve :
		0
	},
	{
		complete:function(){
			if(parseInt($(this).css('left'),10)<0){
				$("#HPBoxInfoButton").addClass('showInfoBox');
			}
			else
			{
				$("#HPBoxInfoButton").removeClass('showInfoBox');
			}
		}
	}
	);
  
}

jQuery.fn.toggleDown = function () {
	elTop = parseInt(this.css('top'),10);
	parentHeight = this.parent().outerHeight();
	this.animate({
		top: elTop == parentHeight ? (parentHeight-this.outerHeight()) : parentHeight
		});
  
}

jQuery.fn.toggleDownLayoutTypeA = function () {
	elTop = parseInt(this.css('margin-top'),10);
  
	this.animate({
		marginTop: elTop > 0 ? '0px' : '443px'
		});

}

jQuery.fn.toggleDownLayoutTypeB = function () {
	elTop = parseInt(this.css('margin-top'),10);

	this.animate({
		marginTop: elTop > 0 ? '0px' : '543px'
		});

}

jQuery.fn.toggleTop = function ($pixelsToView,$bgVisual) {
	var elTop = parseInt(this.css('top'),10);
	var el = this.attr('id');
	var bg = 'url(./images/layout/'+$bgVisual+')';

  
	if(elTop < 0 && $bgVisual!=''){
		this.css('background-image', bg);
	}


	//$reserve = $pixelsToView;
	$reserve = -1*(this.outerHeight() - $pixelsToView);
  
	this.animate({
		top: elTop == $reserve ? 0 : $reserve
		},{
		complete:function(){
			if(elTop == 0 && $bgVisual!=''){
				$("#"+el).css('background-image', 'none')
				}
		}
	});

  
  

}



/**
 * Validace telefonu pomoci JQuery validatoru
 */
$.validator.addMethod("phone", function(value) {

	var reg_mobil1 = "^[1-9]{1}[0-9]{8}$";
	var reg_mobil2 = "^00[0-9]{12}$";
	var reg_mobil3 = "^[\+][0-9]{12}$";

	value = value.replace(/ /g,"");
	if(value.length){
		return ( value.match(reg_mobil1) || value.match(reg_mobil2) || value.match(reg_mobil3));
	}
	return true;
}, "Telefon");

    

