window.addEvent("domready", function(){

          /* url text */

if($$("html").get("lang") == "en"){
  var text_value = "";
} else {
  var text_value = "";
}
if($("url")){
  if($("url").value == ""){
    $("url").value = text_value;
  }
  $("url").addEvent("click", function(){
    if($("url").value == text_value){
      $("url").value = "";
    }    
  });
  $("url").addEvent("focus", function(){
    if($("url").value == text_value){
      $("url").value = "";
    }    
  });
  $("url").addEvent("blur", function(){
    if($("url").value == ""){
      $("url").value = text_value;
    }    
  });  
}

/* captcha */     
if($$("#button")){ 
	$$("button").addEvent("click", function(){
		$('input[name=captcha]').value = 2;
		alert($('input[name=captcha]').value());
  	return true;
 	});	
}

/* slovnik */
  $$(".slovnik").addEvent("click", function(){
    this.getElement("span").toggleClass("nocss"); 
  }); 

/* facebook */   
  

$$(".log_on_web").addEvent("click", function(){
	$('login_form').removeClass("nocss");
	$('links').addClass('nocss'); 
	$$('.log_on_web').addClass("nocss");
	return false;
});	


$$('select[name="ticker"]').addEvent("change", function(){
	var ticker = $$('#ticker').get('value');
	var iframe = '<IFRAME style="border:3px Solid #E5E7D9" name="zone_article" align="center" height="550" scrolling="no" frameborder="0" width="550" src="http://www.24hgold.com/UserControls/ExportDataXML';
	if(ticker == 'GOLD'){
		iframe += 'Commodities.aspx?lg=en&WorldCom=true&codecom=GOLD&changecom=chgecom&valuecom=valecom';
	} else if(ticker == 'SILVER'){
		iframe += 'Commodities.aspx?lg=en&WorldCom=true&codecom=SILVER&changecom=chgecom&valuecom=valecom';
	} else if(ticker == 'OIL'){
		iframe += 'Commodities.aspx?lg=en&WorldCom=true&codecom=WTI CRUDE FUTURE&changecom=chgecom&valuecom=valecom';
	} else if(ticker == 'GAS'){
		iframe += 'Commodities.aspx?lg=en&WorldCom=true&codecom=NATURAL GAS FUTR&changecom=chgecom&valuecom=valecom';
	} else if(ticker == 'EUR-USD'){
		iframe += 'Currencies.aspx?lg=en&worldcur=true&codecur=EUR-USD';
	} else if(ticker == 'EUR-GBP'){
		iframe += 'Currencies.aspx?lg=en&worldcur=true&codecur=EUR-GBP';
	} else if(ticker == 'USD-JPY'){
		iframe += 'Currencies.aspx?lg=en&worldcur=true&codecur=USD-JPY';
	} else if(ticker == 'DOWJONES'){
		iframe += 'Indices.aspx?lg=en&worldind=true&codeind=DOW JONES INDUS. AVG';
	} else if(ticker == 'NASDAQ'){
		iframe += 'Indices.aspx?lg=en&worldind=true&codeind=NASDAQ COMPOSITE INDEX';
	} else if(ticker == 'NIKKEI'){
		iframe += 'Indices.aspx?lg=en&worldind=true&codeind=NIKKEI 225';
	} else if(ticker == 'FTSE'){
		iframe += 'Indices.aspx?lg=en&worldind=true&codeind=FTSE 100 INDEX';
	} else if(ticker == 'DAX'){
		iframe += 'Indices.aspx?lg=en&worldind=true&codeind=DAX INDEX';
	}

	iframe += '&format=550&periode=all"></IFRAME>';
	$$('#graf').set('html',iframe);
});	
	
          /* xbox 
          
var x_box = new XBox();          
*/          
          /* novinky */          

if($("novinka")){
  $$("#novinka a.vice").addEvent("click", function(){
    $$("#"+this.getParent().id+" a.vice").addClass("nocss");
	$$("#"+this.getParent().id+" a.mene").removeClass("nocss");
	$(this.getParent().id + "_content").setStyle("display", "block");
    return false;
  });
  $$("#novinka a.mene").addEvent("click", function(){
    $$("#"+this.getParent().id+" a.vice").removeClass("nocss");
	$$("#"+this.getParent().id+" a.mene").addClass("nocss");
	$(this.getParent().id + "_content").setStyle("display", "none");
    return false;
  });
}

          /* zpravy */          

if($("zprava")){
  $$("#zprava a.vice").addEvent("click", function(){
    $$("#"+this.getParent().id+" a.vice").addClass("nocss");
	$$("#"+this.getParent().id+" a.mene").removeClass("nocss");
	$(this.getParent().id + "_content").setStyle("display", "block");
	$(this.getParent().id + "_uvod").setStyle("display", "none");
    return false;
  });
  $$("#zprava a.mene").addEvent("click", function(){
    $$("#"+this.getParent().id+" a.vice").removeClass("nocss");
	$$("#"+this.getParent().id+" a.mene").addClass("nocss");
	$(this.getParent().id + "_content").setStyle("display", "none");
	$(this.getParent().id + "_uvod").setStyle("display", "block");
    return false;
  });
}



          /* form-validation */
          
var form_validation = new FormValidation({
    default_border : "1px solid #C9C9C9"
});

          /* navi */
if($("navi")){
  $$("#navi .level0").each(function(item){
    item.addEvents({
      "mouseover" : function(){
        if(this.getElement("ul")){
          this.getElement("ul").setStyle("display", "block");
        }
      },
      "mouseout" : function(){
        if(this.getElement("ul")){
          this.getElement("ul").setStyle("display", "none");
        }
      }
    });
  });
}
          /* naviz */

if($("naviz")){
  var looper = looping.periodical(3000);  // set delay in miliseconds 
}

if($("naviz")){
  $$("#naviz a").addEvent("click", function(){
    $$("#naviz a.act").removeClass("act");
    this.addClass("act");
    looper = $clear(looper);
    $$(".naviz_content").setStyle("display", "none");
    $("naviz_" + this.getParent().id + "_content").setStyle("display", "block");
    this.blur();
    return false;
  });
}

          /* home naviz */
          
if($("home_naviz")){
  var home_looper = home_looping.periodical(5000);  // set delay in miliseconds 
}

if($("home_naviz")){
  $$("#home_naviz a").addEvent("click", function(){
    $$("#home_naviz a.act").removeClass("act");
    this.addClass("act");
    home_looper = $clear(home_looper);
    $$(".home_naviz_content").setStyle("display", "none");
    $("home_naviz_" + this.getParent().id + "_content").setStyle("display", "block");
    this.blur();
    return false;
  });
}

          /* zajimave odkazy */
if($("submit_zo")){
  $$("#submit_zo").addEvent("click", function(){
    $$(".loading").setStyle("display", "block");
    return true;
  });
}

          /* search text */

if($$("html").get("lang") == "en"){
  var search_value = "Searched word...";
  var user_value = "User"; 
  var pass_value = "Pass"; 
} else {
  var search_value = "Hledaný výraz...";
  var user_value = "Uživatelské jméno"; 
  var pass_value = "Heslo"; 
}

if($("search")){
  if($("search").value == ""){
    $("search").value = search_value;
  }
  $("search").addEvent("click", function(){
    if($("search").value == search_value){
      $("search").value = "";
    }    
  });
  $("search").addEvent("focus", function(){
    if($("search").value == search_value){
      $("search").value = "";
    }    
  });
  $("search").addEvent("blur", function(){
    if($("search").value == ""){
      $("search").value = search_value;
    }    
  });  
}

          /* user text */
          
if($("f_user")){
  if($("f_user").value == ""){
    $("f_user").value = user_value;
  }
  $("f_user").addEvent("click", function(){
    if($("f_user").value == user_value){
      $("f_user").value = "";
    }    
  });
  $("f_user").addEvent("focus", function(){
    if($("f_user").value == user_value){
      $("f_user").value = "";
    }    
  });
  $("f_user").addEvent("blur", function(){
    if($("f_user").value == ""){
      $("f_user").value = user_value;
    }    
  });  
}

          /* pass text */

if($("f_pass")){
  if($("f_pass").value == ""){
    $("f_pass").value = pass_value;
  }
  $("f_pass").addEvent("click", function(){
    if($("f_pass").value == pass_value){
      $("f_pass").value = "";
    }    
  });
  $("f_pass").addEvent("focus", function(){
    if($("f_pass").value == pass_value){
      $("f_pass").value = "";
    }    
  });
  $("f_pass").addEvent("blur", function(){
    if($("f_pass").value == ""){
      $("f_pass").value = pass_value;
    }    
  });  
}


          /* targetblanks */

$$("a.targetblank").addEvent("click", function(event){
  if(typeof window.open(this.href)=="object"){
    event.stop();
  }
});



          /* alerts */
		if($$('.search_link')){
			$$(".search_link").addEvent("click", function(event){
				window.location = $$(".search_link");
			});	
		}

if($("alert")){
	$("alert").addEvent("click", function(event){
		if($$('.log_on_web')){
			if($('login_form')){
				$('login_form').removeClass("nocss");
				$('links').removeClass("nocss");	
			}
			$$('.log_on_web').addClass("nocss");
		}
		$("alert").addClass("nocss");
		return false;
	});
}

});



var looping_index = 2;
var looping = function(looping_steps){
  $$("#naviz a.act").removeClass("act");  
  $$(".naviz_content").setStyle("display", "none");
  $("l"+looping_index).getFirst().addClass("act");
  $("naviz_l" + looping_index + "_content").setStyle("display", "block");  
  if(looping_index == $$(".naviz_content").length){
    looping_index = 1;
  } else {
    looping_index++;
  }
}

var home_looping_index = 2;
var home_looping = function(looping_steps){
  $$("#home_naviz a.act").removeClass("act");  
  $$(".home_naviz_content").setStyle("display", "none");
  $("home_l"+home_looping_index).getFirst().addClass("act");
  $("home_naviz_home_l" + home_looping_index + "_content").setStyle("display", "block");  
  if(home_looping_index == $$(".home_naviz_content").length){
    home_looping_index = 1;
  } else {
    home_looping_index++;
  }
}


// Surrounds the selected text with text1 and text2.
function surroundText(text1, text2, textarea)
{
	
 if(typeof(textarea.caretPos) != "undefined") {
 
 var SelectedString = document.selection.createRange().text;  
	// Can a text range be created?
	if (SelectedString.length>0)
	{

  var ReplaceString = text1+SelectedString+text2;
  document.selection.createRange().text = ReplaceString;


	}
	}
	// Mozilla text range wrap.
	else if (typeof(textarea.selectionStart) != "undefined")
	{
		var begin = textarea.value.substr(0, textarea.selectionStart);
		var selection = textarea.value.substr(textarea.selectionStart, textarea.selectionEnd - textarea.selectionStart);
		var end = textarea.value.substr(textarea.selectionEnd);
		var newCursorPos = textarea.selectionStart;
		var scrollPos = textarea.scrollTop;

		textarea.value = begin + text1 + selection + text2 + end;

		if (textarea.setSelectionRange)
		{
			if (selection.length == 0)
				textarea.setSelectionRange(newCursorPos + text1.length, newCursorPos + text1.length);
			else
				textarea.setSelectionRange(newCursorPos, newCursorPos + text1.length + selection.length + text2.length);
			textarea.focus();
		}
		textarea.scrollTop = scrollPos;
	}
	// Just put them on the end, then.
	else
	{
	  var SelectedString = document.selection.createRange().text;  
	// Can a text range be created?
	if (SelectedString.length>0)
	{

  var ReplaceString = text1+SelectedString+text2;
  document.selection.createRange().text = ReplaceString;


	}else{
		textarea.value += text1 + text2;
		textarea.focus(textarea.value.length - 1);
	}


	}
}
