function $(elementId){
	return document.getElementById(elementId);
}
function prepearVar(sendVar){
	if(sendVar==0){
		post='';
	}else{
		post='js='+JSON.stringify(sendVar);
	} 
	return post;
}
function prepearVar2(sendVar){
	if(sendVar==0){
		post='';
	}else{
		post=JSON.stringify(sendVar);
	} 
	return post;
}

function getXML(){
	var xmlHttp=null;
	try{
		// Firefox, Opera 8.0+, Safari, IE8
		xmlHttp=new XMLHttpRequest();
	}catch (e){
		// Internet Explorer
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	    }catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function error(){
	
	if(errors.length==0) return false;
	
	var er=document.getElementById('errorText');
	
	for(x in errors){
		var p1 = document.createElement("p");
		p=er.appendChild(p1);
		p.text=errors[x].msg;
	}
	
	document.getElementById('error').style.display='block';
}
function closeErrors(){
	document.getElementById('errorText').innerHTML='';
	document.getElementById('error').style.display='none';
}

function newInput(type,name,id,value,onclk){
	var input=document.createElement('input');
	input.type=type;
	input.name=name;
	input.id=id;
	input.value=value;
	if(onclk!=''){
		//input.onclick=onclk;
	}
	return input;
}
function newLabel(for_,val){
	var lable=document.createElement('label');
	//lable.setAttribute(document.createAttribute('for'),for_);
	
	lable.setAttribute("for",for_);
	lable.innerHTML=val;
	return lable;
}
function newA(href,text,title){
	var a=document.createElement('a');
	//lable.setAttribute(document.createAttribute('for'),for_);
	a.href=href;
	a.title=title;
	a.innerHTML=text;
	return a;
}
function newSelect(name, id, options){
	var select=document.createElement('select');
	select.name=name;
	select.id=id;
	
	for(x in options){
		var option=document.createElement('option');
		option.innerHTML=options[x];
		option.value=x;
		try			{select.add(option,null);}
		catch(ex)	{select.add(option);}
	}
	return select;
}
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}