var default_login = 'E-mail';
var default_password = 'пароль';
function login_fild()
{
  var login_fild = document.getElementById('login');
  if (login_fild.value == default_login) {
    login_fild.value = '';
  }
}
function login_blur()
{
  var login_fild = document.getElementById('login');
  if (!login_fild.value) {
    login_fild.value = default_login;
  }  
}
function password_fild()
{
  var password_fild = document.getElementById('password');  
  if (password_fild.value == default_password) {
    password_fild.value = '';
  }  
}
function password_blur()
{
  var password_fild = document.getElementById('password');  
  if (!password_fild.value) {
    password_fild.value = default_password;
  }  
}
var ser = '';
function chAmount(new_amount) {

var text='';
switch(new_amount){
	case 'few': text='Few'; break;
	case 'norm': text='Normal'; break;
	case 'many': text='Many'; break;
}

document.getElementById('amount_href').innerHTML=text;
document.getElementById('amount_positions').style.display='none';
document.getElementById('pos1').style.display=''

  // Create new JsHttpRequest object.
  var req = new JsHttpRequest();
  // Code automatically called on load finishing.
  req.onreadystatechange = function() {
    if (req.readyState == 4) {
      // Write result to page element (_RESULT becomes responseJS).
      document.getElementById('cat1').innerHTML =  req.responseJS.ajax_result[0];
      document.getElementById('cat2').innerHTML =  req.responseJS.ajax_result[1];
      document.getElementById('pages').innerHTML =  req.responseJS.ajax_result[2];
      // Write debug information too (output becomes responseText).
      //alert(req.responseText);
    }
  }
  // Prepare request object (automatically choose GET or POST).
  req.open(null, '/ajax/cat'+ser+'Amount/', true);
  // Send data to backend.

  req.send({ amount:new_amount});
}


function chPage(page) {

  // Create new JsHttpRequest object.
  var req = new JsHttpRequest();
  // Code automatically called on load finishing.
  req.onreadystatechange = function() {
    if (req.readyState == 4) {
      // Write result to page element (_RESULT becomes responseJS).
      document.getElementById('cat1').innerHTML =  req.responseJS.ajax_result[0];
      document.getElementById('cat2').innerHTML =  req.responseJS.ajax_result[1];
      document.getElementById('pages').innerHTML =  req.responseJS.ajax_result[2];
      // Write debug information too (output becomes responseText).
      //alert(req.responseText);
    }
  }
  // Prepare request object (automatically choose GET or POST).
  req.open(null, '/ajax/cat'+ser+'Page/', true);
  // Send data to backend.

  req.send({ page:page});
}

function search_ref(ref) {


  // Create new JsHttpRequest object.
  var req = new JsHttpRequest();
  // Code automatically called on load finishing.
  req.onreadystatechange = function() {
    if (req.readyState == 4) {
      if(req.responseJS.ajax_result[0]!=''){
        location.href=req.responseJS.ajax_result[0];
      }else{
        document.getElementById('cat1').innerHTML ="By your inquiry it is found nothing";
      }

      // Write result to page element (_RESULT becomes responseJS).
      
      document.getElementById('cat2').innerHTML =  req.responseJS.ajax_result[1];
      document.getElementById('pages').innerHTML =  req.responseJS.ajax_result[2];
      // Write debug information too (output becomes responseText).
      //alert(req.responseText);
    }
  }
  // Prepare request object (automatically choose GET or POST).
  req.open(null, '/ajax/catSearchRef/', true);
  // Send data to backend.

  req.send({ ref:ref});
}

function do_search_on_cat(location,price_start,price_end,type,stars) {
//alert("wef");
document.getElementById("dosearching").style.display="";
// alert(price);
var a=document.getElementById('type_4kd').checked;
var b=document.getElementById('price_yes').checked;
var c=document.getElementById('loc_4kd').checked;
var d=document.getElementById('stars_4kd').checked;
if(!b){
	price_start=0;
	price_end=0;
}
if(!c){
	location=0;
}
if(!a){
	type=0;
}
if(!d){
	stars=0;
}

  // Create new JsHttpRequest object.
  var req = new JsHttpRequest();
  // Code automatically called on load finishing.
  req.onreadystatechange = function() {
    if (req.readyState == 4) {
      // Write result to page element (_RESULT becomes responseJS).
      document.getElementById('cat1').innerHTML =  req.responseJS.ajax_result[0];
      document.getElementById('cat2').innerHTML =  req.responseJS.ajax_result[1];
      document.getElementById('pages').innerHTML =  req.responseJS.ajax_result[2];
document.getElementById("dosearching").style.display="none";
      // Write debug information too (output becomes responseText).
      //alert(req.responseText);
    }
  }
  // Prepare request object (automatically choose GET or POST).
  req.open(null, '/ajax/catSearch/', true);
  // Send data to backend.

  req.send({ loc:location, price_start:price_start, price_end:price_end, type:type, stars:stars});
}

var ppid=1;
function ChPicture(file,pid){
	//alert(file);
 document.getElementById('pic_big').style.backgroundImage='url('+file+')';
 if(ppid)document.getElementById('border'+ppid).className="objborder2";
 document.getElementById('border'+pid).className="objborder";
 ppid=pid;

}

function nextPic(){
	var id=ppid+1;
	id="pichref"+id;
	//alert(id);
  if(document.getElementById(id)){
  	document.getElementById(id).click();
  }else{
  	document.getElementById('pichref1').click();
  }
  return true;
}


function make_price(price,num)
{
	price.toString;
  var spaceRe = /[ \D]+/g;
  price=price.replace(spaceRe,"");
	switch(num){
	  case 0:sl0.f_setValue(price,1);
           formatPrice(0);
           do_search_on_cat(-1,price,-1,-1,-1);
           break;
 	  case 1:sl1.f_setValue(price,1);
           formatPrice(1);
           do_search_on_cat(-1,-1,price,-1,-1);
           break;

	}
	
}


function show_all(){
  document.getElementById('price_yes').checked=false;
  document.getElementById('loc_4kd').checked=false;
  document.getElementById('type_4kd').checked=false;
  document.getElementById('stars_4kd').checked=false;
	do_search_on_cat(0,0,0,0,0);
}
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;
	try {
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
    var str = '';
    if (isIE && isWin && !isOpera)
    {
  		str += '<object ';
  		for (var i in objAttrs)
  			str += i + '="' + objAttrs[i] + '" ';
  		for (var i in params)
  			str += '><param name="' + i + '" value="' + params[i] + '" /> ';
  		str += '></object>';
    } else {
  		str += '<embed ';
  		for (var i in embedAttrs)
  			str += i + '="' + embedAttrs[i] + '" ';
  		str += '> </embed>';
    }

    document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":

      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "id":
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
function FlashTag(src, width, height)
{
    this.src       = src;
    this.width     = width;
    this.height    = height;
    this.id        = null;
    this.bgcolor   = 'ffffff';
    this.flashVars = null;
}
FlashTag.prototype.toString = function()
{
    var ie = (navigator.appName.indexOf ("Microsoft") != -1) ? 1 : 0;
    var flashTag = new String();
    if (ie)
    {
        flashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
        if (this.id != null)
        {
            flashTag += 'id="'+this.id+'" ';
        }
        //flashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+this.version+'" ';
        flashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" ';
        flashTag += 'width="'+this.width+'" ';
        flashTag += 'height="'+this.height+'">';
        flashTag += '<param name="movie" value="'+this.src+'"/>';
        if (this.opaque) {
          flashTag += '<param name="wmode" value="transparent">';
        }
        flashTag += '<param name="quality" value="high"/>';
        flashTag += '<param name="bgcolor" value="#'+this.bgcolor+'"/>';
        if (this.flashVars != null)
        {
            flashTag += '<param name="flashvars" value="'+this.flashVars+'"/>';
        }
        flashTag += '</object>';
    }
    else
    {
        flashTag += '<embed src="'+this.src+'" ';
        if (this.opaque) {
          flashTag += 'wmode="transparent"';
        }
        flashTag += 'quality="high" '; 
        flashTag += 'bgcolor="#'+this.bgcolor+'" ';
        flashTag += 'width="'+this.width+'" ';
        flashTag += 'height="'+this.height+'" ';
        flashTag += 'type="application/x-shockwave-flash" ';
        if (this.flashVars != null)
        {
            flashTag += 'flashvars="'+this.flashVars+'" ';
        }
        if (this.id != null)
        {
            flashTag += 'name="'+this.id+'" ';
        }
        flashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
        flashTag += '</embed>';
    }
    return flashTag;
}

FlashTag.prototype.write = function(doc)
{
    doc.write(this.toString());
}
var max_width = 800;
var max_height = 600;
function openPhoto(url, width, height)
{
  //window.open(url,"_blank","left=50,top=50,width="+width+",height="+height+",scrollbars=no");  
  var img = document.getElementById('image');
  img.style.left = '50px';
  img.style.top = '50px';
  if (width > max_width) {
    width = 800;
  }
  if (height > max_height) {
    height = 600;
  }
  img.innerHTML = '<a href="javascript: closePhoto()"><img src="'+url+'" width="'+width+'" height="'+height+'"></a>';
  img.style.display = 'block';
}
function closePhoto()
{
  var img = document.getElementById('image');
  img.style.display = 'none';
  img.innerHTML = '';
}
var doajax = true;
function slider (a_init, a_tpl) {

   this.f_setValue  = f_sliderSetValue;
   this.f_getPos    = f_sliderGetPos;

   // register in the global collection
   if (!window.A_SLIDERS)
       window.A_SLIDERS = [];
   this.n_id = window.A_SLIDERS.length;
   window.A_SLIDERS[this.n_id] = this;
   // save config parameters in the slider object
   var s_key;
   if (a_tpl)
       for (s_key in a_tpl)
           this[s_key] = a_tpl[s_key];
   for (s_key in a_init)
       this[s_key] = a_init[s_key];

   this.n_pix2value = this.n_pathLength / (this.n_maxValue - this.n_minValue);
   if (this.n_value == null)
       this.n_value = this.n_minValue;

   this.e_base   = get_element('sl' + this.n_id + 'base');
   this.e_slider = get_element('sl' + this.n_id + 'slider');
   
   // safely hook document/window events
   if (document.onmousemove != f_sliderMouseMove) {
       window.f_savedMouseMove = document.onmousemove;
       document.onmousemove = f_sliderMouseMove;
   }
   if (document.onmouseup != f_sliderMouseUp) {
       window.f_savedMouseUp = document.onmouseup;
       document.onmouseup = f_sliderMouseUp;
   }
   // preset to the value in the input box if available
   var e_input = this.s_form == null
       ? get_element(this.s_name)
       : document.forms[this.s_form]
           ? document.forms[this.s_form].elements[this.s_name]
           : null;
   this.f_setValue(e_input && e_input.value != '' ? e_input.value : null, 1);
   this.e_slider.style.visibility = 'visible';
}

function f_sliderSetValue (n_value, b_noInputCheck) {

  
  if (n_value == null)
       n_value = this.n_value == null ? this.n_minValue : this.n_value;
   if (isNaN(n_value))
       return false;
   // round to closest multiple if step is specified
      
   if (this.n_step)
       n_value = Math.round((n_value - this.n_minValue) / this.n_step) * this.n_step + this.n_minValue;
   // smooth out the result
   if (n_value % 1)
       n_value = Math.round(n_value * 1e5) / 1e5;

   if (n_value < this.n_minValue)
       n_value = this.n_minValue;
   if (n_value > this.n_maxValue)
       n_value = this.n_maxValue;

   this.n_value = n_value;

   // move the slider
   if (this.b_vertical)
       this.e_slider.style.top  = (this.n_pathTop + this.n_pathLength - Math.round((n_value - this.n_minValue) * this.n_pix2value)) + 'px';
   else
       this.e_slider.style.left = (this.n_pathLeft + Math.round((n_value - this.n_minValue) * this.n_pix2value)) + 'px';

   if(document.getElementById('seldiv')){
       if(document.getElementById('sl0slider')==this.e_slider){
         var sleft=((this.n_pathLeft + Math.round((n_value - this.n_minValue) * this.n_pix2value))+10);
         if(sl1){ 
         var prvalw1=sl1.e_slider.style.left;
          prvalw1=prvalw1.substr(0,prvalw1.length-2);}else
          {
            var prvalw1=195;
          } 
          document.getElementById('seldiv').style.left=sleft + 'px';
          var widthp = (prvalw1-sleft)<0 ? 0 : prvalw1-sleft;
          document.getElementById('seldiv').style.width=widthp + 'px';
          //alert(sleft+' '+(prvalw1-sleft));
        }
        if(document.getElementById('sl1slider')==this.e_slider){
          var prvalw=document.getElementById('seldiv').style.left;
          prvalw=prvalw.substr(0,prvalw.length-2); 
          //alert(this.e_slider.style.left);
          var widthp1 = ((this.n_pathLeft + Math.round((n_value - this.n_minValue) * this.n_pix2value))-prvalw)<0 ? 0 : ((this.n_pathLeft + Math.round((n_value - this.n_minValue) * this.n_pix2value))-prvalw);
          document.getElementById('seldiv').style.width=widthp1 + 'px';
          }
   }    
       
       
       // save new value.
   var e_input;
   if (this.s_form == null) {
       e_input = get_element(this.s_name);
       if (!e_input)
           return b_noInputCheck ? null : f_sliderError(this.n_id, "Can not find the input with ID='" + this.s_name + "'.");
   }
   else {
       var e_form = document.forms[this.s_form];
       if (!e_form)
           return b_noInputCheck ? null : f_sliderError(this.n_id, "Can not find the form with NAME='" + this.s_form + "'.");
       e_input = e_form.elements[this.s_name];
       if (!e_input)
           return b_noInputCheck ? null : f_sliderError(this.n_id, "Can not find the input with NAME='" + this.s_name + "'.");
   }
   e_input.value = n_value;
}

// get absolute position of the element in the document
function f_sliderGetPos (b_vertical, b_base) {
   var n_pos = 0,
       s_coord = (b_vertical ? 'Top' : 'Left');
   var o_elem = o_elem2 = b_base ? this.e_base : this.e_slider;

   while (o_elem) {
       n_pos += o_elem["offset" + s_coord];
       o_elem = o_elem.offsetParent;
   }
   o_elem = o_elem2;

   var n_offset;
   while (o_elem.tagName != "BODY") {
       n_offset = o_elem["scroll" + s_coord];
       if (n_offset)
           n_pos -= o_elem["scroll" + s_coord];
       o_elem = o_elem.parentNode;
   }
   return n_pos;
}

function f_sliderMouseDown (n_id,doa) {
   if(doa){
   	doajax = false;
   }
   window.n_activeSliderId = n_id;
   return false;
}

function f_sliderMouseUp (e_event, b_watching) {
   if (window.n_activeSliderId != null) {
    
       var o_slider = window.A_SLIDERS[window.n_activeSliderId];
        //alert(o_slider.e_slider.style.left+' '+o_slider.n_pathLeft);
       o_slider.f_setValue(o_slider.n_minValue + (o_slider.b_vertical
           ? (o_slider.n_pathLength - parseInt(o_slider.e_slider.style.top) + o_slider.n_pathTop)
           : (parseInt(o_slider.e_slider.style.left) - o_slider.n_pathLeft)) / o_slider.n_pix2value);
       if (b_watching) return;
       num=window.n_activeSliderId;
       window.n_activeSliderId = null;

     	if(document.getElementById('price_yes')){
      	document.getElementById('price_yes').checked="checked";
      }
      
      if(doajax){
       make_price(document.getElementById('sliderValue'+num).value,num);
       }else{
       	if(document.getElementById('sliderValue'+num)){
        formatPrice(num);
        }
       }

   }
   if (window.f_savedMouseUp)
       return window.f_savedMouseUp(e_event);
}

function f_sliderMouseMove (e_event) {

   if (!e_event && window.event) e_event = window.event;

   // save mouse coordinates
   if (e_event) {
       window.n_mouseX = e_event.clientX + f_scrollLeft();
       window.n_mouseY = e_event.clientY + f_scrollTop();
   }

   // check if in drag mode
   if (window.n_activeSliderId != null) {
       var o_slider = window.A_SLIDERS[window.n_activeSliderId];

       var n_pxOffset;
       if (o_slider.b_vertical) {
           var n_sliderTop = window.n_mouseY - o_slider.n_sliderHeight / 2 - o_slider.f_getPos(1, 1) - 3;
           // limit the slider movement
           if (n_sliderTop < o_slider.n_pathTop)
               n_sliderTop = o_slider.n_pathTop;
           var n_pxMax = o_slider.n_pathTop + o_slider.n_pathLength;
           if (n_sliderTop > n_pxMax)
               n_sliderTop = n_pxMax;
           o_slider.e_slider.style.top = n_sliderTop + 'px';
           n_pxOffset = o_slider.n_pathLength - n_sliderTop + o_slider.n_pathTop;
       }
       else {
           var n_sliderLeft = window.n_mouseX - o_slider.n_sliderWidth / 2 - o_slider.f_getPos(0, 1) - 3;
           // limit the slider movement
           if (n_sliderLeft < o_slider.n_pathLeft)
               n_sliderLeft = o_slider.n_pathLeft;
           var n_pxMax = o_slider.n_pathLeft + o_slider.n_pathLength;
           if (n_sliderLeft > n_pxMax)
               n_sliderLeft = n_pxMax;
           o_slider.e_slider.style.left = n_sliderLeft + 'px';
           n_pxOffset = n_sliderLeft - o_slider.n_pathLeft;
       }
       if (o_slider.b_watch)
            f_sliderMouseUp(e_event, 1);

       return false;
   }

   if (window.f_savedMouseMove)
       return window.f_savedMouseMove(e_event);
}

// get the scroller positions of the page
function f_scrollLeft() {
   return f_filterResults (
       window.pageXOffset ? window.pageXOffset : 0,
       document.documentElement ? document.documentElement.scrollLeft : 0,
       document.body ? document.body.scrollLeft : 0
   );
}
function f_scrollTop() {
   return f_filterResults (
       window.pageYOffset ? window.pageYOffset : 0,
       document.documentElement ? document.documentElement.scrollTop : 0,
       document.body ? document.body.scrollTop : 0
   );
}
function f_filterResults(n_win, n_docel, n_body) {
   var n_result = n_win ? n_win : 0;
   if (n_docel && (!n_result || (n_result > n_docel)))
       n_result = n_docel;
   return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function f_sliderError (n_id, s_message) {
   alert("Slider #" + n_id + " Error:\n" + s_message);
   window.n_activeSliderId = null;
}

get_element = document.all ?
   function (s_id) { return document.all[s_id] } :
   function (s_id) { return document.getElementById(s_id) };

var prval;
var pr;
   


function formatPrice(num)
{
	
 
  var element=document.getElementById('sliderValue'+num);
	var price=element.value;
	price.toString;
  var spaceRe = / +/g;
  price=price.replace(spaceRe,"");
	var len=price.length;
	var lenr=Math.ceil(price.length/3);
	var n_pr='';
	var start=0;
	var end=0;
	for(var i=1;i<=lenr;i++){
		start = len-i*3<0 ? 0 : len-i*3;
		end = len-i*3<0 ? 3+len-i*3 : 3;
		n_pr=price.substr(start,end)+' '+n_pr;
	}
	n_pr=n_pr.replace(/\s+$/,"");
	
	switch(num){
    case 0: prval=sl0.e_slider.style.left;
            prval=prval.substr(0,prval.length-2); 
            pr=sl0.n_value;
            sl1.n_pathLeft=parseInt(prval)+9; 
            sl1.n_pathLength=195-prval;
            sl1.n_minValue=pr;
            break;
    case 1: prval=sl1.e_slider.style.left;
            prval=prval.substr(0,prval.length-2); 
            pr=sl1.n_value;
            sl0['n_pathLength']=prval-10;
            sl0['n_maxValue']=pr;
            break;
  }
	
	
	element.value=n_pr;
	
}











function checkKey(evt,id)
{
	var key;
	//pref = '';
	var el=document.getElementById(id);
	var cur_pos=getCaretPosition(el);
	var prev_val=el.value;
	var chk0=0

	if(brows=='Firefox'||brows=='Netscape'||brows=='Mozilla')
	{
		key=evt.charCode;
		if(key==0)
		{
			key=evt.keyCode;
		}
	}
	else
	{
		key=evt.keyCode;
	}

	if((key<48&&key!=46&&key!=8&&key!=37&&key!=39)||key>57||(key==48&&prev_val==''&&!chk0)||(cur_pos==0&&key==48&&!chk0))
	{
		return false;
	}
  
	//setPrice(val,num);
	return true;
}

function getCaretPosition(el)
{
	if (document.selection)
	{
		// IE
		var range = document.selection.createRange();
		range.moveStart('textedit', -1);
		return range.text.length;
	}
	else if (el.selectionStart)
	{
		// Gecko
		return el.selectionStart;
	}
	return el.value.length-1;
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
var brows=BrowserDetect.browser;

function search_open()
{
  document.getElementById('search_main').style.display = 'block';
}
function search_close()
{
  close_local();
  close_type();
  close_stars();
  document.getElementById('search_main').style.display = 'none';
}
function open_local()
{
  close_stars();
  close_type();
  document.getElementById('search_local').style.display = 'block';
}
function close_local()
{
  if (document.getElementById('search_local'))
    document.getElementById('search_local').style.display = 'none';  
}


function open_type()
{
  close_local();
  close_stars();
  document.getElementById('search_type').style.display = 'block'; 
}
function close_type()
{
  if (document.getElementById('search_type'))
    document.getElementById('search_type').style.display = 'none';   
}


function open_stars()
{
  close_local();
  close_type();
  document.getElementById('search_stars').style.display = 'block'; 
}
function close_stars()
{
  if (document.getElementById('search_stars'))
    document.getElementById('search_stars').style.display = 'none';   
}


