function hidediv(pass) {
var divs = document.getElementsByTagName('div');
for(i=0;i<divs.length;i++){
if(divs[i].id.match(pass)){//if they are 'see' divs
if (document.getElementById) // DOM3 = IE5, NS6
divs[i].style.visibility="hidden";// show/hide
else
if (document.layers) // Netscape 4
document.layers[divs[i]].display = 'hidden';
else // IE 4
document.all.hideshow.divs[i].visibility = 'hidden';
}
}
}

function showdiv(pass) {
var divs = document.getElementsByTagName('div');
for(i=0;i<divs.length;i++){
if(divs[i].id.match(pass)){
if (document.getElementById)
divs[i].style.visibility="visible";
else
if (document.layers) // Netscape 4
document.layers[divs[i]].display = 'visible';
else // IE 4
document.all.hideshow.divs[i].visibility = 'visible';
}
}
}

function td_tog2(row)
{
var my_r=document.getElementById(row).style;
	if(my_r.display=='') my_r.display='none'; else my_r.display='';
}

function submenu_show(o,what) {
	var pos = Position.get(o);
	Position.set(what,pos.left+80,pos.top+16);
	showdiv(what);
}

function submenu_hide(what) {
	hidediv(what);
}

function updateimg(img,val){
    document.getElementById(img).src = val;
}

function updatepage(div_name,val){
    document.getElementById(div_name).innerHTML = val;
}


function upd_top_m(param)
{
// Top menju	
AjaxRequest.get({
	'method':'POST', 'url':'/top_menu.php', 'HORDE':''+param+'',
    'onSuccess':function(req) { document.title=req.responseText; }
  });
}

function upd_l_side_m1(param)
{
}

function upd_l_side_m2(param)
{
}

function upd_r_side_m1(param)
{
}

function upd_sp(param)
{
}

function upd_search(param)
{
}

function renew_site(param)
{
}


function lily3_wheel(place)
{
// ritentinsh gaidishanas rezhiimaa
updatepage(place,'<img src="/wheel1.gif"/>');
}

function lily3_set_doc_title(param)
{
// dokumenta objekta TITLE	
AjaxRequest.get({ 
	'method':'POST', 'url':'/ajax_mod/get_title.php', 'HORDE':''+param+'',
    'onSuccess':function(req) { document.title=req.responseText; }
  });
}

function lily3_set_top_m_img(param)
{
// izmainam galveno bildi headeri IMG ID jabuut: img_t_cen
AjaxRequest.get({
	'method':'POST', 'url':'/ajax_mod/ret_top_mid_pic.php', 'HORDE':''+param+'',
    'onSuccess':function(req) { updateimg('img_t_cen',req.responseText); }
  });
}

function lily3_set_center_div(param)
{
// izmainam gcentralo DIV: center_div
AjaxRequest.get({ 
	'method':'POST', 'url':'/ajax_mod/ret_center_text.php', 'HORDE':''+param+'',
    'onSuccess':function(req) { updatepage('main',req.responseText); }
  });
}

function lily3_set_center_main(param)
{
// izmainam gcentralo DIV: center_div
AjaxRequest.get({ 
	'method':'POST', 'url':'/modules/pub_ajax/celojumi.php', 'HORDE':''+param+'',
    'onSuccess':function(req) { updatepage('main',req.responseText); }
  });
}

function lily3_set_site_path(param)
{
// veicam SITE PATH izmainjas	
AjaxRequest.get({
	'method':'POST', 'url':'/modules/w_path/w_path.php', 'HORDE':''+param+'',
    'onSuccess':function(req) { updatepage('menu_path',req.responseText); }
  });
}

function lily3_add_history(param,ev_type)
{
//reg - regular entry
//comp - complex
dhtmlHistory.add(param,ev_type);
}

function lily3_set_left_m1(param)
{
//kresa menucha M1 izmainjas
AjaxRequest.get({
	'method':'POST', 'url':'/ajax_mod/ret_left_menu.php', 'HORDE':''+param+'',
    'onSuccess':function(req) { updatepage('kreisais_menju',req.responseText); }
  });
}

function upd_center_pub(param)
{
// param - new location	
// param_b - current location
lily3_wheel('main');
lily3_set_doc_title(param);
lily3_set_center_div(param);
//lily3_set_left_m1(param_b);
//lily3_set_site_path(param);
//lily3_add_history(param,'reg');
}

function upd_center_celo(param)
{
// param - new location	
// param_b - current location
lily3_wheel('main');
lily3_set_doc_title(param);
lily3_set_center_main(param);
//lily3_set_left_m1(param_b);
//lily3_set_site_path(param);
//lily3_add_history(param,'reg');
}


function get_url_parm()
{
var strHref = window.location.href;

if ( strHref.indexOf("?") > -1 ){
	//dabonam visu kas ir pec jautajumziimes
  var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
  if(strQueryString.indexOf("#")>-1) 
  		new_return=strQueryString.substr(0,strQueryString.length-1);
	else new_return=strQueryString;
  }

else new_return='?';
return new_return;
}

function search_items(theform)
{
 var status = AjaxRequest.submit(
    theform
    ,{
      'onSuccess':function(req){updatepage('center_div',req.responseText) }
    }
  );
//lily3_add_history(theform,'meklet');
updatepage('center_div','<img src="/loading2.gif"/>');
return status;
}

function upd_center_pub_sear(param)
{
lily3_wheel('center_div');
lily3_set_center_div(param);
lily3_add_history(param,'meklet');
}
