function checkBrowser(){
    this.ver=navigator.appVersion
    this.dom=document.getElementById?1:0
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
    this.ie4=(document.all && !this.dom)?1:0;
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
    this.ns4=(document.layers && !this.dom)?1:0;
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
    return this
}

function det(obj){

bw=new checkBrowser();

Element = bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj]:0;

return Element;

}


function chpic(src){
    pic = det('picture');
    pic.src = src;

}

var SelAddValue = '';

function chprice(price,rprice,addvalue){
    pcena = det('pcena');
    pcena.innerHTML = price;

    if (det('rcena')){
        rcena = det('rcena');
        rcena.innerHTML = rprice;
    }

    if(det('option_id_'+SelAddValue))det('option_id_'+SelAddValue).className = '';
    SelAddValue = addvalue;
    det('option_id_'+addvalue).className = 'cell1';
    det('product_option').value=SelAddValue;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}



function toggleDisplay(id) {
  var el = document.getElementById(id);
  var el_img = document.getElementById('_img_'+id);

  if (el!=null) {
    if (el.style.display == 'none') {
        if (el_img!=null) el_img.src='icons/minus.gif';
       el.style.display = '';
     }
    else {
       el.style.display = 'none';
       if (el_img!=null) el_img.src='icons/plus.gif';
    }
  }
}


// Copyright 2006-2007 javascript-array.com

var timeout	= 500;
var closetimer	= 2;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose;







 xajax.callback.global.onRequest = function() {

var _x,_y;
var test1 = document.body.scrollHeight;
var test2 = document.body.offsetHeight
if (test1 > test2) // all but Explorer Mac
{
    _x = document.body.scrollWidth;
    _y = document.body.scrollHeight;
}
else // Explorer Mac;
     //would also work in Explorer 6 Strict, Mozilla and Safari
{
    _x = document.body.offsetWidth;
    _y = document.body.offsetHeight;
}

var x,y;
if (self.pageYOffset) // all except Explorer
{
    x = self.pageXOffset;
    y = self.pageYOffset;
}
else if (document.documentElement && document.documentElement.scrollTop)
    // Explorer 6 Strict
{
    x = document.documentElement.scrollLeft;
    y = document.documentElement.scrollTop;
}
else if (document.body) // all other Explorers
{
    x = document.body.scrollLeft;
    y = document.body.scrollTop;
}

    y_ = (_y/2 + y/2)-100;

    xajax.$('loading').style.top = y_;
    xajax.$('loading').style.display = 'block';

    }

xajax.callback.global.beforeResponseProcessing = function() {xajax.$('loading').style.display='none';}






function showCalendar(id, format) {
  var el = document.getElementById(id);
   if (calendar != null) {
    // we already have some calendar created
    calendar.hide();                 // so we hide it first.
  } else {
    // first-time call, create the calendar.
    var cal = new Calendar(false, null, selected, closeHandler);
    // uncomment the following line to hide the week numbers
    cal.setDisabledHandler(isDisabled);
    cal.weekNumbers = false;
    calendar = cal;                  // remember it in the global var
    cal.setRange(1994, 2020);        // min/max year allowed.
    cal.create();
  }

  calendar.setDateFormat(format);    // set the specified date format
  calendar.parseDate(el.value);      // try to parse the text in field
  calendar.sel = el;                 // inform it what input field we use
  calendar.showAtElement(el);        // show the calendar below it
  return false;
}

function isDisabled(date) {
 return false;
}

function selected(cal, date) {
  cal.sel.value = date; // just update the date in the input field.
  if (cal.sel.id == "sel1" || cal.sel.id == "sel3")
    // if we add this call we close the calendar on single-click.
    // just to exemplify both cases, we are using this only for the 1st
    // and the 3rd field, while 2nd and 4th will still require double-click.
    cal.callCloseHandler();
}
// And this gets called when the end-user clicks on the _selected_ date,
// or clicks on the "Close" button.  It just hides the calendar without
// destroying it.
function closeHandler(cal) {
  cal.hide();                        // hide the calendar
}


function fc(name,dec)
{
  inp=name.value;
  vejica=0;

  if (inp=="") return;
  outt="";
  for (var i=0; i<inp.length; i++) {
    znak=inp.charAt(i);
    if (znak==".") continue;
    else if (znak==",") {
      if (dec==0) break;
      if (vejica>0) break;
      vejica=1;
      outt=outt+znak;
    }
    else if (znak<"0" || znak>"9") break;
    else outt=outt+znak;
  }
  out="";
  if (dec) {
    nule="000000000";
    out=",";
    pos1=outt.indexOf(",");
    if (pos1!=-1) {
      pos2=outt.length;
      if (pos2-pos1-1>dec) pos2=pos1+dec+1;
      out=out+outt.substring(pos1+1,pos2);
      outt=outt.substring(0,pos1);
    }
    out=out+nule.substring(0,3-out.length);
  }
  for (i=outt.length; i>3; i-=3) out="." + outt.substring(i-3,i) + out;
  out=outt.substring(0,i)+out;

  name.value=out;
}


function fcc(val,dec)
{
  inp=val;
  vejica=0;

  if (inp=="") return;
  outt="";
  for (var i=0; i<inp.length; i++) {
    znak=inp.charAt(i);
    if (znak==".") continue;
    else if (znak==",") {
      if (dec==0) break;
      if (vejica>0) break;
      vejica=1;
      outt=outt+znak;
    }
    else if (znak<"0" || znak>"9") break;
    else outt=outt+znak;
  }
  out="";
  if (dec) {
    nule="000000000";
    out=",";
    pos1=outt.indexOf(",");
    if (pos1!=-1) {
      pos2=outt.length;
      if (pos2-pos1-1>dec) pos2=pos1+dec+1;
      out=out+outt.substring(pos1+1,pos2);
      outt=outt.substring(0,pos1);
    }
    out=out+nule.substring(0,3-out.length);
  }
  for (i=outt.length; i>3; i-=3) out="." + outt.substring(i-3,i) + out;
  out=outt.substring(0,i)+out;

  return out;
}


function msgdialog(text){
 	det('msgdialog').innerHTML = text;
 	det('msgdialog').style.display = 'block';
}

function msgbox(text){
 	det('msgbox').innerHTML = text;
 	det('msgbox').style.display = 'block';
 	window.setTimeout(msgbox_close, 1000)
}

function msgbox_close(){
		det('msgbox').style.display = 'none';
}

function msgdialog_close(){
		det('msgdialog').style.display = 'none';
}

