	
	var ajax_val = new Array();

	function $(id) {
		return document.getElementById(id);
	}
	
	var submenu_status1;
	function showSubmenu1(type, action)
	{
		if(action == 'over')
		{
			submenu_status1 = 'block';
			$('submenu_' + type).style.display = 'block';
			$('submenu_' + type).style.zIndex = 102;
		}
		else
		{
			$('submenu_' + type).style.zIndex = 100;
			submenu_status1 = 'none';
			var submenu_name = 'submenu_' + type
			setTimeout("hide1('" + submenu_name + "')", 2000);
			
		}
	}
	
	function hide1(name)
	{
		$(name).style.display = submenu_status1;
	}
	
	
	var submenu_status2;
	function showSubmenu2(type, action)
	{
		if(action == 'over')
		{
			submenu_status2 = 'block';
			$('submenu_' + type).style.display = 'block';
			$('submenu_' + type).style.zIndex = 102;
		}
		else
		{
			$('submenu_' + type).style.zIndex = 100;
		
			submenu_status2 = 'none';
			var submenu_name = 'submenu_' + type
			setTimeout("hide2('" + submenu_name + "')", 2000);
			
		}
	}
	
	function hide2(name)
	{
		$(name).style.display = submenu_status2;
	}
	
	var submenu_status3;
	function showSubmenu3(type, action)
	{
		if(action == 'over')
		{
			submenu_status3 = 'block';
			$('submenu_' + type).style.display = 'block';
			$('submenu_' + type).style.zIndex = 102;
		}
		else
		{
			$('submenu_' + type).style.zIndex = 100;
			submenu_status3 = 'none';
			var submenu_name = 'submenu_' + type
			setTimeout("hide3('" + submenu_name + "')", 2000);
			
		}
	}
	
	function hide3(name)
	{
		$(name).style.display = submenu_status3;
	}
	
	



	function List()
	{
		var current_row_bgcolor;
		var current_row_id;
		
		this.over = function(obj)
		{
			current_row_bgcolor = obj.style.backgroundColor;
			current_row_id = obj.id;
			
			$(obj.id).style.backgroundColor = '#FF4E00';
		}
		
		this.out = function(obj)
		{
			$(current_row_id).style.backgroundColor = current_row_bgcolor;
		}
	}

	
	function Language()
	{
		this.switchLg = function(field_name, type, lg)
		{
			if(type == 'input')
			{
			
				for (var idx in supp_lg)
				{
					if( supp_lg[idx] == lg )
					{
						$('switch_lg_' + field_name + '_' + supp_lg[idx]).style.fontWeight = 'bold';
						$('switch_lg_' + field_name + '_' + supp_lg[idx]).style.textDecoration = 'underline overline';
						$(field_name + '_' + supp_lg[idx] + '_field_box').style.display = 'block';
					}
					else
					{
						$('switch_lg_' + field_name + '_' + supp_lg[idx]).style.fontWeight = 'normal';
						$('switch_lg_' + field_name + '_' + supp_lg[idx]).style.textDecoration = 'none';
						$(field_name + '_' + supp_lg[idx] + '_field_box').style.display = 'none';
					}
				}
				
			}
			else
			{
				var actual_lg = $(field_name + '_active').value;
				var oEditor = FCKeditorAPI.GetInstance(field_name);
				
				if( $('switch_lg_' + field_name + '_' + actual_lg) )
				{
					$('switch_lg_' + field_name + '_' + actual_lg).style.fontWeight = 'normal';
					$('switch_lg_' + field_name + '_' + actual_lg).style.textDecoration = 'none';
				}
				$(field_name + '_' + actual_lg).value = oEditor.GetHTML();

				if( $('switch_lg_' + field_name + '_' + lg) )
				{
					$('switch_lg_' + field_name + '_' + lg).style.fontWeight = 'bold';
					$('switch_lg_' + field_name + '_' + lg).style.textDecoration = 'underline overline';
				}
				oEditor.SetHTML( $(field_name + '_' + lg).value );
			}
			
			
			$(field_name + '_active').value = lg;
		}
	
	
		this.copyValToAllLg = function(field_name)
		{
			var lg = $(field_name + '_active').value;
			var val = $(field_name + '_' + lg).value;
			
			for (var idx in supp_lg)
			{
				$(field_name + '_' + supp_lg[idx]).value = val;
			}
		}
	}

	// Zacatek sekce k funkcemi pro E-SHOP
	
	
	function Shop() 
	{
		this.own = this;
		
		var action = "";
		
		this.addItemToBasket = function(id_item, pcs)
		{
			if(!pcs) pcs = 1;

			action = "add_to_basket";

			var url = $('server_www').value + "/ajax/?action=" + action + "&id_item=" + id_item + "&pcs=" + pcs;

			GetUrl(url, this);
		}
		
		
		this.ajax_success = function()
		{
			var response = htmlConnection.responseText;
			
			if(action == "add_to_basket")
			{
				var arr_response = intoArray(response);

				$('basket_pcs').innerHTML = arr_response['BASKET_PCS'];
				$('basket_price').innerHTML = formatNumber( arr_response['BASKET_PRICE'] );
			
			
			}
		
		}
	}
	
	

  function setDelAddr() {
  	if($('same_inv_address').checked)
  		$('box_inv_addr').style.display = 'none';
  	else
  		$('box_inv_addr').style.display = 'block';
  }
	

	function formatNumber(n, c, d, t ) 
	{
		if(!c) c = 0;
		if(!d) d = ',';
		if(!t) t = '.';
		
		var m = ( c = Math.abs( c ) + 1 ? c : 2, d = d || ",", t = t || ".", /(\d+)(?:(\.\d+)|)/.exec( n + "" ) ), x = m[1].length % 3;
		return ( x ? m[1].substr( 0, x ) + t : "" ) + m[1].substr( x ).replace( /(\d{3})(?=\d)/g, "$1" + t ) + ( c ? d + ( +m[2] ).toFixed( c ).substr( 2 ) : "" );
	};

	
	function intoArray(string)
	{
		var res_string = new Array();
		
		var tmp_string = string.split(";");
		for(var i=0; i < tmp_string.length; i++) 
		{
			var arr_string = tmp_string[i].split("=");
			
			res_string[ arr_string[0] ] = arr_string[1];
		}
	
		return res_string;
	}
	
	
	// Konec sekce k funkcemi pro E-SHOP
	
	
	function addToBasket() {
	
		global_action = 'add_to_basket';
		
		var url = $('server_www').value+'index.php?page=8&IDproduct='+$('size').value;

		GetUrl(url);
	}
	
	
	function success(){

		var response = htmlConnection.responseText;

		if(global_action == 'change_pcs') {
			var arr_response = response.split(";");
			document.getElementById('basket_price').innerHTML=arr_response[0];
			document.getElementById('basket_final_price').innerHTML=arr_response[0]+',-';
	
			document.getElementById('basket_pcs').innerHTML=arr_response[1];
			document.getElementById('prod_price_'+IDproduct).innerHTML=arr_response[2]+',-';
	  }
	}
	

	function changePcs(id, pcs) {
	
		global_action = 'change_pcs';

		IDproduct = id;

		var url = $('server_www').value+'ajax/?action='+global_action+'&id_item='+id+'&pcs='+pcs;

		GetUrl(url);
	}
	
	
	
	

  
  function submit() {
  	$('form_prod_list').submit();
  }
  
  function showBoxInvAddr() {
  	if($('same_inv_address').checked)
  		$('box_inv').style.display = 'none';
  	else
  		$('box_inv').style.display = 'block';
  }
	
	function showBoxCompany(type) {
		if(type == 'company') {
			$('box_comp').style.display = 'block';
		}
		else {
			$('box_comp').style.display = 'none';
		}
	}
	
	function loadSubCategory(id_category) {
	
		if(!$('subcategory_' + id_category).innerHTML)
		{
			ajax_val['action'] = 'get_subcategory';
			ajax_val['id_category'] = id_category;
	
			var url = $('server_www').value + "/ajax/?action=" + ajax_val['action'] + "&id_category=" + id_category;
	
			GetUrl(url);
		}
		else
		{
			var display = $('subcategory_' + id_category).style.display;

			$('subcategory_' + id_category).style.display = (display == 'none' ? 'block' : 'none');
		}
	}
	
	/* Fce na otevirani a zavirani leveho menu.
	 * Zapamatovava se stav jednotlivych slozek.
	 */
	function showSubTree(id,level) {
	
		// pokud uzivatel kliknul na slozku, ktera uz nejde otevrit
		if($('b_' + id) == null) {

			sendTree();
			location.href = $('server_www').value+'shop/t-' + id + '/';
		} else {

			if(level == 1 && $('levelStatus_1').value != id) {
			
				for(var i=1; i<=5; i++) {
	
					if($('levelStatus_' + i).value) {
						$('b_' + $('levelStatus_' + i).value).style.display = 'none';
						$('levelStatus_' + i).value = '';
					}
				}
			}
					
			if($('b_' + id).style.display == 'block') {
				$('b_' + id).style.display = 'none';
				$('levelStatus_' + level).value = '';
			}
			else {
				if($('levelStatus_' + level).value)
					$('b_' + $('levelStatus_' + level).value).style.display = 'none';
				$('b_' + id).style.display = 'block';
				$('levelStatus_' + level).value = id;
			}
		}
		
		sendTree();
		
	}
	
	function sendTree() {
	
		global_action = 'send_tree';

		var url = $('server_www').value+'index.php?page=7&l1='+$('levelStatus_1').value+
							'&l2='+$('levelStatus_2').value+
							'&l3='+$('levelStatus_3').value+
							'&l4='+$('levelStatus_4').value+'&l5='+$('levelStatus_5').value;

		GetUrl(url);
	}



	function alertController(id) {

		if(id != 'alert_add_to_basket') $('alert_add_to_basket').style.display = 'none';
		if(id != 'alert_login') $('alert_login').style.display = 'none';
		if(id != 'alert_reg') $('alert_reg').style.display = 'none';
		if(id != 'alert_logout') $('alert_logout').style.display = 'none';
		if(id != 'alert_buy') $('alert_buy').style.display = 'none';
	}
	
	function closeAlert(id) {
		
		alertController(id);
	
		$(id).style.display = 'none';
	}
	
	function openAlert(id) {
	
		alertController(id);
	
		$(id).style.display = 'block';
	}



  function openPopup(link, name, width, height, resizable) 
  {
    if(!width)  width=400;
    if(!height) height=400;
    if(resizable!=0) resizable=1;

    win = window.open(link, name, 'toolbar=0,location=0,status=1,resizable='+ resizable +',scrollbars=1,width='+ width +',height='+ height +',top=100,left=180');
    win.focus();
    
    return win;
  }
  
  function basketAction(action) 
  {
  	$('basket_action').value = action;
  	$('basket_form').submit();
  }

	function hoverMenu(name, sufix) 
	{
		$(name).src = $('server_www').value+'img/'+name+'_'+sufix+'.gif';
	}
	
	
	
	function chooseProduct(name, foto_name, w, h, part_number) {

		window.opener.window.$('choose_name_box').innerHTML = name;
		window.opener.window.$('choose_name').value = name;
		window.opener.window.$('choose_part_number').value = part_number;
		window.opener.window.$('choose_foto').src = $('server_www').value + 'data/prod_photos/list/' + foto_name;
		window.opener.window.$('choose_foto').width = w;
		window.opener.window.$('choose_foto').height = h;
		window.opener.window.$('choose_foto_box').style.display = 'block';
    opener.focus();
    window.close();
	}

	
