//hide-show block
function pop(){
//document.getElementById('adv').style.display = document.getElementById('adv').style.display == 'none' ? 'block' : 'none'; return(false);
}

//
function setValues(){}

function addLoadEvent (func) { 
     var oldonload = window.onload; 
     if (typeof window.onload != 'function') { 
         
          window.onload = func; 
     } 
   } 
// replase blocks
function swapBlocks()
{
//var first  = document.getElementById('baze');
//var second = document.getElementById('form');
//second.parentNode.insertBefore(second, first);

setValues();

}

function bitzheight()
{
document.getElementById('matter').style.paddingTop=document.getElementById('bitz').offsetHeight+'px';
}

//addLoadEvent(swapBlocks); 
//addLoadEvent(bitzheight);


 var ln = '';
 var d = document;
 var old_link_html = '';
 var def_tab = 1; checkTabs();

 function checkTabs(){
  var loc = location.href;
  var s = loc.search('#tab');
  if(s!=-1){
   var tab = parseInt(loc.substr(s+4));
   if(tab>0 && tab<5){def_tab = tab;}
  }
 }

/*
 function setTab(n, ajax){

  if(ajax==null){ajax=1;}

  if(n==ln){return;}

  if(ln!=''){
   d.getElementById("top_span_"+ln).className = ''; d.getElementById("bottom_span_"+ln).className = '';
   d.getElementById("top_link_"+ln).className = ''; d.getElementById("bottom_link_"+ln).className = '';
   d.getElementById("top_link_"+ln).innerHTML = old_link_html; d.getElementById("bottom_link_"+ln).innerHTML = old_link_html;
   d.getElementById("tab"+ln).style.display = 'none';
  }
  ln = n;
  d.getElementById("top_span_"+n).className = 'active'; d.getElementById("bottom_span_"+n).className = 'active';

  var link_html = d.getElementById("top_link_"+n).innerHTML;
  old_link_html = link_html;
  d.getElementById("top_link_"+n).innerHTML = '<b>'+link_html+'</b>';
  d.getElementById("bottom_link_"+n).innerHTML = '<b>'+link_html+'</b>';

  var link_class = '';
  if(n==1){link_class = 'lft';}
  d.getElementById("top_link_"+ln).className = ''; d.getElementById("bottom_link_"+ln).className = '';

  var cl = '';
  var clc = [];
  for(var nn=1;nn<=4;nn++){
   cl = 'bor';
   if(nn==1 && n==nn){cl='';}
   if(nn==n-1 || nn==4){cl='';}
   if(nn==4 && nn==n){cl = '';}
   clc[nn-1] = '_'+cl;

   d.getElementById("top_link_"+nn).className = cl;
   d.getElementById("bottom_link_"+nn).className = cl;
  }

  d.getElementById("tab"+n).style.display = 'block';
  d.getElementById("breadcrumb").innerHTML = link_html;

  if(ajax){
   hid_fr.location.href = 'settab.php?tab='+n;
  }

 }
 

 function setFTab(n){
  if(n!=1){setTab(1, 0);}
  setTab(n);
 }
 */

 var def_photo = 1;
 var max_photo = 1;

 function setBigPhoto(fl, num){
  d.getElementById("photo_bigfile").src = fl;
  def_photo = num;
 }

 function setPrevPhoto(){
  if(def_photo==1){return;}
  def_photo--;
  d.getElementById("photo_bigfile").src = phs_ar[def_photo-1];
 }

 function setNextPhoto(){
  if(def_photo==max_photo){return;}
  def_photo++;
  d.getElementById("photo_bigfile").src = phs_ar[def_photo-1];
 }


function sprintf()
{
    var args = arguments;
    var frmt = arguments[0].replace(/%%/g, "\0\0");
    var result = "", prev = 0, index = 0;
    var re = /%(\d+[\$#])?([+-])?('.|0| )?(\d*)(\.\d*)?([bcdfosuxX])/g;
    /*
    * The re.exec() method returns the array with the following properties
    * witch are used in this function
    *    x.index contains the substring position found at the origin string
    *    x[0] contains the found substring
    *    x[1] contains the index specifier (as \d+\$ or \d+#)
    *    x[2] contains the alignment specifier ("+" or "-" or empty)
    *    x[3] contains the padding specifier (space char, "0" or defined as '.)
    *    x[4] contains the width specifier (as \d*)
    *    x[5] contains the floating-point precision specifier (as \.\d*)
    *    x[6] contains the type specifier (as [bcdfosuxX])
    */
    while (x = re.exec(frmt)) {
        index++;
        if (x[1]) var ins = args[x[1].substring(0, x[1].length - 1)];
        else var ins = args[index];
        switch (x[6]) {
        case "b":
            ins = Number(ins).toString(2);
            break;
        case "c":
            ins = String.fromCharCode(ins);
            break;
        case "d":
        case "u":
            ins = Number(ins).toString(10);
            break;
        case "f":
            ins = Number(ins);
            if (x[5].length > 1) ins = ins.toFixed(x[5].substr(1));
            else ins = ins.toExponential(x[4]);
            break;
        case "o":
            ins = Number(ins).toString(8);
            break;
        case "s":
            ins = ins.toString();
            break;
        case "x":
            ins = Number(ins).toString(16);
            break;
        case "X":
            ins = Number(ins).toString(16).toUpperCase();
            break;
        }
        result += frmt.substring(prev, x.index);
        prev = x.index + x[0].length;
        if (!x[3]) x[3] = "";
        result += ins.padding(x[2] + x[4], x[3].substr(x[3].length - 1));
    }
    if (prev < frmt.length) result += frmt.substr(prev);
    result = result.replace(/\0\0/g, "%");
    return result;
}

String.prototype.repeat = function(n)
{
    if (!n || n <= 0) return "";
    if (!this.origin) this.origin = this.valueOf();
    var val = this.repeat(parseInt(n / 2));
    return ((n % 2) ? this.origin : "") + val + val;
}

// The padding functions
String.prototype.padding = function(n, c)
{
    if (!c) c = " ";
    if (c.length > 1) c = c.charAt(0);
    var val = this.valueOf();
    var pad = c.repeat(Math.abs(n) - this.length);
    if (n < 0)
    return val + pad;
    return pad + val;
}


			function getHotelBooking(tobooktab, code, url, hone){

			 if(url){
				if(tobooktab) url += "#tab4";
				else url += "#tab1";
				
			 }

			 if(hone==null){hone=1;}
			 document.sec_hotel_srch.action = url;
			 //alert("url: "+url+"\r\naction: "+document.sec_hotel_srch.action);
			 document.sec_hotel_srch.hotel_code.value = code;
			 document.sec_hotel_srch.hotel_one.value = hone;
			 document.sec_hotel_srch.submit();
			}

			var def_div=0;
			var def_div_cancel=0;

			function showHiddenDiv(n){
			 if(def_div){document.getElementById("det_div"+def_div).style.display="none";}
			 def_div = n;
			 document.getElementById("det_div"+def_div).style.display="block";
			}

			function showHiddenDivCancel(n){
			 if(def_div_cancel){document.getElementById("det_div_cancel"+def_div_cancel).style.display="none";}
			 def_div_cancel = n;
			 document.getElementById("det_div_cancel"+def_div_cancel).style.display="block";
			}


			function closeHiddenDiv(n){
			 if(def_div){document.getElementById("det_div"+def_div).style.display="none"; def_div=0;}
			}

			function closeHiddenDivCancel(n){
			 if(def_div_cancel){document.getElementById("det_div_cancel"+def_div_cancel).style.display="none"; def_div_cancel=0;}
			}


var sub_wd=0;

function startSearch(){
 var obj = document.getElementById("main_wait");
 if(obj!=null){
  obj.style.display = 'block';
  startChWidth(); }
}

function startChWidth(){
 var obj = document.getElementById("sub_wait");
 sub_wd += 3;
 err = 0; if(sub_wd>300){sub_wd=300; err=1;}
 obj.style.width = sub_wd+'px';
 if(err){sub_wd=0;}
 setTimeout("startChWidth();", 50);
}

var chs_checked = 0;
// var max_chs - max allowed of checkboxes
function setOneCheckbox(obj){
 var ret = true;
 if(obj.checked){
  if(chs_checked+1>max_chs){ obj.checked=false; alert('Max qty of checked checkboxes.'); ret=false; }
  else {chs_checked++;}
 } else {
  chs_checked--;
 }
// alert('chs: '+chs_checked+'; max: '+max_chs);
 return ret;
}