// JavaScript Document
function trim(string) {
	return string.replace(/(^\s+)|(\s+$)/g, "");
}
function pas_change(bt) {
var flag;
flag = 0;

if (document.f_reg_pas.pass.value != document.f_reg_pas.pass_conf.value) {
	document.f_reg_pas.pass_conf.focus();
	flag=1;
	}	
if (document.f_reg_pas.pass_conf.value == "") {
	document.f_reg_pas.pass_conf.focus();
	flag=1;
	}	
if (document.f_reg_pas.pass.value == "") {
	document.f_reg_pas.pass.focus();
	flag=1;
	}
if (document.f_reg_pas.pass_old.value == "") {
	document.f_reg_pas.pass_old.focus();
	flag=1;
	}
if (flag == 1) {
	alert("Enter all info");
	}
if (flag == 0) {
	bt.disabled=true;
  	window.setTimeout(function() {bt.disabled=false;}, 10000);
	document.f_reg_pas.submit();
	}
}

function clear_val(t) {
	t.value='';	
}

function open_wind_owner_pass(id){
var w=400;
var h=600;
var x=(screen.width/2)-(w/2);var y=(screen.height/2)-(h/2);
window.open(id, 'comm2' ,config='left='+x+', top='+y+', height='+h+', width='+w+', scrollbars=yes, resizable=no,location=no').focus(); 
}
function open_wind_coment3(id){
var w=600;
var h=165;
var x=(screen.width/2)-(w/2);var y=(screen.height/2)-(h/2);
window.open(id, 'comm2' ,config='left='+x+', top='+y+', height='+h+', width='+w+', scrollbars=no, resizable=no,location=no').focus(); 
}
function open_wind_coment2(id){
var w=600;
var h=100;
var x=(screen.width/2)-(w/2);var y=(screen.height/2)-(h/2);
window.open(id, 'comm2' ,config='left='+x+', top='+y+', height='+h+', width='+w+', scrollbars=no, resizable=no,location=no').focus(); 
}
function but_show_com(b) {
toggle_div('hideshow_aggr');
//opener.document.form_srch.cat1.value=
//alert (opener.document.frek.Button);
var bt = document.frek.Button;
	if (document.getElementById('agr').checked == true) {
		//alert(bt.disabled);		
		bt.disabled=false;
		//alert(bt.disabled);		
	} else {
		bt.disabled=true;
	}
	
}

function ser_private() {
	var forma  = document.getElementById('fser');
	if (forma.ser_obj[0].checked) {
		forma.pg.value="lst";	
	} else {
		forma.pg.value="ser";	
	}		
	forma.submit();
}

var hh=0;
function ad_des_go(id) {
//alert(hh);
	if (hh==0) {
		window.location.href = "index.php?pg=ds&id="+id; 
	}
	hh=0;
}
function ad_des_go_bo(id) {
//alert(hh);
	if (hh==0) {
		window.location.href = "index.php?pg=ds_bo&id="+id; 
	}
	hh=0;
}
function open_ad_mail(id){
var w=350;
var h=200;
var x=(screen.width/2)-(w/2);var y=(screen.height/2)-(h/2);
window.open(id, 'comm' ,config='left='+x+', top='+y+', height='+h+', width='+w+', scrollbars=no, resizable=no,location=no').focus(); 
}
function to_basket_3(id,dv) {
	hh=1;
//alert(hh+"*****");
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
           document.getElementById(dv).innerHTML = '<span class=link_favor>&nbsp;Added</span>';
			//document.getElementById(dv).innerHTML = req.responseText;
        }
    }
	document.getElementById(dv).innerHTML = '<img src=images/loading.gif width=16 height=16>';
    req.open(null, '../includes_all/basket_ajax.php', true);	
    req.send( { id_bsk: id } );
}
function to_basket_2(id,dv) {
	hh=1;
//alert(hh+"*****");
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
           document.getElementById(dv).innerHTML = '<span class=link_favor>&nbsp;Added</span>';
			//document.getElementById(dv).innerHTML = req.responseText;
        }
    }
	document.getElementById(dv).innerHTML = '<img src=images/loading.gif width=16 height=16>';
    req.open(null, 'includes_all/basket_ajax_2.php', true);	
    req.send( { id_bsk: id } );
}
function to_basket(id,dv) {
	hh=1;
//alert(hh+"*****");
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
           document.getElementById(dv).innerHTML = '<span class=link_favor>&nbsp;Added</span>';
			//document.getElementById(dv).innerHTML = req.responseText;
        }
    }
	document.getElementById(dv).innerHTML = '<img src=images/loading.gif width=16 height=16>';
    req.open(null, 'includes_all/basket_ajax.php', true);	
    req.send( { id_bsk: id } );
}

function ser_listing(f,t,t1,t2,t3,t4,t5,t6,t7,t8,t9,ord,lang,ser,dg_pr,dg_val,mg2) {
///alert(f);
	var forma  = document.getElementById(f);
	forma.rec_start.value=t1;
	forma.rec_start_nav.value=t2;
	forma.ct1.value=t3;
	forma.mg.value=t4;
	forma.ip.value=t5;
	forma.sft.value=t6;
	forma.brk.value=t7;
	forma.sdlr.value=t8;
	forma.smc.value=t9;
	forma.ord.value=ord;
	forma.lang.value=lang;
	forma.ser.value=ser;
	forma.dg_price.value=dg_pr;
	forma.dg_valuta.value=dg_val;
	forma.mg2.value=mg2;
	forma.action = t;
	forma.submit();
}
function ser_listing_bask(f,t,t1,t2,t3,t4,t5,t6,t7,t8,t9,bask,lang,ser) {
hh=1;
	var forma  = document.getElementById(f);
	forma.rec_start.value=t1;
	forma.rec_start_nav.value=t2;
	forma.ct1.value=t3;
	forma.mg.value=t4;
	forma.ip.value=t5;
	forma.sft.value=t6;
	forma.brk.value=t7;
	forma.sdlr.value=t8;
	forma.smc.value=t9;
	forma.bask.value=bask;
	forma.lang.value=lang;
	forma.ser.value=ser;
	forma.action = t;
	//alert(t);
	forma.submit();
}
function reg_agree(tt) {
if (tt == 'ch') {
	document.f_reg_info.action = "index.php?pg=reg";
} else {
	if (document.f_reg_info.ad_prnt.checked ) {
		this.print();
	}
	document.f_reg_info.action = "inserts.php?fr=reg_edit";
}
	document.f_reg_info.submit();
}
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;
}
function open_wind(id,nm){
var w=900;
var h=800;
hh=1;
//alert(hh+"*****");
var x=(screen.width/2)-(w/2);var y=(screen.height/2)-(h/2);
window.open(id, nm ,config='left='+x+', top='+y+', height='+h+', width='+w+', scrollbars=yes, resizable=no,location=no').focus(); 
}
function open_wind_coment(id){
var w=656;
var h=370;
var x=(screen.width/2)-(w/2);var y=(screen.height/2)-(h/2);
window.open(id, 'comm' ,config='left='+x+', top='+y+', height='+h+', width='+w+', scrollbars=no, resizable=no,location=no').focus(); 
}
function open_wind_coment_special(id){
var w=656;
var h=350;
var x=(screen.width/2)-(w/2);var y=(screen.height/2)-(h/2);
window.open(id, 'comm' ,config='left='+x+', top='+y+', height='+h+', width='+w+', scrollbars=no, resizable=no,location=no').focus(); 
}
function open_wind_help(id){
var w=700;
var h=750;
var x=(screen.width/2)-(w/2);var y=(screen.height/2)-(h/2);
window.open(id, 'comm' ,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;
}
function srch_go(t) {
	var forma  = document.getElementById(t);
	forma.submit();
}
function srch_id() {
	if (document.f_serid.adid.value != "") {
		document.f_serid.submit();
	}
}
function big_foto_set(t) {
	document.getElementById('ima').src=t;
}
// ubani hide show for broker order
function ubani_hs(selObj)
{
  var selectedValue = selObj.options[selObj.selectedIndex].value;
  var selectedText = selObj.options[selObj.selectedIndex].text;
  if (selectedValue == '1') {

    document.getElementById('ubani_div').style.display = 'block';
	document.getElementById('ubani_div2').style.display = 'none';

  }
  else{
	 document.getElementById('ubani_div').style.display = 'none';
	 document.getElementById('ubani_div2').style.display = 'block';
  }

  
}
// additional information hide show for broker order
function addinfo_hs(selObj)
{
  var selectedValue = selObj.options[selObj.selectedIndex].value;
  var selectedText = selObj.options[selObj.selectedIndex].text;
  if (selectedValue == '2') {

    document.getElementById('ai_bina_div').style.display = 'block';
	document.getElementById('ai_ssx_div').style.display = 'none';
	document.getElementById('ai_ofisi_div').style.display = 'none';
	document.getElementById('ai_comm_div').style.display = 'none';
	document.getElementById('ai_mica_div').style.display = 'none';
	document.getElementById('ai_agaraki_div').style.display = 'none';

  }
  if (selectedValue == '1' | selectedValue == '6') {

    document.getElementById('ai_bina_div').style.display = 'none';
	document.getElementById('ai_ssx_div').style.display = 'block';
	document.getElementById('ai_ofisi_div').style.display = 'none';
	document.getElementById('ai_comm_div').style.display = 'none';
	document.getElementById('ai_mica_div').style.display = 'none';
	document.getElementById('ai_agaraki_div').style.display = 'none';

  }
  if (selectedValue == '3') {

    document.getElementById('ai_bina_div').style.display = 'none';
	document.getElementById('ai_ssx_div').style.display = 'none';
	document.getElementById('ai_ofisi_div').style.display = 'block';
	document.getElementById('ai_comm_div').style.display = 'none';
	document.getElementById('ai_mica_div').style.display = 'none';
	document.getElementById('ai_agaraki_div').style.display = 'none';

  }
  if (selectedValue == '4') {

    document.getElementById('ai_bina_div').style.display = 'none';
	document.getElementById('ai_ssx_div').style.display = 'none';
	document.getElementById('ai_ofisi_div').style.display = 'none';
	document.getElementById('ai_comm_div').style.display = 'block';
	document.getElementById('ai_mica_div').style.display = 'none';
	document.getElementById('ai_agaraki_div').style.display = 'none';

  }
  if (selectedValue == '7') {

    document.getElementById('ai_bina_div').style.display = 'none';
	document.getElementById('ai_ssx_div').style.display = 'none';
	document.getElementById('ai_ofisi_div').style.display = 'none';
	document.getElementById('ai_comm_div').style.display = 'none';
	document.getElementById('ai_mica_div').style.display = 'block';
	document.getElementById('ai_agaraki_div').style.display = 'none';

  }
  
}
//hide show aggreement
function toggle_div(id) {
     var diq = document.getElementById(id).style;
     diq.display=(diq.display=="none") ? "" : "none";
 
}
