// JavaScript Document

// dhtml fucntions to hide the element
  function jsu_display(itemId){
	 
		var elem = document.getElementById(itemId);
		if(elem.style.display == 'block')
			elem.style.display = 'none';
		else
			elem.style.display = 'block';
		
	}

  function jsu_visible(itemId){
		var elem = document.getElementById(itemId);
		if(elem.style.visibility == 'hidden')
			elem.style.visibility = 'visible';
		else
			elem.style.visibility = 'hidden';
		
	}
	
	
function jsu_hide(id)
	{
		//alert(id);
		document.getElementById(id).style.display = 'none';
	}
	
	function jsu_show(id)
	{
		document.getElementById(id).style.display = 'block';
	}


function jsu_by_id(id)
{
	return window.document.getElementById(id);	
}

function trim(stringToTrim) {//alert('trim ');
    return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function clear_value(element)
{
	element . value = '';	
}

function jsu_popup(goLocation,scrollbars) {
	
	

var ver=parseInt(navigator.appVersion);
var isNetscape=navigator.appName.indexOf("Netscape")>=0;
var isExplorer=navigator.appName.indexOf("Explorer")>=0;

	if (scrollbars != 'yes' && scrollbars != 'no')
		scrollbars = 'yes';

        var ww=630;
        var wh=450;
        var positionCode="";
        if(ver>=4) {
                sw  = screen.width;
                sh  = screen.height;
                wbx = Math.round((sw-ww)/2);
                wby = Math.round((sh-wh)/2);
                if(isExplorer) positionCode="left="+wbx+",top="+wby+",";
                if(isNetscape) positionCode="screenX="+wbx+",screenY="+wby+",";
        }

//alert(scrollbars);

        newWindow=window.open(goLocation,"sample",
        "width="+ww+",height="+wh+","+
        positionCode+
        "toolbar=no,"+
        "bar=no"+
        "location=no,"+
        "status=no,"+
        "menubar=no,"+
        "scrollbars=" + scrollbars + ","+
        "resizable=1");
        if(isNetscape && ver>=3) newWindow.focus();
    window.name='main';
	
	return newWindow;
	
}

var submitted_form = new Array();
function jsu_forms_submit(form_name)
{
	
	if ( !submitted_form[form_name] )
	{
		submitted_form[form_name] =1;
		document.forms[form_name].submit();
	}
	
}

function check(id)
{
	element = document.getElementById(id);
	if (element)element.checked = true;
}

function uncheck(id)
{
	element = document.getElementById(id);
	if (element)element.checked = false;
}




function check_all(value)
{
	collection = document.getElementsByTagName("input");
	
	for( i = 0; i < collection.length; i++)
	{
  		if (collection[i].type == 'checkbox') collection[i].checked = value;    
	}
}


var displayed_element = '';
/* скрытие отображения старого элемента при открытиии нового*/
function jsu_display_mem( new_element )
{
	if (displayed_element != '' && new_element != displayed_element)
		jsu_hide(displayed_element);
	
	displayed_element = new_element;
	jsu_display(new_element);
}


