// JavaScript Document
var id_cat=0;
function menu(id,cat) {
	window.parent.id_cat=cat;
	window.parent.document.getElementById("cntr").src = "index.php"+id;
}

function check(id) {
 if (confirm('Delete?')) {
	window.location.href = "inserts.php"+id;
    return true;
 } 
}
function srch_go(t) {
	var forma  = document.getElementById(t);
	forma.submit();
}
function ad_des_go2(id) {
	window.location.href = id; 
}
function cat_menu_out(im,prf) {
	document.getElementById(im).src='imgs/'+prf;
}
function cat_menu_over(im) {
	document.getElementById(im).src='imgs/cat_arr2.gif';
}
function cat_search_submit() {
	i=document.f_cat_search.cat_search.value;
 	document.f_cat_search.submit(); 
}
function ad_des_go(id,pg) {
	window.location.href = "index.php?pg="+pg+"&id_ad="+id; 
}

var selob2;
function select_menu_sub(t) {
	if(selob2) {		
		selob2.className='link_menu_sub';
	}
	selob2=document.getElementById(t);		
	selob2.className='link_menu_sub_on';
}
var selob;
var sel_long_name;
function menu_out(ob,long_name) {
	if (ob.className!='menu_bg'+long_name+'_on_on') {
		ob.className='menu_bg'+long_name;
	}
}
function menu_over(ob,long_name) {
	if (ob.className!='menu_bg'+long_name+'_on_on') {
		ob.className='menu_bg'+long_name+'_on';
	}
}
function select_menu(t,long_name) {	
	if(selob) {		
		selob.className='menu_bg'+sel_long_name;
	}
	selob=document.getElementById(t);	
	selob.className='menu_bg'+long_name+'_on_on';
	sel_long_name=long_name;
}
function doLoad_adds(id_cat,ms,rec_start,rec_start_nav,long_name,subb,srt) {	
	if(subb==0) {
		select_menu('td'+ms,long_name);
	} else {
		select_menu_sub(long_name);
	}
	var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
			//document.getElementById('div_center').innerHTML = req.responseJS.vote;
			document.getElementById('div_center').innerHTML = req.responseText;
        }
    }
	document.getElementById('div_center').innerHTML = '<img src=imgs/loading.gif width=16 height=16>';
    req.open(null, 'includes/ajax.php', true);
    req.send( { id_cat: id_cat, ms: ms,rec_start:rec_start, rec_start_nav:rec_start_nav, srt:srt } );	
}

function trim(string) {
	return string.replace(/(^\s+)|(\s+$)/g, "");
}
var oldtext;
var wt=0;
function isNumericOB(ob){ 
 var x=ob;
 x=(x+1)*1;
 if (x){
    return true
  }else {
    return false
  }
}
function test(ob){
 if (wt){return 0}
 wt=1;
 var a=trim(ob.value);
 if (isNumericOB(a)){
  oldtext=a;
  ob.value=a;
 }else{
  ob.value=oldtext;
  alert("Error")
 }
 wt=0;
}
function varclear(ob){
 oldtext=ob.value;
}

////for number check
function big_foto_set(t) {
	document.getElementById('ima').src=t;
}

function search_form_submit() {
	var forma = document.getElementById('f_search_gl');
	
	if(document.getElementById('ser_inter').checked==true) {
		forma.action = 'http://holmes.ge/search.htm?geo=on&';
		document.getElementById('ser_gl').name = 'q';
		forma.submit();
	} else {
		document.getElementById('cntr').src='index.php?pg=ser_gl&ser_gl='+document.getElementById('ser_gl').value+'&id_cat='+id_cat;
	}
}
function aversi_submit() {
	var forma = document.getElementById('f_aversi');
	forma.action = 'http://www.aversi.ge/search/search.php?geo=on&';
	document.getElementById('av_ser').name = 'comment';
    forma.submit(); 
}

function form_submit(forr) {
	var forma = document.getElementById(forr);
    forma.submit(); 
}

function form_submit2(forr,t1,t2,t3) {
var forma = document.getElementById(forr);
if (t1==1) {
	document.getElementById('cat_sub1').value="";
}
if (t2==1) {
	document.getElementById('cat_sub2').value="";
}
if (t3==1) {
	document.getElementById('cat_sub3').value="";
}
    forma.submit(); 
}

function open_print(id){
var w=600;
var h=600;
var x=(screen.width/2)-(w/2);var y=(screen.height/2)-(h/2);
window.open(id, 'print' ,config='left='+x+', top='+y+', height='+h+', width='+w+', scrollbars=yes, resizable=no,location=no').focus(); 
}

function open_email(id){
var w=800;
var h=335;
var x=(screen.width/2)-(w/2);var y=(screen.height/2)-(h/2);
window.open(id, 'email' ,config='left='+x+', top='+y+', height='+h+', width='+w+', scrollbars=yes, resizable=no,location=no').focus(); 
}

function open_error_email(id){
var w=800;
var h=335;
var x=(screen.width/2)-(w/2);var y=(screen.height/2)-(h/2);
window.open(id, 'email' ,config='left='+x+', top='+y+', height='+h+', width='+w+', scrollbars=yes, resizable=no,location=no').focus(); 
}
function make_active(id,im) {
	document.getElementById(id).src=im;
}

