function trimString (str) {
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}
///////////////////////////
function resetval(name,text){
	var value = document.getElementById(name).value;
	
	if(value==text){
	document.getElementById(name).value = "";
	}
	document.getElementById(name).style.color = "#000000";
}

/////////////////////////////////
function showhideDiv(divname){
	
if(document.getElementById(divname).style.visibility=="hidden"){
document.getElementById(divname).style.visibility="visible";
document.getElementById(divname).style.display="block";
}else{
document.getElementById(divname).style.visibility="hidden";
document.getElementById(divname).style.display="none";

}
}
/////////////////////////////////////
function showDiv(divname){
	

document.getElementById(divname).style.visibility="visible";
document.getElementById(divname).style.display="block";

}
/////////////////////////////////////
function hideDiv(divname){
	

document.getElementById(divname).style.visibility="hidden";
document.getElementById(divname).style.display="none";


}
/////////////////////////////////////
function ajax_form_submit(link,divname,formname) {
  //The form data is sent to the given URL using a POST method, 
  //rather than a GET by using the dojo.xhrPost function.

dojo.require("dojo.parser");
dojo.require("dojo.io.iframe");
var contentNode = dojo.byId(divname);
  dojo.xhrPost({
    url: link,
    load: function(response, ioArgs){
      contentNode.innerHTML = response;
      dojo.parser.parse(contentNode);
      //Dojo recommends that you always return(response); to propagate 
      //the response to other callback handlers. Otherwise, the error 
      //callbacks may be called in the success case.
      return response;
    },
    error: function(response, ioArgs){
      contentNode.innerHTML = 
        "An error occurred, with response: " + response;
           dojo.parser.parse(contentNode);   
      return response;
    },
    
    //Setting the 'form' parameter to the ID of a form on the page
    //submits that form to the specified URL
    form: formname
  });
    dojo.query('[widgetId]', dojo.byId(divname)).forEach(function(node){
var widget = dijit.byNode(node);
if(widget)
widget.destroy();
})
}
/////////////////////////////////////
function show_div(divname){
	document.getElementById(divname).style.visibility="visible";
document.getElementById(divname).style.display="block";
}
////////////////////////////////////
function hide_div(divname){
document.getElementById(divname).style.visibility="hidden";
document.getElementById(divname).style.display="none";
}
////////////////////////////////////
function run_ajax2(parm,go,divname){
	dojo.query('[widgetId]', dojo.byId(divname)).forEach(function(node){
	var widget = dijit.byNode(node);
	if(widget)
	widget.destroy();
	})
	var init = function(){
	if(parm){
	t = "&"+parm+"&sid="+Math.random();
	}else{
	t = "&sid="+Math.random();
	}
	var urlx = go+t;
	dojo.require("dijit.ProgressBar");
	var LoadingMsg = "";
	dojo.require("dojo.parser");
	var contentNode = dojo.byId(divname);
	dojo.xhrGet({
		url: urlx,
		load: function(data,args){
			// fade out the node we're modifying
			dojo.fadeOut({
				node: contentNode,
				duration: 1000,
				beforeBegin: function(){
				  // set the data, fade it back in
				  contentNode.innerHTML = LoadingMsg;
				  console.log("Posting data & parsing Content");
				  dojo.eval(dojo.parser.parse(contentNode));
				  //dojo.fadeIn({node: contentNode,duration: 1000, delay:5}).play();
				},
				onEnd: function(){
				  // set the data, fade it back in
				contentNode.innerHTML = data;
				dojo.eval(dojo.parser.parse(contentNode));
				console.log('Get requested url : '+urlx+'');
				dojo.fadeIn({node: contentNode,duration: 1000, delay:5}).play();
				}
			}).play();
		},
		// if any error occurs, it goes here:
		error: function(error,args){
			console.warn("error!",error);
		}
	});
}; 
dojo.addOnLoad(init);
}
/////////////////////////////////////
function ajax_url(parm,go,divname){
	dojo.query('[widgetId]', dojo.byId(divname)).forEach(function(node){
	var widget = dijit.byNode(node);
	if(widget)
	widget.destroy();
	})
	var init = function(){
	if(parm){
	t = "?"+parm+"&sid="+Math.random();
	}else{
	t = "?sid="+Math.random();
	}
	var urlx = go+t;
	var LoadingMsg = "<div><strong>Loading...</strong></div>";
	dojo.require("dojo.parser");
	var contentNode = dojo.byId(divname);
	dojo.xhrGet({
		url: urlx,
		load: function(data,args){
			// fade out the node we're modifying
			dojo.fadeOut({
				node: contentNode,
				duration: 100,
				beforeBegin: function(){
				  // set the data, fade it back in
				  contentNode.innerHTML = LoadingMsg;
				  console.log("Posting data & parsing Content");
				  dojo.eval(contentNode);
				  //dojo.fadeIn({node: contentNode,duration: 1000, delay:5}).play();
				},
				onEnd: function(){
				  // set the data, fade it back in
				contentNode.innerHTML = data;
				dojo.eval(contentNode);
				console.log('Get requested url : '+urlx+'');
				dojo.fadeIn({node: contentNode,duration: 100, delay:5}).play();
				}
			}).play();
		},
		// if any error occurs, it goes here:
		error: function(error,args){
			console.warn("error!",error);
		}
	});
}; 
dojo.addOnLoad(init);
}

///////////////////////////////////////////

var handle;
function run_ajax(paramenters,page,div)
{
	handle = getbrowser();
    handle.onreadystatechange = function()
{



    if(handle.readyState==4|| handle.readyState=="complete")
{

document.getElementById(div).innerHTML = handle.responseText;      

}

}
if(page.indexOf("?")>-1){
	 url = page+"&seId="+Math.random()+"&"+paramenters;
}
else{
	 url = page+"?seId="+Math.random()+"&"+paramenters;
}
   
    handle.open("GET",url,true);
    handle.send(null);
}
/////////////////////////////////////
var handle;
function append_ajax(paramenters,page,div)
{
	handle = getbrowser();
    handle.onreadystatechange = function()
{



    if(handle.readyState==4|| xmlHttp.readyState=="complete")
{

document.getElementById(div).innerHTML += handle.responseText;      

}

}
if(page.indexOf("?")>-1){
	 url = page+"&seId="+Math.random()+"&"+paramenters;
}
else{
	 url = page+"?seId="+Math.random()+"&"+paramenters;
}
    
    handle.open("GET",url,true);
    handle.send(null);
}

/////////////////////////////////////
var handle;
function run_ajax_form(action,div,form_ord)
{
	handle = getbrowser();
    handle.onreadystatechange = function()
{


    if(handle.readyState==4)
{

document.getElementById(div).innerHTML = handle.responseText;                  
}

}
var len = document.forms[form_ord].elements.length;
var paramenters="",el_name="",el_val = "",el_type = "";
for(var x=0;x<len;x++){
	el_name = document.forms[form_ord].elements[x].name;
	el_type = document.forms[form_ord].elements[x].type;
	el_val = document.forms[form_ord].elements[x].value;
	if(el_type=="radio"){
	if(document.forms[form_ord].elements[x].checked){
	paramenters += "&"+el_name+"="+el_val;
	}
	}
	else{
	paramenters += "&"+el_name+"="+el_val;
	}
	
	
}

     url = action+"?seId="+Math.random()+paramenters;
	
    handle.open("GET",url,true);
    handle.send(null);
}
/////////////////////////////////////
var handle;

function fillregions(val,no,div,folder)
{
	handle = getbrowser();
    handle.onreadystatechange = function()
{


    if(handle.readyState==4)
{

document.getElementById(div).innerHTML = handle.responseText;                  
}

}

     url = folder+"ajaxes.php?seId="+Math.random()+"&id="+val+"&no="+no;
    handle.open("GET",url,true);
    handle.send(null);
}
/////////////////////////////////////

function doctornames(num,div,row,upd)
{
	handle = getbrowser();
    handle.onreadystatechange = function()
{


    if(handle.readyState==4)
{

		document.getElementById(div).innerHTML = handle.responseText;   

}

}
     url = "doctors.php?seId="+Math.random()+"&num="+num+"&row="+row+"&upd="+upd;
    handle.open("GET",url,true);
	
    handle.send(null);
}
/////////////////////////////////////
function update_spec(id,div,newval,no)
{
	handle = getbrowser();
    handle.onreadystatechange = function()
{


    if(handle.readyState==4)
{

		document.getElementById(div).innerHTML = handle.responseText;   

}

}
     url = "dir/check.php?seId="+Math.random()+"&num="+id+"&newval="+newval+"&no="+no;

    handle.open("GET",url,true);
	handle.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=Windows-1256");
    handle.send(null);
}
/////////////////////////////////////
//var handle;
function checkName(name,divname,lang)
{
	
	handle = getbrowser();
    handle.onreadystatechange = function()
{


    if(handle.readyState==4)
{

document.getElementById(divname).innerHTML = handle.responseText;                  
}

}
     url = "dir/check.php?seId="+Math.random()+"&uname="+name+"&lang="+lang;
    handle.open("GET",url,true);
    handle.send(null);
}

/////////////////////////////////////
function showdetails(divName)
{
	if(document.getElementById(divName).style.visibility == "visible")
	{
		document.getElementById(divName).style.visibility = "hidden";
		document.getElementById(divName).style.display = "none";
	}
	else
	{
	document.getElementById(divName).style.visibility = "visible";
	document.getElementById(divName).style.display = "inline";
	}
}
/////////////////////////////////////
function showdiv(divName)
{
	document.getElementById(divName).style.visibility = "visible";
	document.getElementById(divName).style.display = "inline";
}
/////////////////////////////////////
function hidediv(divName)
{
	document.getElementById(divName).style.display = "none";
	document.getElementById(divName).style.visibility = "hidden";
	
}
/////////////////////////////////////
function showAndSet(divName,buttonname)
{
	if(document.getElementById(divName).style.visibility == "visible")
	{
		document.getElementById(divName).style.visibility = "hidden";
		document.getElementById(divName).style.display = "none";
		document.getElementById(buttonname).value = "ÚÑÖ";
	}
	else
	{
	document.getElementById(divName).style.visibility = "visible";
	document.getElementById(divName).style.display = "inline";
	document.getElementById(buttonname).value = "ÅÎÝÇÁ";
	}
}
/////////////////////////////////////
function getbrowser()
{

var handle=null;

try{

handle = new XMLHttpRequest();

}

catch(e)
{

try{

handle = new ActiveXObject("Microsoft.XMLHTTP");

}

catch(e)
{

try{

handle = new ActiveXObject("Msxml2.XMLHTTP");

}

catch(e)
{

alert("your browser does not support AJAX");

}


}


}

return handle;

}



