function openBlock(btnOpen, boxOpen){

	var flag = true;
	$(btnOpen).click(function(){
		if(flag){
			flag = false;
			if ($(boxOpen).is(':hidden')) {
				$(this).removeClass('close-box');
				$(boxOpen).slideDown(500, function(){flag = true;});
			}
			else {
				$(this).addClass('close-box');
				$(boxOpen).slideUp(500, function(){flag = true;});
			}
		}
		return false;
	});
}


if(typeof(window["initPage"]) == 'undefined')
{
	window.initPage = function()
	{
		var nav = document.getElementById("header");
		if (nav)
		{
			var nodes = nav.getElementsByTagName("div");
			for (var i = 0; i < nodes.length; i++)
			{
				nodes[i].onmouseover = function ()
				{
					if (this.className.indexOf("hover") == -1)
					{
						this.className += " hover";
					}
				}
				nodes[i].onmouseout = function ()
				{
					this.className = this.className.replace(" hover", "");
				}
			}
		}
	}
	$(document).ready(function(){
	if (window.attachEvent && !window.opera)
    	window.attachEvent("onload", window.initPage);
	});
}

$(document).ready(function(){

  //BUTTONS REPLACEMENT AND ANIMATION
    $(".linkbutton").each(function(){
    $(this).after("<a style='position:relative' class='"+$(this).attr('class')+"' id='"+$(this).attr('id')+"_link'><span>"+$(this).attr('value')+"</span></a>").hide();
     var btn = $(this);
     $("#"+$(this).attr('id')+"_link").click(function(){
      if(btn.attr('type')=='submit'){
		prnt = btn.parent();
		while(prnt.length != 0){
			if(prnt[0].tagName != undefined && prnt[0].tagName=="FORM"){
				prnt.append('<input id="temp_submit_input" type="hidden" value="'+btn.attr('value')+'" name="'+btn.attr('name')+'" />');
				prnt.submit();
				$('#temp_submit_input').remove();
			}
			prnt = prnt.parent();
		}
	  }
	  else{
		//btn.click();
	  }
     });
    });

    $(".linkbutton").hover(function () {
        $(this).addClass("opacity_off");
      }, function () {
       $(this).removeClass("opacity_off");
      });

    $(".linkbutton *").hover(function () {
        $(this).parents('.linkbutton').addClass("opacity_off");
      }, function () {});

});
