var OK = false;
var remove_func;
var set_focus = '';
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isIE6 = (navigator.userAgent.indexOf("MSIE 6.0") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
var SiteUrl = 'http://www.swisstimeclub.ru/';
/// JsHttpRequest
function JsHttpRequest(){var i=this;i.onreadystatechange=null;i.readyState=0;i.responseText=null;i.responseXML=null;i.status=200;i.statusText="OK";i.responseJS=null;i.caching=false;i.loader=null;i.session_name="PHPSESSID";i._0=null;i._1=[];i._3=null;i._5={inv_form_el:"Invalid FORM element detected: name=%, tag=%",must_be_single_el:"If used, <form> must be a single HTML element in the list.",js_invalid:"JavaScript code generated by backend is invalid!\n%",url_too_long:"Cannot use so long query with GET request (URL is larger than % bytes)",unk_loader:"Unknown loader: %",no_loaders:"No loaders registered at all, please check JsHttpRequest.LOADERS array",no_loader_matched:"Cannot find a loader which may process the request. Notices are:\n%",no_headers:"Method setRequestHeader() cannot work together with the % loader."};i.abort=function(){with(this){if(_0&&_0.abort){_0.abort()}_6();if(readyState==0){return}if(readyState==1&&!_0){readyState=0;return}_4(4,true)}};i.open=function(a,b,c,f,d){with(this){try{if(document.location.search.match(new RegExp("[&?]"+session_name+"=([^&?]*)"))||document.cookie.match(new RegExp("(?:;|^)\\s*"+session_name+"=([^;]*)"))){b+=(b.indexOf("?")>=0?"&":"?")+session_name+"="+this.escape(RegExp.$1)}}catch(e){}_3={method:(a||"").toUpperCase(),url:b,asyncFlag:c,username:f!=null?f:"",password:d!=null?d:""};_0=null;_4(1,true);return true}};i.send=function(a){if(!this.readyState){return}this._4(1,true);this._0=null;var b=[];var c=[];if(!this._7(a,null,b,c)){return}var f=null;if(this.caching&&!c.length){f=this._3.username+":"+this._3.password+"@"+this._3.url+"|"+b+"#"+this._3.method;var d=JsHttpRequest.CACHE[f];if(d){this._8(d[0],d[1]);return false}}var j=(this.loader||"").toLowerCase();if(j&&!JsHttpRequest.LOADERS[j]){return this._2("unk_loader",j)}var k=[];var g=JsHttpRequest.LOADERS;for(var l in g){var h=g[l].loader;if(!h){continue}if(j&&l!=j){continue}var m=new h(this);JsHttpRequest.extend(m,this._3);JsHttpRequest.extend(m,{queryText:b.join("&"),queryElem:c,id:(new Date().getTime())+""+JsHttpRequest.COUNT++,hash:f,span:null});var n=m.load();if(!n){this._0=m;JsHttpRequest.PENDING[m.id]=this;return true}if(!j){k[k.length]="- "+l.toUpperCase()+": "+this._9(n)}else{return this._2(n)}}return l?this._2("no_loader_matched",k.join("\n")):this._2("no_loaders")};i.getAllResponseHeaders=function(){with(this){return _0&&_0.getAllResponseHeaders?_0.getAllResponseHeaders():[]}};i.getResponseHeader=function(a){with(this){return _0&&_0.getResponseHeader?_0.getResponseHeader():[]}};i.setRequestHeader=function(a,b){with(this){_1[_1.length]=[a,b]}};i._8=function(a,b){with(this){if(caching&&_0){JsHttpRequest.CACHE[_0.hash]=[a,b]}if(a!==null||b!==null){status=4;responseText=responseXML=a;responseJS=b}else{status=500;responseText=responseXML=responseJS=null}_4(2);_4(3);_4(4);_6()}};i._9=function(a){var b=0,c=0,f=this._5[a[0]];while((c=f.indexOf("%",c))>=0){var d=a[++b]+"";f=f.substring(0,c)+d+f.substring(c+1,f.length);c+=1+d.length}return f};i._2=function(a){a=this._9(typeof(a)=="string"?arguments:a);a="JsHttpRequest: "+a;if(!window.Error){throw a;}else{if((new Error(1,"test")).description=="test"){throw new Error(1,a);}else{throw new Error(a);}}};i._7=function(a,b,c,f){if(b==null){b=""}if(a instanceof Object){var d=false;for(var j in a){var k=a[j];if(k instanceof Function){continue}var g=b?b+"["+this.escape(j)+"]":this.escape(j);var l=k&&k.parentNode&&k.parentNode.appendChild&&k.tagName;if(l){var h=k.tagName.toUpperCase();if(h=="FORM"){d=true}else{if(h=="INPUT"||h=="TEXTAREA"||h=="SELECT"){}else{return this._2("inv_form_el",(e.name||""),e.tagName)}}f[f.length]={name:g,e:k}}else{if(k instanceof Object){this._7(k,g,c,f)}else{if(k===null){continue}c[c.length]=g+"="+this.escape(""+k)}}if(d&&f.length>1){return this._2("must_be_single_el")}}}else{c[c.length]=a}return true};i._6=function(){var a=this._0;if(!a){return}JsHttpRequest.PENDING[a.id]=false;var b=a.span;if(!b){return}a.span=null;var c=function(){b.parentNode.removeChild(b)};JsHttpRequest.setTimeout(c,50)};i._4=function(a,b){with(this){if(b){status=statusText=responseJS=null;responseText=""}readyState=a;if(onreadystatechange){onreadystatechange()}}};i.escape=function(a){return escape(a).replace(new RegExp("\\+","g"),"%2B")}}JsHttpRequest.COUNT=0;JsHttpRequest.MAX_URL_LEN=2000;JsHttpRequest.CACHE={};JsHttpRequest.PENDING={};JsHttpRequest.LOADERS={};JsHttpRequest._b=function(){};JsHttpRequest.TIMEOUTS={s:window.setTimeout,c:window.clearTimeout};JsHttpRequest.setTimeout=function(a,b){window.JsHttpRequest_tmp=JsHttpRequest.TIMEOUTS.s;if(typeof(a)=="string"){c=window.JsHttpRequest_tmp(a,b)}else{var c=null;var f=function(){a();delete JsHttpRequest.TIMEOUTS[c]};c=window.JsHttpRequest_tmp(f,b);JsHttpRequest.TIMEOUTS[c]=f}window.JsHttpRequest_tmp=null;return c};JsHttpRequest.clearTimeout=function(a){window.JsHttpRequest_tmp=JsHttpRequest.TIMEOUTS.c;delete JsHttpRequest.TIMEOUTS[a];var b=window.JsHttpRequest_tmp(a);window.JsHttpRequest_tmp=null;return b};JsHttpRequest.query=function(a,b,c,f){var d=new this();d.caching=!f;d.onreadystatechange=function(){if(d.readyState==4){c(d.responseJS,d.responseText)}};var j=null;if(a.match(/^((\w+)\.)?(GET|POST)\s+(.*)/i)){d.loader=RegExp.$2?RegExp.$2:null;j=RegExp.$3;a=RegExp.$4}d.open(j,a,true);d.send(b)};JsHttpRequest.dataReady=function(a){var b=this.PENDING[a.id];delete this.PENDING[a.id];if(b){b._8(a.text,a.js)}else{if(b!==false){throw"dataReady(): unknown pending id: "+a.id;}}};JsHttpRequest.extend=function(a,b){for(var c in b){a[c]=b[c]}};JsHttpRequest.LOADERS.xml={loader:function(d){JsHttpRequest.extend(d._5,{xml_no:"Cannot use XMLHttpRequest or ActiveX loader: not supported",xml_no_diffdom:"Cannot use XMLHttpRequest to load data from different domain %",xml_no_headers:"Cannot use XMLHttpRequest loader or ActiveX loader, POST method: headers setting is not supported, needed to work with encodings correctly",xml_no_form_upl:"Cannot use XMLHttpRequest loader: direct form elements using and uploading are not implemented"});this.load=function(){if(this.queryElem.length){return["xml_no_form_upl"]}if(this.url.match(new RegExp("^([a-z]+)://([^\\/]+)(.*)","i"))){if(RegExp.$2.toLowerCase()==document.location.hostname.toLowerCase()){this.url=RegExp.$3}else{return["xml_no_diffdom",RegExp.$2]}}var a=null;if(window.XMLHttpRequest){try{a=new XMLHttpRequest()}catch(e){}}else{if(window.ActiveXObject){try{a=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}if(!a){try{a=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){}}}}if(!a){return["xml_no"]}var b=window.ActiveXObject||a.setRequestHeader;if(!this.method){this.method=b?"POST":"GET"}if(this.method=="GET"){if(this.queryText){this.url+=(this.url.indexOf("?")>=0?"&":"?")+this.queryText}this.queryText="";if(this.url.length>JsHttpRequest.MAX_URL_LEN){return["url_too_long",JsHttpRequest.MAX_URL_LEN]}}else{if(this.method=="POST"&&!b){return["xml_no_headers"]}}this.url+=(this.url.indexOf("?")>=0?"&":"?")+"JsHttpRequest="+(d.caching?"0":this.id)+"-xml";var c=this.id;a.onreadystatechange=function(){if(a.readyState!=4){return}a.onreadystatechange=JsHttpRequest._b;d.status=null;try{d.status=a.status;d.responseText=a.responseText}catch(e){}if(!d.status){return}try{eval("JsHttpRequest._a = function(id) { var d = "+d.responseText+"; d.id = id; JsHttpRequest.dataReady(d); }")}catch(e){return d._2("js_invalid",d.responseText)}JsHttpRequest._a(c);JsHttpRequest._a=null};a.open(this.method,this.url,true,this.username,this.password);if(b){for(var f=0;f<d._1.length;f++){a.setRequestHeader(d._1[f][0],d._1[f][1])}a.setRequestHeader("Content-Type","application/octet-stream")}a.send(this.queryText);this.span=null;this.xr=a;return null};this.getAllResponseHeaders=function(){return this.xr.getAllResponseHeaders()};this.getResponseHeader=function(a){return this.xr.getResponseHeader(a)};this.abort=function(){this.xr.abort();this.xr=null}}};JsHttpRequest.LOADERS.script={loader:function(j){JsHttpRequest.extend(j._5,{script_only_get:"Cannot use SCRIPT loader: it supports only GET method",script_no_form:"Cannot use SCRIPT loader: direct form elements using and uploading are not implemented"});this.load=function(){if(this.queryText){this.url+=(this.url.indexOf("?")>=0?"&":"?")+this.queryText}this.url+=(this.url.indexOf("?")>=0?"&":"?")+"JsHttpRequest="+this.id+"-script";this.queryText="";if(!this.method){this.method="GET"}if(this.method!=="GET"){return["script_only_get"]}if(this.queryElem.length){return["script_no_form"]}if(this.url.length>JsHttpRequest.MAX_URL_LEN){return["url_too_long",JsHttpRequest.MAX_URL_LEN]}if(j._1.length){return["no_headers","SCRIPT"]}var a=this,b=document,c=null,f=b.body;if(!window.opera){this.span=c=b.createElement("SCRIPT");var d=function(){c.language="JavaScript";if(c.setAttribute){c.setAttribute("src",a.url)}else{c.src=a.url}f.insertBefore(c,f.lastChild)}}else{this.span=c=b.createElement("SPAN");c.style.display="none";f.insertBefore(c,f.lastChild);c.innerHTML="Workaround for IE.<script></script>";var d=function(){c=c.getElementsByTagName("SCRIPT")[0];c.language="JavaScript";if(c.setAttribute){c.setAttribute("src",a.url)}else{c.src=a.url}}}JsHttpRequest.setTimeout(d,10);return null}}};JsHttpRequest.LOADERS.form={loader:function(r){JsHttpRequest.extend(r._5,{form_el_not_belong:"Element \"%\" does not belong to any form!",form_el_belong_diff:"Element \"%\" belongs to a different form. All elements must belong to the same form!",form_el_inv_enctype:"Attribute \"enctype\" of the form must be \"%\" (for IE), \"%\" given."});this.load=function(){var g=this;if(!g.method){g.method="POST"}g.url+=(g.url.indexOf("?")>=0?"&":"?")+"JsHttpRequest="+g.id+"-form";if(r._1.length){return["no_headers","FORM"]}if(g.method=="GET"){if(g.queryText){g.url+=(g.url.indexOf("?")>=0?"&":"?")+g.queryText}if(g.url.length>JsHttpRequest.MAX_URL_LEN){return["url_too_long",JsHttpRequest.MAX_URL_LEN]}var l=g.url.split("?",2);g.url=l[0];g.queryText=l[1]||""}var h=null;var m=false;if(g.queryElem.length){if(g.queryElem[0].e.tagName.toUpperCase()=="FORM"){h=g.queryElem[0].e;m=true;g.queryElem=[]}else{h=g.queryElem[0].e.form;for(var n=0;n<g.queryElem.length;n++){var i=g.queryElem[n].e;if(!i.form){return["form_el_not_belong",i.name]}if(i.form!=h){return["form_el_belong_diff",i.name]}}}if(g.method=="POST"){var s="multipart/form-data";var t=(h.attributes.encType&&h.attributes.encType.nodeValue)||(h.attributes.enctype&&h.attributes.enctype.value)||h.enctype;if(t!=s){return["form_el_inv_enctype",s,t]}}}var o=h&&(h.ownerDocument||h.document)||document;var q="jshr_i_"+g.id;var p=g.span=o.createElement("DIV");p.style.position="absolute";p.style.visibility="hidden";p.innerHTML=(h?"":"<form"+(g.method=="POST"?" enctype=\"multipart/form-data\" method=\"post\"":"")+"></form>")+"<iframe name=\""+q+"\" id=\""+q+"\" style=\"width:0px; height:0px; overflow:hidden; border:none\"></iframe>";if(!h){h=g.span.firstChild}o.body.insertBefore(p,o.body.lastChild);var u=function(a,b){var c=[];var f=a;if(a.mergeAttributes){var f=o.createElement("form");f.mergeAttributes(a,false)}for(var d=0;d<b.length;d++){var j=b[d][0],k=b[d][1];c[c.length]=[j,f.getAttribute(j)];f.setAttribute(j,k)}if(a.mergeAttributes){a.mergeAttributes(f,false)}return c};var v=function(){top.JsHttpRequestGlobal=JsHttpRequest;var a=[];if(!m){for(var b=0,c=h.elements.length;b<c;b++){a[b]=h.elements[b].name;h.elements[b].name=""}}var f=g.queryText.split("&");for(var b=f.length-1;b>=0;b--){var d=f[b].split("=",2);var j=o.createElement("INPUT");j.type="hidden";j.name=unescape(d[0]);j.value=d[1]!=null?unescape(d[1]):"";h.appendChild(j)}for(var b=0;b<g.queryElem.length;b++){g.queryElem[b].e.name=g.queryElem[b].name}var k=u(h,[["action",g.url],["method",g.method],["onsubmit",null],["target",q]]);h.submit();u(h,k);for(var b=0;b<f.length;b++){h.lastChild.parentNode.removeChild(h.lastChild)}if(!m){for(var b=0,c=h.elements.length;b<c;b++){h.elements[b].name=a[b]}}};JsHttpRequest.setTimeout(v,100);return null}}};

function show_catalog(){
   var link = ($w('mark').value) ? '/'+$w('mark').value+'/catalogue/' : '/catalogue/';
   link += ($w('mech').value) ? '?mech='+$w('mech').value : '';
   link += ($w('sex').value) ? ($w('mech').value?'&':'?')+'sex='+$w('sex').value : '';
   if (!$w('mark').value && !$w('mech').value && !$w('sex').value) close_message('info','Выберите хотя бы один параметр поиска');
   else location.href = link;
   //$w('filter_data').submit();
}

function $w(id){ return document.getElementById(id); }

function _key(event)	{

if (event) {	 var k = event.keyCode;
	 if(k==0) { k=event.charCode; return false; }
	 if(k==13 && $w('loading-box').style.display == 'block')  {
	 		$w('loading-box').style.display = 'none';
		    if (OK==true) remove_func();
		    if (set_focus != '' && set_focus != undefined) {
		    	set_focus.focus();
				if (set_focus!=null && set_focus.className == 'inp_text') set_focus.className = 'inp_text_err';
		    	}
		    return false;
		    }
	 if(k==27) {
		    if ($w('loading-box').style.display == 'block') $w('loading-box').style.display = 'none';
		    if (set_focus != '' && set_focus != undefined) {		    	set_focus.focus();
				if (set_focus!=null && set_focus.className == 'inp_text') set_focus.className = 'inp_text_err';
		    	}
		   return false;
		   }
	 if(k==37 && event.ctrlKey && $w('prev_page'))  {
		   // left
		    if ($w('prev_page').href.length>0) location.href = $w('prev_page').href;
	 }
	 if(k==39 && event.ctrlKey && $w('next_page')) {
		   // right
		   if ($w('next_page').href.length>0) location.href = $w('next_page').href;
	 }
}

}


function show_message(text){
	if (text==undefined) text = 'Обработка данных';
	if (!$w('loading-box')) return false;
	var top = (document.body.scrollTop>0) ? document.body.scrollTop : document.documentElement.scrollTop;
	$w('loading-box').style.width = '270px';
	$w('loading-box').style.textAlign = 'center';
	$w('loading-box').style.display = 'block';
    	$w('loading-actions').style.display = 'none';
    	$w('loading-actions-confirm').style.display = 'none';
	if (self.screen) $w('loading-box').style.top = (parseInt(top,10)+(screen.height/2)-200)+'px';
	else $w('loading-box').style.top = (parseInt(top,10)+(document.body.clientHeight/2)-90)+'px';
	$w('loading-box').style.left = ((document.body.clientWidth/2)-100)+'px';
   	$w('loading-text').style.textAlign = 'center';
	var new_height = $w('loading-box').offsetHeight;
	var top = (document.body.scrollTop>0) ? document.body.scrollTop : document.documentElement.scrollTop;
	//var scr_height=0; if (self.screen) scr_height = screen.height
	//else if (self.java) { var jkit = java.awt.Toolkit.getDefaultToolkit(); var scrsize = jkit.getScreenSize(); scr_height = scrsize.height;	}
	//var body_height = (scr_height>0 && document.body.clientHeight>scr_height) ? scr_height-150 : document.body.clientHeight;
	body_height = document.body.clientHeight;
	var new_top = (parseInt(top,10)+(body_height/2)-(new_height/2)-30);
	if (!isIE6) $w('loading-box').style.top = new_top+'px';

	var new_width = $w('loading-box').offsetWidth;
	$w('loading-box').style.left = ((document.body.clientWidth/2)-(new_width/2))+'px';

	$w('loading-img').style.display = '';
	$w('loading-text').innerHTML = text+', пожалуйста подождите...';
}

function close_message(status, text, focus){
	if (!$w('loading-box')) { if (text!=undefined) alert(text); return true; }
    OK = false;
	$w('loading-box').style.display = 'block';
	$w('loading-box').style.textAlign = 'left';
	$w('loading-text').style.textAlign = 'center';
	$w('loading-box').style.left = '0px';

	if (isIE6) {
		$w('loading-box').style.width = '270px';
		$w('loading-box').style.height = '70px';
	}
	else {
		$w('loading-box').style.width = 'auto';
		$w('loading-box').style.height = 'auto';
		$w('loading-box').style.maxWidth = '600px';
		}


   	$w('loading-actions').style.display = 'none';
   	$w('loading-actions-confirm').style.display = 'none';

	if (status==undefined) {
		$w('loading-box').style.display = 'none';
		return false;
		}
	else if (status=='info') {
		$w('loading-img').style.display = 'none';
		if (text==undefined) text = 'Информация';
		$w('loading-text').innerHTML = '<br /><img class="image" src="/_admincp/_design/img/icons/warning.png" />&nbsp;'+text+'';
	    $w('loading-actions').style.display = '';
	} else if (status=='bas') {
		$w('loading-text').style.textAlign = 'left';
		$w('loading-img').style.display = 'none';
		if (text==undefined) text = 'Информация';
		if (isIE) $('#loading-text').css({display: ''}).html(text);
		else $('#loading-text').css({display: 'none'}).html(text).fadeIn('slow');
	    $w('loading-actions').style.display = 'none';
	} else if (status=='sravnit') {
		$w('loading-text').style.textAlign = 'left';
		$w('loading-img').style.display = 'none';
		var srv_val = getCookie('sravnit');
		if (srv_val==undefined || !srv_val || srv_val == null) srv_val = '';
		var elms = srv_val.split(',');
		if (text==undefined) text = '<div class="catalog-item-popup"><p>Часы успешно добавлены к сравнению'+(elms.length>1?'<br />Всего отложено часов: <b>'+(elms.length-1)+'</b>':'')+
		'</p><div class="popup-btn clearfix"><input type="button" class="contents-favorit-btn btn" onclick="location.href = \''+SiteUrl+'favorite_products/\'; return false;" />'+
		'<input type="button" class="proceed-order-btn brn" onclick="$(\'#loading-box\').fadeOut(\'slow\'); return false;" /></div></div>';
		if (isIE) $('#loading-text').css({display: ''}).html(text);
		else $('#loading-text').css({display: 'none'}).html(text).fadeIn('slow');
	    $w('loading-actions').style.display = 'none';
	} else if (status=='confirm') {
		OK = true;
		$w('loading-img').style.display = 'none';
		if (text==undefined) text = 'Информация';
		$w('loading-text').innerHTML = '<br />&nbsp;'+text+'';     //<img class="image" src="/_admincp/_design/img/icons/warning.png" />
	    $w('loading-actions').style.display = 'none';
	    $w('loading-actions-confirm').style.display = '';
	}
	else if (status=='error') {
		$w('loading-text').style.textAlign = 'left';
		$w('loading-img').style.display = 'none';
		if (text==undefined) text = 'Произошла ошибка';
		$w('loading-text').innerHTML = '<br /><img class="image" src="/_admincp/_design/img/icons/error.png" />&nbsp;'+text+'';
	    $w('loading-actions').style.display = '';
	}

	var new_height = $w('loading-box').offsetHeight;
//	if (navigator.appName == 'Microsoft Internet Explorer' && /MSIE 6.0/i.test(navigator.userAgent)) var top = 0;
//	else var top = (document.body.scrollTop>0) ? document.body.scrollTop : document.documentElement.scrollTop;

	var new_height = $w('loading-box').offsetHeight;
	var top = (document.body.scrollTop>0) ? document.body.scrollTop : document.documentElement.scrollTop;
	//var half_screen_height = (screen.height>0) ? (screen.height/2)-parseInt(screen.height/8) : (document.body.clientHeight/2);
	var half_screen_height = document.body.clientHeight/2;
	if (isIE6) { half_screen_height = (screen.height>0) ? (screen.height/2)-parseInt(screen.height/8) : half_screen_height;  }
	$w('loading-box').style.top = (parseInt(top,10)+(half_screen_height)-(new_height/2)-30)+'px';
	var new_width = $w('loading-box').offsetWidth;
   	$w('loading-box').style.left = ((document.body.clientWidth/2)-(new_width/2))+'px';

	if (focus!=undefined && $w(focus)!=null) {		set_focus = $w(focus);
        	if (set_focus!=null && set_focus.className == 'inp_text') { set_focus.className = 'inp_text_err'; }
		}
	else set_focus = '';
	$w('loading-box').focus();

}


// ****************************************** //
// ********* <<<<<<   ФИЛЬТР		   ****** //
// ****************************************** //
function execute_filter(){	var brend = $w('brend');
	var catalog1 = $w('catalog1');
	var catalog2 = $w('catalog2');
	if (brend.value == 0) close_message('info', 'Необходимо выбрать производителя', 'brend');
	else if (catalog1.value == 0) close_message('info', 'Необходимо выбрать категорию товара', 'catalog1');
	else if (brend.value == 'all' && catalog1.value == 'all') close_message('info', 'Необходимо выбрать подкатегорию товара', 'catalog2');
	else document.filter.submit();
}




// ****************************************** //
// **** <<<<<< КОРЗИНА ПОЛЬЗОВАТЕЛЯ    ****** //
// ****************************************** //

function update_basket(text){
	$("img[alt=basket_icon]").attr('alt','basket_icon_del').clone().attr('title',text).attr('alt','basket_icon').appendTo(".sba");
	$("img[alt=basket_icon_del]").remove();
	$("img[alt=basket_icon]").tooltip({
		offset: [5, 2],
		effect: 'slide',
		layout: '<div><div class="tooltip-top"><div class="tooltip-bottom"><div class="tooltip-repeat"><div class="tooltip-icon tooltip-inner"></div></div></div></div></div>',
		tipInner: 'tooltip-inner'
	});
	//if (isIE6) DD_belatedPNG.fix('.pngfix');
}

function check_basket(){var result = true;
	if ($w('empty_shopping_cart')!=null) result = ($w('empty_shopping_cart').style.display == '') ? false : true;
	if (result == false) close_message('info', 'Ваша корзина пуста');
return result;}

// добавить позицию в корзину
function add_product(sid, catalog_id, id, price, action) {
  var spec_price = 1;
  if ($w('new_pr'+id) && $w('p2_'+id) && $w('p1_'+id)) {
  	if (!$w('p1_'+id).checked && !$w('p2_'+id).checked) { close_message('info','Выберите пожалуйста цену'); return false;}
  	if ($w('p2_'+id).checked) if (!isNaN(parseInt($w('new_pr'+id).innerHTML.replace(/[^0-9]/ig,'')))) {
  			price = parseInt($w('new_pr'+id).innerHTML.replace(/[^0-9]/ig,''));
  			spec_price = 2;
  	}
  } else if ($w('special_price')) {
  	 var sprice = parseInt($w('special_price').value);
     if (sprice>0 && !isNaN(sprice)) {
     	price = sprice;
     	switch($w('special_type').value){
     		case 'sale price': spec_price = 0; break;
 			case 'vip price': spec_price = 2; break;
 			default: spec_price = 1;
     	}
     	}

  }

  var req = new JsHttpRequest();
	req.open(null, '/js/_ajax/basket/add.php', true);
	var data = { 'sid': sid, 'catalog_id': catalog_id, 'id': id, 'price' : price, 'spec_price' : spec_price };
        req.send(data);

	if (action!='купить') show_message('Добавление товара в корзину');

    	req.onreadystatechange = function() {
//		if (req.responseText) { close_message('info',req.responseText);  return false; }
		if (req.readyState == 4) {


			var quantity = req.responseJS.quantity;
			var total_price = req.responseJS.total_price;
			var content = req.responseJS.content;

			if (quantity>0) {
				$('.in_clock').css({top: -110, left: 30, opacity: 0.5}).fadeIn('slow').animate({top: 23, left: 55, opacity: 1},1500,'',function(){
					$('.clock').css({top: 23, left: 55, opacity: 1}).fadeIn();
				});

				update_basket(req.responseJS.in_text);

				if ($w('divbasket') != null) $w('divbasket').style.display = '';
				if ($w('lba') != null) $w('lba').style.display = 'none';
				if ($w('empty_shopping_cart') != null) $w('empty_shopping_cart').style.display = 'none';
				if ($w('shopping_cart') != null) $w('shopping_cart').style.display = '';
				if ($w('quantity') != null) $w('quantity').innerHTML = quantity;
				if ($w('total_price') != null) $w('total_price').innerHTML = total_price;
				if ($w('ending') != null) $w('ending').innerHTML = req.responseJS.end;
				if ($w('basket_'+id) != null) $w('basket_'+id).src = '/img/buttons/p10.gif';

			}

			if (action == 'купить') window.location.href=SiteUrl+'shopping_cart/';
			else close_message('bas',content); //close_message('confirm','Товар добавлен в корзину<br>&nbsp;Приятных, Вам, покупок');

		}

   }
}

/* BASKET >> */


function removeElement(parent_name,child_name) {
  if ($w(parent_name) && $w(child_name)) {
  var d = $w(parent_name);
  var olddiv = $w(child_name);
  d.removeChild(olddiv);
  }
}



function change_content(id, path, parent_name){
	var content = $w(parent_name);

	if (content!=null) {

		show_message('Загрузка данных');

	  	var req = new JsHttpRequest();
		req.open(null, '/js/_ajax/change_content.php', true);
		var data = { 'id': id, 'path': path, 'module': parent_name };
    	req.send(data);

		req.onreadystatechange = function() {
//			$w('debug').innerHTML = req.responseText;

			if (req.readyState == 4) {

			//**** СОДЕРЖИМОЕ ****//
			var html = req.responseJS.html;
			content.innerHTML = (html) ? html : '';

			//**** ЗАГОЛОВОК СТРАНИЦЫ ****//
			document.title = req.responseJS.MetaTitle;

			//**** НАВИГАЦИОННАЯ ЛИНИЯ ****//
			//var navigationLine = req.responseJS.navigationLine;
			//if (navigationLine && $w('navigation')!=null) $w('navigation').innerHTML = navigationLine;
			//**** МЕНЮ САЙТА ****//
			//var menu = req.responseJS.menu;
			//if (menu && $w('menu')!=null) $w('menu').innerHTML = menu;
			close_message();
			//$(window).scrollTo($('#'+parent_name), 1000);
			}


		}
	} else if (path) location.href = ''+path+'';
}

// <<<<< РАБОТА С COOKIE  //
function addCookie(szName,szValue,dtDaysExpires,cPath)
{
   cPath = '/';
   var dtExpires = new Date();
   var dtExpiryDate = "";

   dtExpires.setTime(dtExpires.getTime() + dtDaysExpires * 24 * 60 * 60 * 1000);
   dtExpiryDate = dtExpires.toGMTString();		//domain=www.swisstimeclub.ru;
   document.cookie = szName + "=" + szValue + "; path=" +cPath+ "; expires=" + dtExpiryDate;
}

function getCookie(name) {
        var prefix = name + "="
        var cookieStartIndex = document.cookie.indexOf(prefix)
        if (cookieStartIndex == -1) return null
        var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
        if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length
        return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}

function deleteCookie(name, path, domain) {		if (path==undefined) path = '/';
        if (getCookie(name)) {
                document.cookie = name + "=" +
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                "; expires=Thu, 01-Jan-70 00:00:01 GMT"
	}
}

function saveCookieValues(cookie_name, new_values, period, path){
        if (!new_values) return false;
        if (period==undefined) period = 1;
        if (path==undefined) path = '/';

        var checked_values = {};
  		var cookie_value = getCookie(cookie_name);
        if (cookie_value == null || cookie_value == '') addCookie(cookie_name, new_values, period, path);
        else {
            var values = (cookie_value+','+new_values).split(',');
            var save_values = '';
         	if (values.length > 0) for (var i=0; i<values.length; i++) if (values[i]>0 && !checked_values['id'+values[i]]) {
					save_values += values[i]+',';
					checked_values['id'+values[i]] = 1;
         			}
         if (save_values) {
         	save_values = save_values.substring(0,save_values.length-1);
         	addCookie(cookie_name, save_values, period, path);
         	}
		}
}

function delCookieValues(cookie_name, del_values, period, path){
        if (!del_values) return false;
        if (period==undefined) period = 1;
        if (path==undefined) path = '/';

        var checked_values = {};
  		var cookie_value = getCookie(cookie_name);

        if (cookie_value != null && cookie_value != '') {        	del_values = del_values.split(',');
        	if (del_values.length>0) for (var i=0; i<del_values.length; i++) checked_values['id'+del_values[i]] = 1;

            var values = cookie_value.split(',');
            var save_values = '';
         	if (values.length > 0) for (var i=0; i<values.length; i++) if (values[i]>0 && !checked_values['id'+values[i]]) {
					save_values += values[i]+',';
					checked_values['id'+values[i]] = 1;
         			}
     	if (save_values) save_values = save_values.substring(0,save_values.length-1);
       	addCookie(cookie_name, save_values, period, path);
		}
}

function resetCookie(cookie_name,group,period, path){	if (group==undefined) return false;
    if (period==undefined) period = 1;
    if (path==undefined) path = '/';

	var value = getCookie(cookie_name+'_group');
	//alert(value + ' == ' + group);
	if (value!=null && value!=group) {		addCookie(cookie_name,'',period,path);
	}
	addCookie(cookie_name+'_group',group,period,path);


}
// РАБОТА С COOKIE >>>>>> //

function change_class(e){
 if (e!=null && e.value!='') e.className = 'inp_text';
}

function FormCheckEmail(id, user_id){
    var e = $w(id);
	if (e!=null) {
		if (e.value=='') close_message('error', 'Необходимо ввести email адрес', e.id);
		else if (/^[\w\-\.]{2,32}\@[\w\-\.]+\.[a-zA-Z0-9]{2,5}$/i.test(e.value)==false) close_message('error', 'Некорректно введен email адрес', e.id);
		else if (FormCheckLogin(e, 'Email', user_id, 'Необходимо ввести email адрес', 'Введенный email адрес уже существует')) return true;
    } else close_message('error', 'Неверно указан елемент');

return false;
}



function check_form_errors(form_id){var t = eval('checkFields_'+form_id);
var mas = (t) ? t : null;
if (!mas) return false;

for (var i in mas)
	if ($w('fields'+i)){		var fname = ($w('fname'+i)) ? ' "'+$w('fname'+i).innerHTML+'"' : '';
		var value = $w('fields'+i).value;
			if ((value == '' || value == 0) && mas[i] == 1) {				if ($w('fields'+i).type == 'text') close_message('error', 'Необходимо заполнить поле'+fname, 'fields'+i);
				else close_message('error', 'Необходимо выбрать значение в поле'+fname, 'fields'+i);
				return false;
			} else if (/e-?mail|ема[и|й]л|электро(нная\ )?почта/i.test(fname) && /^[\w\-\.]+\@[\w\-\.]+\.[a-z]{2,5}$/i.test(value)==false && ((value.length>0 && mas[i] == 0) || mas[i] == 1)) {
				close_message('error', 'Некорректно введен email адрес', 'fields'+i);
				return false;
			} else if (/телефон|мобильный|сотовый|phone|mobile/i.test(fname) && /^[\d\-\(\)\ \.\,\+]{4,}$/i.test(value)==false && ((value.length>0 && mas[i] == 0) || mas[i] == 1)) {
				close_message('error', 'Некорректно введен '+fname, 'fields'+i);
				return false;
			}
	}

return true;}

function send_form_data(form_id){
if (check_form_errors(form_id) == false) return false;
else {
	var fdata = $w('form_data'+form_id);
	var fields_value = new Array(fdata.length);
	for (var i=0; i<fdata.length; i++) fields_value[fdata.elements[i].name] = fdata.elements[i];

  		var req = new JsHttpRequest();
		req.open(null, '/js/_ajax/messages/send_form_data.php', true);
		var data = { 'form_id': form_id, 'data': fields_value, 'back_link' : eval('back_link'+form_id) };
        req.send(data);

		show_message('Отправление данных');

    	req.onreadystatechange = function() {
		  //if (req.responseText) alert( req.responseText );

		  if (req.readyState == 4) {

		  var message = req.responseJS.result;
		  var errors = req.responseJS.errors;
          var focus = req.responseJS.focus;

            if (errors != '') close_message('error', errors, focus);
            else {
		        if (message) {
		        	close_message('info', message);
		        	$w('form_data'+form_id).reset();
		        	reImg('iCodeForm'+form_id);
					//for (var i=0; i<fdata.length; i++) fdata.elements[i].value = '';
		        }
				else close_message();
            }

		   }
		}

}
}


function reImg(id){
	if ($w(id)==null) return false;
	var ndate = new Date().getTime();
	$w(id).src = "inc/Modules/antibot.php?" + ndate;
}


// ******* Работа с формами >>>>>>> ******** //
function change_city(id, value){

	if (value == 'other') {
		document.getElementById(id).style.display = '';
	} else document.getElementById(id).style.display = 'none';
}

function setPhoneFormat(e,event){
   var k = event.keyCode;
	   if (k != 8 && k != 46){
	   var val = e.value;
	   val = val.replace(/[^0-9]/g, "");
	   var pattern = /\(?([0-9]{3})\)?\ ?([0-9]{0,7})?/;
	   if (pattern.test(val)) val = '('+RegExp.$1+') '+RegExp.$2;
	   e.value = val;
   }
   show_result(e.id, true);
}

var horizontal_offset="9px"
var vertical_offset="0"
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
	tipwidth = 'auto';
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.style.display = '';
document.getElementById('hint_cont').innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth-30+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")-60+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
dropmenuobj.style.display = '';
}


function send_sms(phone,message){
	var req = new JsHttpRequest();
	req.open(null, '/inc/Modules/sms/_ajax/send_sms.php', true);
	var data = { 'phone': phone, 'message': message };
        req.send(data);
        //show_message();

	   	req.onreadystatechange = function() {
	    //if (req.responseText) alert(req.responseText);
    	   if (req.readyState == 4) {
			var result = req.responseJS.result;
			var errors = req.responseJS.errors;
			var type = req.responseJS.type;

            /*
            if (errors != '') { if (type == 'WARNING') close_message('info', errors); else close_message('error', errors); }
            else if (result && type == 'OK'){
					close_message('info', result, 'sms_code');
            } else close_message('info','По техническим причинам сервис SMS временно недоступен');
            */
         }
        }
}



/**** CAPTIONS ****/
jQuery.fn.extend({
	captify: function(uo) {
		var o = $.extend({
			speedOver: 'fast',				// speed of the mouseover effect
			speedOut: 'normal',				// speed of the mouseout effect
			hideDelay: 500,					// how long to delay the hiding of the caption after mouseout (ms)
			animation: 'slide',				// 'fade', 'slide', 'always-on'
			prefix: '',						// text/html to be placed at the beginning of every caption
			opacity: '0.50',				// opacity of the caption on mouse over
			className: 'caption-top',	// the name of the CSS class to apply to the caption box
			position: 'bottom',				// position of the caption (top or bottom)
			spanWidth: '100%'				// caption span % of the image
		}, uo);
		$(this).each(function() {
			var img = this;
			$(this).load(function() {
				if (img.hasInit){ return false; }
				img.hasInit = true;
				var over_caption = false;
				var over_img = false;

				//pull the label from another element if there is a
				//valid element id inside the rel="..." attribute, otherwise,
				//just use the text in the alt="..." attribute.
				var captionLabelSrc = $('#' + $(this).attr('rel'));
				var captionLabelHTML = !captionLabelSrc.length ? $(this).attr('alt') : captionLabelSrc.html();
				captionLabelSrc.remove();
				var toWrap = this.parent && this.parent.tagName == 'a' ? this.parent : $(this);

				var wrapper =
					toWrap.wrap('<div></div>').parent()
					.css({
						overflow: 'hidden',
						padding: 0,
						fontSize: 0.1
					})
					.addClass('caption-wrapper')
					.width($(this).width())
					.height($(this).height());

				//transfer the margin and border properties from the image to the wrapper
				$.map(['top', 'right', 'bottom', 'left'], function(i) {
					wrapper.css('margin-' + i, $(img).css('margin-' + i));
					$.map(['style', 'width', 'color'], function(j) {
						var key = 'border-' + i + '-' + j;
						wrapper.css(key, $(img).css(key));
					});
				});
				$(img).css({ border: '0 none' });

				//create two consecutive divs, one for the semi-transparent background,
				//and other other for the fully-opaque label
				var caption = $('div:last', wrapper.append('<div></div>'))
					.addClass(o.className);

				var captionContent = $('div:last', wrapper.append('<div></div>'))
					.addClass(o.className)
					.append(o.prefix)
					.append(captionLabelHTML);


				//override hiding from CSS, and reset all margins (which could have been inherited)
				$('*', wrapper).css({ margin: 0 }).show();

				//ensure the background is on bottom
				var captionPositioning = jQuery.browser.msie ? 'static' : 'relative';
				caption.css({
					zIndex: 1,
					position: captionPositioning,
					opacity: o.animation == 'fade' ? 0 : o.opacity,
					width: o.spanWidth
				});

				if (o.position == 'bottom'){
					var vLabelOffset =
						parseInt(caption.css('border-top-width').replace('px', '')) +
						parseInt(captionContent.css('padding-top').replace('px', '')) - 1;
					captionContent.css('paddingTop', vLabelOffset);
				}
				//clear the backgrounds/borders from the label, and make it fully-opaque
				captionContent.css({
					position: captionPositioning,
					zIndex: 2,
					background: 'none',
					border: '0 none',
					opacity: o.animation == 'fade' ? 0 : 1,
					width: o.spanWidth
				});
				caption.width(captionContent.outerWidth());
				caption.height(captionContent.height());

				// represents caption margin positioning for hide and show states
				var topBorderAdj = o.position == 'bottom' && jQuery.browser.msie ? -4 : 0;
				var captionPosition = o.position == 'top'
				   ? { hide: -$(img).height() - caption.outerHeight() - 2, show: -$(img).height() }
				   : { hide: 0, show: -caption.outerHeight() + topBorderAdj };

				//pull the label up on top of the background
				captionContent.css('marginTop', -caption.outerHeight());
				caption.css('marginTop', captionPosition[o.animation == 'fade' || (o.animation == 'always-on' || img.alt == 'always-on') ? 'show' : 'hide']);

				//function to push the caption out of view
				var cHide = function() {
					if (!over_caption && !over_img){
						var props = o.animation == 'fade'
							? { opacity: 0 }
							: { marginTop: captionPosition.hide };
						caption.animate(props, o.speedOut);
						if (o.animation == 'fade'){
							captionContent.animate({opacity: 0}, o.speedOver);
						}
					}
				};
 				//function to push the caption out of view
				var cShow = function() {
							if (!over_caption) {
								var props = o.animation == 'fade'
									? { opacity: o.opacity }
									: { marginTop: captionPosition.show };
								caption.animate(props, o.speedOver);
								if (o.animation == 'fade'){
									captionContent.animate({opacity: 1}, o.speedOver/2);
								}
							}
				};

				if (o.animation != 'always-on' && img.alt != 'always-on'){
					//when the mouse is over the image
					$(this).hover(function(){
							over_img = true;
							window.setTimeout(cShow, 1);
						},
						function() {
							over_img = false;
							window.setTimeout(cHide, o.hideDelay);
						}
					);
					//when the mouse is over the caption on top of the image (the caption is a sibling of the image)
					$('div', wrapper).hover(
						function() { over_caption = true; },
						function() { over_caption = false; window.setTimeout(cHide, o.hideDelay); }
					);
				}
			});
			//if the image has already loaded (due to being cached), force the load function to be called
			if (this.complete || this.naturalWidth > 0) {
				$(img).trigger('load');
			}
		});
	}
});


/**
 * @license
 * jQuery Tools 1.2.5 Tooltip - UI essentials
 *
 * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
 *
 * http://flowplayer.org/tools/tooltip/
 *
 * Since: November 2008
 * Date:    Wed Sep 22 06:02:10 2010 +0000
 */

(function($) {
	// static constructs
	$.tools = $.tools || {version: '1.2.5'};

	$.tools.tooltip = {

		conf: {

			// default effect variables
			effect: 'toggle',
			fadeOutSpeed: "fast",
			predelay: 0,
			delay: 50,
			opacity: 1,
			tip: 0,

			// 'top', 'bottom', 'right', 'left', 'center'
			position: ['top', 'center'],
			offset: [0, 0],
			relative: false,
			cancelDefault: true,

			// type to event mapping
			events: {
				def: 			"mouseenter,mouseleave",
				input: 		"focus,blur",
				widget:		"focus mouseenter,blur mouseleave",
				tooltip:		"mouseenter,mouseleave"
			},

			// 1.2
			layout: '<div/>',
			tipClass: 'tooltip',
			tipInner: ''
		},

		addEffect: function(name, loadFn, hideFn) {
			effects[name] = [loadFn, hideFn];
		}
	};


	var effects = {
		toggle: [
			function(done) {
				var conf = this.getConf(), tip = this.getTip(), o = conf.opacity;
				if (o < 1) { tip.css({opacity: o}); }
				tip.show();
				done.call();
			},

			function(done) {
				this.getTip().hide();
				done.call();
			}
		],

		fade: [
			function(done) {
				var conf = this.getConf();
				this.getTip().fadeTo(conf.fadeInSpeed, conf.opacity, done);
			},
			function(done) {
				this.getTip().fadeOut(this.getConf().fadeOutSpeed, done);
			}
		]
	};


	/* calculate tip position relative to the trigger */
	function getPosition(trigger, tip, conf) {


		// get origin top/left position
		var top = conf.relative ? trigger.position().top : trigger.offset().top,
			 left = conf.relative ? trigger.position().left : trigger.offset().left,
			 pos = conf.position[0];

		top  -= tip.outerHeight() - conf.offset[0];
		left += trigger.outerWidth() + conf.offset[1];

		// iPad position fix
		if (/iPad/i.test(navigator.userAgent)) {
			top -= $(window).scrollTop();
		}

		// adjust Y
		var height = tip.outerHeight() + trigger.outerHeight();
		if (pos == 'center') 	{ top += height / 2; }
		if (pos == 'bottom') 	{ top += height; }


		// adjust X
		pos = conf.position[1];
		var width = tip.outerWidth() + trigger.outerWidth();
		if (pos == 'center') 	{ left -= width / 2; }
		if (pos == 'left')   	{ left -= width; }

		return {top: top, left: left};
	}



	function Tooltip(trigger, conf) {

		var self = this,
			 fire = trigger.add(self),
			 tip,
			 timer = 0,
			 pretimer = 0,
			 title = trigger.attr("title"),
			 tipAttr = trigger.attr("data-tooltip"),
			 effect = effects[conf.effect],
			 shown,

			 // get show/hide configuration
			 isInput = trigger.is(":input"),
			 isWidget = isInput && trigger.is(":checkbox, :radio, select, :button, :submit"),
			 type = trigger.attr("type"),
			 evt = conf.events[type] || conf.events[isInput ? (isWidget ? 'widget' : 'input') : 'def'];


		// check that configuration is sane
		if (!effect) { throw "Nonexistent effect \"" + conf.effect + "\""; }

		evt = evt.split(/,\s*/);
		if (evt.length != 2) { throw "Tooltip: bad events configuration for " + type; }


		// trigger --> show
		trigger.bind(evt[0], function(e) {

			clearTimeout(timer);
			if (conf.predelay) {
				pretimer = setTimeout(function() { self.show(e); }, conf.predelay);

			} else {
				self.show(e);
			}

		// trigger --> hide
		}).bind(evt[1], function(e)  {
			clearTimeout(pretimer);
			if (conf.delay)  {
				timer = setTimeout(function() { self.hide(e); }, conf.delay);

			} else {
				self.hide(e);
			}

		});


		// remove default title
		if (title && conf.cancelDefault) {
			trigger.removeAttr("title");
			trigger.data("title", title);
		}

		$.extend(self, {

			show: function(e) {

				// tip not initialized yet
				if (!tip) {

					// data-tooltip
					if (tipAttr) {
						tip = $(tipAttr);

					// single tip element for all
					} else if (conf.tip) {
						tip = $(conf.tip).eq(0);

					// autogenerated tooltip
					} else if (title) {
						tip = $(conf.layout).addClass(conf.tipClass).appendTo(document.body).hide();

						if(conf.tipInner) {
							tip.find('.' + conf.tipInner).html(title);
						} else {
							tip.append(title);
						}

					// manual tooltip
					} else {
						tip = trigger.next();
						if (!tip.length) { tip = trigger.parent().next(); }
					}

					if (!tip.length) { throw "Cannot find tooltip for " + trigger;	}
				}

			 	if (self.isShown()) { return self; }

			 	// stop previous animation
			 	tip.stop(true, true);

				// get position
				var pos = getPosition(trigger, tip, conf);

				// restore title for single tooltip element
				if (conf.tip) {
					tip.html(trigger.data("title"));
				}

				// onBeforeShow
				e = e || $.Event();
				e.type = "onBeforeShow";
				fire.trigger(e, [pos]);
				if (e.isDefaultPrevented()) { return self; }


				// onBeforeShow may have altered the configuration
				pos = getPosition(trigger, tip, conf);

				// set position
				tip.css({position:'absolute', top: pos.top, left: pos.left});

				shown = true;

				// invoke effect
				effect[0].call(self, function() {
					e.type = "onShow";
					shown = 'full';
					fire.trigger(e);
				});


				// tooltip events
				var event = conf.events.tooltip.split(/,\s*/);

				if (!tip.data("__set")) {

					tip.bind(event[0], function() {
						clearTimeout(timer);
						clearTimeout(pretimer);
					});

					if (event[1] && !trigger.is("input:not(:checkbox, :radio), textarea")) {
						tip.bind(event[1], function(e) {

							// being moved to the trigger element
							if (e.relatedTarget != trigger[0]) {
								trigger.trigger(evt[1].split(" ")[0]);
							}
						});
					}

					tip.data("__set", true);
				}

				return self;
			},

			hide: function(e) {

				if (!tip || !self.isShown()) { return self; }

				// onBeforeHide
				e = e || $.Event();
				e.type = "onBeforeHide";
				fire.trigger(e);
				if (e.isDefaultPrevented()) { return; }

				shown = false;

				effects[conf.effect][1].call(self, function() {
					e.type = "onHide";
					fire.trigger(e);
				});

				return self;
			},

			isShown: function(fully) {
				return fully ? shown == 'full' : shown;
			},

			getConf: function() {
				return conf;
			},

			getTip: function() {
				return tip;
			},

			getTrigger: function() {
				return trigger;
			}

		});

		// callbacks
		$.each("onHide,onBeforeShow,onShow,onBeforeHide".split(","), function(i, name) {

			// configuration
			if ($.isFunction(conf[name])) {
				$(self).bind(name, conf[name]);
			}

			// API
			self[name] = function(fn) {
				if (fn) { $(self).bind(name, fn); }
				return self;
			};
		});

	}


	// jQuery plugin implementation
	$.fn.tooltip = function(conf) {

		// return existing instance
		var api = this.data("tooltip");
		if (api) { return api; }

		conf = $.extend(true, {}, $.tools.tooltip.conf, conf);

		// position can also be given as string
		if (typeof conf.position == 'string') {
			conf.position = conf.position.split(/,?\s/);
		}

		// install tooltip for each entry in jQuery object
		this.each(function() {
			api = new Tooltip($(this), conf);
			$(this).data("tooltip", api);
		});

		return conf.api ? api: this;
	};

}) (jQuery);


(function(d){var i=d.tools.tooltip;d.extend(i.conf,{direction:"up",bounce:false,slideOffset:10,slideInSpeed:200,slideOutSpeed:200,slideFade:!d.browser.msie});var e={up:["-","top"],down:["+","top"],left:["-","left"],right:["+","left"]};i.addEffect("slide",function(g){var a=this.getConf(),f=this.getTip(),b=a.slideFade?{opacity:a.opacity}:{},c=e[a.direction]||e.up;b[c[1]]=c[0]+"="+a.slideOffset;a.slideFade&&f.css({opacity:0});f.show().animate(b,a.slideInSpeed,g)},function(g){var a=this.getConf(),f=a.slideOffset,
b=a.slideFade?{opacity:0}:{},c=e[a.direction]||e.up,h=""+c[0];if(a.bounce)h=h=="+"?"-":"+";b[c[1]]=h+"="+f;this.getTip().animate(b,a.slideOutSpeed,function(){d(this).hide();g.call()})})})(jQuery);



/*** Custom Project Script ***/
jQuery.expr[':'].regex = function(elem, index, match) {
   var matchParams = match[3].split(','),
   validLabels = /^(data|css):/,
   attr = {
      method: matchParams[0].match(validLabels) ? matchParams[0].split(':')[0] : 'attr',
      property: matchParams.shift().replace(validLabels,'')
   },
   regexFlags = 'ig',
   regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
   return regex.test(jQuery(elem)[attr.method](attr.property));
}







var people = {
	delay: 100,
	current: 1,
	def_left: 20,
	def_clock_left: 20,
	def_clock_bottom: -30,
	cur_left: 0,
	cur_bottom: 0,
	fname: 'people',
	get_photo: function(){
		//var t1 = Math.ceil(Math.random()*13);
		var t1 = this.sort.shuffle()[0];
		if (t1>13) t1 = 13;
		else if (t1<=0) t1 = 1;
		/*if (this['show_photos'][t1]==undefined) {
//			if (this['photos'][t1]['left']=undefined)
		}//t1 =  ? t1 : (this['photos'][t2]['left']!=undefined ? t2 : 1);
		*/
		this.current = t1;
	},
	watch_link: '',
	rand: function(){
    	people.get_photo();
    	people.fname = (/people/i.test($('#people img').attr('src'))) ? 'clock' : 'people';
    	$.preloadImages('/img/promo/'+people.fname+people.current+'.png');
	    $('#people img').delay(8000).slideUp('normal', function(){
	    	people.cur_left = people['photos'][people.current]['left']!=undefined ? people['photos'][people.current]['left'] : people.def_left;
	    	people.watch_link = '';
	    	people.cur_bottom = 0;
	    	if (people.fname=='clock') {
	    		 people.cur_left = people.def_clock_left;
	    		 people.cur_bottom = people.def_clock_bottom;
	    		 people.watch_link = people.watch_links[people.current];
	    	}
	    	if (people.cur_left!=undefined){
		    	$('#people').css({'left': people.cur_left+'px', 'bottom': people.cur_bottom+'px'});
		    	$(this).attr('src', '/img/promo/'+people.fname+people.current+'.png').slideDown('normal');
		    	if (people.watch_link && people.watch_link!='' && people.fname=='clock')
		    	 	 $('#people img').css({'cursor': 'pointer'}).click(function(){ if (this.style.cursor=='pointer') location.href = people.watch_link; });
		    	else $('#people img').css({'cursor': 'default'});
		    	setTimeout(function(){ people.rand(); }, people.delay);
	    	}
	    });
	},
	sort: [1,2,3,4,5,6,7,8,9,10,11,12,13],
	photos:{
	1: {'left': 20},
	2: {'left': 35},
	3: {'left': 20},
	4: {'left': 40},
	5: {'left': 23},
	6: {'left': 15},
	7: {'left': 30},
	8: {'left': 15},
	9: {'left': 35},
	10: {'left': 25},
	11: {'left': 37},
	12: {'left': 20},
	13: {'left': 20},
    14: {
         'left': 17,
	     'bottom': -24
        }
	},
	watch_links:{
    1: 'http://bvlgari.swisstimeclub.ru/5240101/',
	2: 'http://vacheron-constantin.swisstimeclub.ru/5150561/',
	3: 'http://a-lange-sohne.swisstimeclub.ru/5011141/',
	4: 'http://roger-dubuis.swisstimeclub.ru/5390191/',
	5: 'http://ulysse-nardin.swisstimeclub.ru/1630301/',
	6: 'http://porsche-design.swisstimeclub.ru/1430181/',
	7: 'http://rolex.swisstimeclub.ru/1131241/',
	8: 'http://glashutte.swisstimeclub.ru/1070561/',
	9: 'http://breguet.swisstimeclub.ru/1040031/',
	10: 'http://louis-vuitton.swisstimeclub.ru/1110191/',
	11: 'http://patek-philippe.swisstimeclub.ru/5120431/',
	12: 'http://versace.swisstimeclub.ru/5310042/',
	13: '',
	14: ''
	}
}

Array.prototype.shuffle = function( b )
{
 var i = this.length, j, t;
 while( i )
 {
  j = Math.floor( ( i-- ) * Math.random() );
  t = b && typeof this[i].shuffle!=='undefined' ? this[i].shuffle() : this[i];
  this[i] = this[j];
  this[j] = t;
 }

 return this;
};

function show_html(){

	if ($w('people')) {
		people.current = $('#people img').attr("src").replace(/[^0-9]/g,"");
	//	people['show_photos'][people.current] = true;
		var clock = /clock/.test($('#people img').attr("src")) ? true : false;
		var pep_left = clock ? people.def_clock_left : people['photos'][people.current]['left'];
        var pep_bottom = clock ? people.def_clock_bottom : (people['photos'][people.current]['bottom']!=undefined?people['photos'][people.current]['bottom']:0);
    	people.watch_link = '';
    	if (clock) people.watch_link = people.watch_links[people.current];
	    if (people.watch_link && people.watch_link!='') $('#people img').css({'cursor': 'pointer'}).click(function(){ if (this.style.cursor=='pointer') location.href = people.watch_link; });
    	else $('#people img').css({'cursor': 'default'});
		$('#people').css({'left': pep_left+'px', 'bottom': pep_bottom+'px'});
		/* if (!isIE6) setTimeout(function(){ people.rand(); }, people.delay);  */
	}


	$('.check_price').click(function(){
		$('.check_price').each( function(){
			this.src = this.src.replace(/form_ok/ig,"form_clear");
		});
		this.src = this.src.replace(/form_clear/ig,"form_ok");
        $('#special_type').val(this.alt);
        var spec_price = 0;
     	switch(this.alt){
     		case 'sale price': spec_price = 0; break;
 			case 'vip price': spec_price = 2; break;
 			default: spec_price = 1;
     	}
        $('#special_price').val($('#price'+spec_price).html().replace(/[^0-9]+/ig,""));
                $('#price0,#price1,#price2').css('fontWeight', 'normal');
        $('#price'+spec_price).css('fontWeight', 'bold');
	});

	//$('h3').click(function(){ $(this).next().slideToggle('slow'); });
	$('.ask_i').click(function(){ $('.cart-tabs-menu li').removeClass('active'); $('.cart-tabs-menu li:eq(0)').addClass('active'); $('#ask_txt1').slideUp('fast'); $('#ask_txt2').slideUp('fast'); $('#ask_txt3').slideUp('fast'); $('#ask_txt0').slideDown('slow'); });
	$('.ask_q').click(function(){ $('.cart-tabs-menu li').removeClass('active'); $('.cart-tabs-menu li:eq(1)').addClass('active'); $('#ask_txt0').slideUp('fast'); $('#ask_txt2').slideUp('fast'); $('#ask_txt3').slideUp('fast'); $('#ask_txt1').slideDown('slow'); });
	$('.ask_o').click(function(){ $('.cart-tabs-menu li').removeClass('active'); $('.cart-tabs-menu li:eq(2)').addClass('active'); $('#ask_txt0').slideUp('fast'); $('#ask_txt1').slideUp('fast'); $('#ask_txt3').slideUp('fast'); $('#ask_txt2').slideDown('slow'); });
	$('.ask_n').click(function(){ $('.cart-tabs-menu li').removeClass('active'); $('.cart-tabs-menu li:eq(3)').addClass('active'); $('#ask_txt0').slideUp('fast'); $('#ask_txt1').slideUp('fast'); $('#ask_txt2').slideUp('fast'); $('#ask_txt3').slideDown('slow'); });
	$('h3.h33').click(function(){ $(this).next().slideToggle('slow'); });


	var req = new JsHttpRequest();
	req.open(null, '/js/_ajax/show_html.php', true);
	var data = sdata;
        req.send(data);
	   	req.onreadystatechange = function() {
	   // if (req.responseText) alert(req.responseText);
    	   if (req.readyState == 4) {
			var main_menu = req.responseJS.main_menu;
			var notices = req.responseJS.notices;
			var watch_special = req.responseJS.watch_special;
			var brands = req.responseJS.brands;
			var errors = req.responseJS.errors;
			var adv_search = req.responseJS.adv_search;
            if (adv_search && $w('adv-search-window')) $('#adv-search-window').html(adv_search);
   		    if (main_menu && $w('fmenu1')) $w('fmenu1').innerHTML = main_menu;
            if (main_menu && $w('fmenu2')) $w('fmenu2').innerHTML = main_menu;
            if (watch_special && $w('watch_special')) $w('watch_special').innerHTML = watch_special;
            if (notices && $w('notices')) $w('notices').innerHTML = notices;
            if (brands && $w('brands')) $w('brands').innerHTML = brands;

			$(".tt-open").tooltip({
				offset: [5, 2],
				effect: 'slide',
				layout: '<div><div class="tooltip-top"><div class="tooltip-bottom"><div class="tooltip-repeat"><div class="tooltip-icon tooltip-inner"></div></div></div></div></div>',
				tipInner: 'tooltip-inner'
			});
			$("[rel=ask]").tooltip({
				offset: [0, 52],
				effect: 'slide',
				tipClass: 'tooltip-width',
				layout: '<div><div class="tooltip-top"><div class="tooltip-bottom"><div class="tooltip-repeat"><div class="tooltip-icon tooltip-inner"></div></div></div></div></div>',
				tipInner: 'tooltip-inner'
			});


			$("a:regex(rel,basket|sravnit)").tooltip({
				offset: [0, -18],
				effect: 'slide',
				layout: '<div><div class="tooltip-top"><div class="tooltip-bottom"><div class="tooltip-repeat"><div class="tooltip-icon tooltip-inner"></div></div></div></div></div>',
				tipInner: 'tooltip-inner'
			});

			$(".catalog-label").tooltip({
				offset: [0, 52],
				effect: 'slide',
				tipClass: 'tooltip-width',
				layout: '<div><div class="tooltip-top"><div class="tooltip-bottom"><div class="tooltip-repeat"><div class="tooltip-icon tooltip-inner"></div></div></div></div></div>',
				tipInner: 'tooltip-inner'
			});


			$(".sa a").click(function(){ return false; });
			$(".sa a").tooltip({
				offset: [-12, 52],
				effect: 'slide',
				tipClass: 'tooltip-width',
				layout: '<div><div class="tooltip-top"><div class="tooltip-bottom"><div class="tooltip-repeat"><div class="tooltip-icon tooltip-inner2"></div></div></div></div></div>',
				tipInner: 'tooltip-inner2'
			});

			 $("input, textarea").focus(function(){
			    if ($(this).attr("value") == $(this).attr("title"))
			      $(this).attr("value", "")
			  });

			  $("input, textarea").blur(function(){
			    if ($(this).attr("value") == "")
			      $(this).attr("value", $(this).attr("title"))
			  });


			    $("#adv-search-open").click(function() { advanced_search.open(); });
				$("#adv-search-hide").click(function() { advanced_search.close(); });

			 	drop_boxes();


         }
    }



	$(".tabs li a").click(function(){
		$(".tabs li").removeClass("active");
		$(this.parentNode).addClass("active");
		var f = /\#m([0-9]+)/.test(this.href);
		var group = RegExp.$1; if (group<=0 || group>3) group = 1;
		addCookie('mtab',group,31,'/');

		if (isIE) {
			$("#brands div").css({"display": "none"});
			if ($w("m"+group)) $("#m"+group).css({"display": ""});
		} else {
			$("#brands div").fadeOut('fast');
			if ($w("m"+group)) $("#m"+group).fadeIn('slow');
		}
		var link_value = '';
		if (group!=1) link_value += (group==2?'?mech=1':(group==3?'?mech=5':''));
		if (sdata['gen']!='') link_value += (link_value!=''?'&':'?')+'sex='+sdata['gen'];
		if (sdata['brend']!='') location.href = (link_value==''?location.href.replace(/catalogue\/\?[^\?]+/,""):location.href.replace(/\?[^\?]+/,""))+link_value;
		return false;
	});


	create_boxes();
    $('a[rel=external]').click(function(){ this.target = "_blank"; });
    $('a[rel=nofollow]').click(function(){ this.target = "_blank"; });
    transp_line();
}


function transp_line(){
//	$('.transp-line').css({display: ''});
/*	$('.transp-line').css({left: 0, opacity: 0.5}).fadeIn('slow').animate({left: 450, opacity: 1},1000,'',function(){
					//alert(1)
					$('.transp-line').animate({left: 450, opacity: 0.5},1000,'',function(){
					});
				});   */

	if (/[0-9]{7}/i.test(location.href)) $("body").animate({scrollTop: 400},700,'',function(){});
}

function drop_boxes(){
		$(".open-list").click(function() {
			$(this).next(".form-list").slideToggle('normal').hover(
			        function() {
			            $(this).stop(true, true);
			        },
			        function() {
			            $(this).slideUp('fast');
			        }
			    );
			return false;
		});
		$(".form-body span").click(function() {
			$(this).next().next(".form-list").slideToggle('normal').hover(
			        function() {
			            $(this).stop(true, true);
			        },
			        function() {
			            $(this).slideUp('fast');
			        }
			    );
		});


		$('input:regex(value,all|japan|swiss|mech)').each(function(){
			var v = $(this).attr('checked');
			var d = v ? true : false;
			if (v) $(this).parent().next('div').find('input').attr({ 'checked': v, 'disabled': d});
		});

		$('input:regex(value,all|japan|swiss|mech)').click(function(){
			var v = $(this).attr('checked');
			var d = v ? true : false;
			$(this).parent().next('div').find('input').attr({ 'checked': v, 'disabled': d});
		});
}


function check_box(e){
  if (!/\?win=box/.test($(e).attr('href'))) $(e).attr('href', $(e).attr('href')+'?win=box');
}

function create_boxes(){

var div_confirm = (/shopping_cart/i.test(location.href))
		? '<a href="#" title="Подтвердить действие (Enter)" onclick="$w(\'loading-box\').style.display = \'none\'; if (OK==true) remove_func(); return false;"><img class="image" src="/js/images/btn_apply.png" alt="OK">&nbsp;<b>OK</b></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
		  '<a href="#" title="Отменить действие (ESC)" onclick="$w(\'loading-box\').style.display = \'none\'; return false;"><img class="image" src="/js/images/btn_close.png" alt="Отмена">&nbsp;<b>Отмена</b></a>'
		: '<a href="'+SiteUrl+'shopping_cart/"><img class="image" src="/img/add_basket.gif" alt="Перейти в корзину">&nbsp;Перейти в корзину</a>&nbsp;&nbsp;'+
		  '<a href="#" title="Закрыть (ESC)" onclick="$w(\'loading-box\').style.display = \'none\'; return false;"><img class="image" src="/js/images/btn_close.png" alt="Закрыть">&nbsp;Закрыть&nbsp;</a>';


var content_id = $w('wrapper') ? 'wrapper' : 'box';

$('#'+content_id).append('<div id="loading-box" class="popup-window catalog-item-popup" style="display: none;">'+
'<div id="loading-text" class="clearfix">&nbsp;</div>'+
'<div style="display: none;" id="loading-img"><img src="/js/images/loading.gif" border="0" alt="Загрузка"></div>'+
'	<div style="display: none; text-align: right;" id="loading-actions">&nbsp;&nbsp;'+
'	  <a href="#" title="Закрыть (ESC)" onclick="$w(\'loading-box\').style.display = \'none\'; if (set_focus != \'\') set_focus.focus(); return false;"><img class="image" src="/js/images/btn_close.png" alt="Закрыть">&nbsp;<b>Закрыть</b>&nbsp;</a>'+
'	</div>'+
'	<div style="display: none; text-align: right;" id="loading-actions-confirm">&nbsp;&nbsp;'+
div_confirm+
'	</div>'+
'</div>'+
'<div id="loading-box2">'+
'	<div id="loading-text2">&nbsp;</div>'+
'	<div style="display: none;" id="loading-img2"><img src="/js/images/loading.gif" border="0" alt="Загрузка"></div>'+
'	<div style="display: none; text-align: right;" id="loading-actions2">&nbsp;&nbsp;'+
'	  <a href="#" title="Закрыть (ESC)" onclick="$w(\'loading-box\').style.display = \'none\'; if (set_focus != \'\') set_focus.focus(); return false;"><img class="image" src="/js/images/btn_close.png" alt="Закрыть">&nbsp;<b>Закрыть</b>&nbsp;</a>'+
'	</div>'+
'	<div style="display: none; text-align: right;" id="loading-actions-confirm2">&nbsp;&nbsp;'+
div_confirm+
'	</div>'+
'</div>'+
'<div id="hintbox" class="catalog-popup" style="display: none;">'+
'	<div class="catalog-popup-in1">'+
'		<div class="catalog-popup-in2" id="hint_cont">'+
'		</div>'+
'	</div>'+
'</div>');
if (isIE) $('.popup-window').css({'border': '1px solid #bdbdbd'});
}




function rec(){

$("#wrapper").prepend(
'<div id="popup" onclick="close_popup()"></div>'
+'<div id="reclama_load"><img src="/img/rec/loader.gif" alt="" border="0" /></div>'
+'<div id="reclama">'
+'<img id="reclama_img" src="/img/rec/1.png" alt="" border="0" usemap="#Map" />'
+'<map name="Map">'
+'  <area shape="poly" coords="10,117,3,155,24,184,163,185,162,312,202,403,450,402,676,402,678,371,586,344,752,325,754,282,639,280,659,157,629,155,632,139,580,117,503,114,513,18,224,13,196,116" href="http://backup-battery.ru/?from=swisstimeclub.ru" target="_blank">'
+'	<area shape="poly" coords="633,152,637,129,663,128,658,153" href="#" onclick="close_popup(); return false;">'
+'</map>'
+'</div>');

$('#reclama').hide();
$('#reclama_img').load( function() {
	$('#reclama_load').hide();
	$('#popup').show();
	$('#reclama').show();
	var record = getCookie('record');
	if (record==undefined || !record) record = 0;
	record = parseInt(record)+1;
	if (record>1) setTimeout(close_popup, 10000);
	addCookie('record',record,31,'/');
} );






}

function close_popup(){
document.getElementById('popup').style.display='none';
document.getElementById('reclama').style.display='none';
document.getElementById('reclama_load').style.display='none';
}

$(document).ready(function(){
   $(window).keydown(function(event){  _key(event); });
   if (/\?win\=[\w]+/i.test(location.href)) {
   	 create_boxes();
	 $('a:regex(href,^(http\:\/\/www\.swisstimeclub\.ru)?\/info\/\\w+\/?$)').click(function(){ check_box(this); });
	 $('a:regex(href,^http\:\/\/gde-kupit-chasy\.swisstimeclub\.ru\/?$)').click(function(){ check_box(this); });
	 $('a:regex(href,^(http\:\/\/www\.swisstimeclub\.ru)?\/(avstrijskie-chasy-naruchnye|belgija-kopii-chasov|evropejskie-kopii-chasov|chasy-naruchnye-optom|oplata-nalozhennym-platezhom|naruchnye-chasy-skidki|kupit-naruchnye-chasy-v-sankt-peterburge|mаgazin-naruchnyh-chasov-v-moskve|internet-magazin-naruchnyh-chasov|magazin-naruchnyh-chasov-v-moskve|chasy-dostavka|chto-takoe-kopija|chasy-v-podarok|kopii-naruchnyh-chasov-ceny)\/?$)').click(function(){ check_box(this); });
   	 $('a:regex(href,^\/$)').click(function(){ parent.parent.location.href = this; return false; });
   	 $('a:regex(href,^\/\\w+\/$)').click(function(){ parent.parent.location.href = this; return false; });
   	 return false;
   }
   setTimeout(function(){ actions.rand(); }, actions.delay);
   if (!isIE) setTimeout(fadeActions, actions.delay);

   $('#art').keydown(function(event){
   	 var k = event.keyCode;
	 if(k==13) $('.id-search .button').click();
   });


   /*
	var record = getCookie('record');
	if (record==undefined || !record) record = 1;
	if (location.href=='http://www.swisstimeclub.ru/' && record<2) setTimeout(rec, 10000);

	$('img').mouseup(function(e){
		if (e.button == 2) {
			removeHandler(this, "click");
			e.preventDefault();
			return false;
		}
	});      */

   $('a[href=#more]').click(function(){
	   	$(".brend_link").css({display: 'none'});
	   	$(".brend_more").slideDown('slow');
   		return false;
   });

   $('a[href=#hide]').click(function(){
	   	$(".brend_more").slideUp('slow',function(){$(".brend_link").css({display: ''})});
   		return false;
   });

   $('.id-search .button').click(function(){
   		var art = parseInt($('#art').val());
   		if (!art || art==0 || isNaN(art)) close_message('info','Необходимо ввести артикул','art');
   		else if (art.length<3) close_message('info','Необходимо ввести не менее 3 цифр для поиска артикула','art');
   		else location.href = '/catalogue/?art='+art;
   		$('#art').val($('#art').val().replace(/[^0-9]/g,""));
   });

   $('a:regex(href,^(http\:\/\/www\.swisstimeclub\.ru)?\/info\/\\w+\/?$)').click(function(){
   	   check_box(this);
       //return box.open(this,{'width': '650px', 'height': '650px'});
       return hs.htmlExpand(this, hs.config1 );
   });
   $('a:regex(href,^http\:\/\/gde-kupit-chasy\.swisstimeclub\.ru\/?$)').click(function(){
   	   check_box(this);
       //return box.open(this,{'width': '650px', 'height': '650px'});
       return hs.htmlExpand(this, hs.config1 );
   });
   $('a:regex(href,^(http\:\/\/www\.swisstimeclub\.ru)?\/(avstrijskie-chasy-naruchnye|belgija-kopii-chasov|evropejskie-kopii-chasov|chasy-naruchnye-optom|oplata-nalozhennym-platezhom|naruchnye-chasy-skidki|kupit-naruchnye-chasy-v-sankt-peterburge|mаgazin-naruchnyh-chasov-v-moskve|internet-magazin-naruchnyh-chasov|magazin-naruchnyh-chasov-v-moskve|chasy-dostavka|chto-takoe-kopija|chasy-v-podarok|kopii-naruchnyh-chasov-ceny)\/?$)').click(function(){
   	   check_box(this);
       //return box.open(this,{'width': '650px', 'height': '650px'});
       return hs.htmlExpand(this, hs.config1 );
   });

//   $('a[href=/info/catalog/]').click(function(){   return false; });

    show_html();

    $('.main-menu ul li').hover(
        function() {
            $(this).addClass("active");
            $(this).find('div.up').stop(true, true);
            $(this).find('div.up').slideDown();
        },
        function() {
            $(this).removeClass("active");
            $(this).find('div.up').slideUp('slow');
        }
    );

    $('img.captify').captify({});
	//$(".tabs li").removeClass("active").fadeTo('fast', 0.5);

	if (!isIE) $('.cart-description-left .catalog-label').animate({opacity: 0}, 2500).animate({opacity: 1}, 2500);
	$('.showIN a[href=#]').click(function(){
		addCookie('onPage',$(this).html().replace(/[^0-9]/ig,""),31,'/');
		location.href = location.href.replace(/((\&|\?)page=[0-9]+)|(page[0-9]+\/)/,"");
		return false;
	});

	//$('.catalog-label').animate({opacity: 0}, 2500).animate({opacity: 1}, 2500);
	if (isIE) $('.ask').css({marginTop: '0px'});

	if ($w('LACpaySys')){
	    $('[name="LACpay_frame"]').hide().attr('src', 'about:blank');
	    $('#LACpaySys').show();
	    $('#LACpaySys A').click(function(){
	        $('input[name="sid"]').val(this.parentNode.id.substr(1));
	        //alert(this.parentNode.id.substr(1));return;
	        $('input[name="sid"]').val(this.parentNode.id.substr(1));
	        $('#LACpay').submit();
	        $('[name="LACpay_frame"]').attr({
	            'width': '100%',
	            'height': '700px'
	        }).show();
	        return false;
	    });
	}

});

/// Поиск
function get_values(id){
var temp = '';
var values = $(id+' input:checked');
for(var i=0; i<values.length; i++) {
	temp += values[i].value+',';
	if (values[i].value=='all') break;
}
if (temp) temp = temp.substring(0,temp.length-1);
temp += '|';
return temp;
}

function resetData(){
	$('input:regex(value,all|japan|swiss|mech)').attr({ 'checked': false, 'disabled': false}).each(function(){
		$(this).parent().next('div').find('input').attr({ 'checked': false, 'disabled': false});
	});
	$('#price_from').val('');
	$('#price_to').val('');
	$('#high_quality').attr('checked',false);
}

function searchData(type){
	if (type==undefined) type = 'lite';
    var get = '';

	switch(type){
		case 'lite': // бренды
					 get += get_values('#mark1');
                     // страны производители
					 get += get_values('#mechanism1');
                     // модель механизма
					 get += get_values('#model1');
                     // пол
					 get += get_values('#gender1');
					 get = 'f1|'+get;
					 break;
		case 'advanced':
					 get += get_values('#mark1');
					 get += get_values('#mechanism1');
					 get += get_values('#model1');
					 get += get_values('#gender1');
					 get += get_values('#mech_type2');
					 get += get_values('#watch_type2');
					 get += get_values('#korpus2');
					 get += get_values('#braslet2');
					 get += ($('#price_from').val() ? $('#price_from').val() : '')+'|';
					 get += ($('#price_to').val() ? $('#price_to').val() : '')+'|';
					 get += ($('#high_quality').attr('checked') ? 2 : '')+'|';

					 get = 'f2|'+get;
					 break;
	}


	addCookie('advSearch',get,30,'/');
	location.href = SiteUrl+'watch_search/?params='+get+'';
}


function act_catalog_filter(type){
	if (type==2) {
        $('.filter-full').slideUp('fast', function(){
        	$('.filter-lite').slideDown('normal');
	        $('#a1').removeClass('act');
    	    $('#a2').addClass('act');
        });
	} else {
        $('.filter-lite').slideUp('fast', function(){
        $('.filter-full').slideDown('normal');
        $('#a2').removeClass('act');
        $('#a1').addClass('act');
        });
	}
}



var advanced_search = {
	open: function(){
		if (isIE) $("#adv-search-window").fadeIn('normal');
		else $("#adv-search-window").show('normal');
	},
	close: function(){
		if (isIE) $("#adv-search-window").fadeOut('normal');
		else $("#adv-search-window").hide('normal');
	}
}


jQuery.preloadImages = function(){
 for(var i = 0; i<arguments.length; i++){
  jQuery("<img>").attr("src", arguments[i]);
 }
};


var actions = {
	delay: 3000,
	current: 1,
	max: 6,
	get_photo: function(){
		this.current = this.current+1;
		if (this.current>actions.max) this.current = 1;
	},
	rand: function(){
    	actions.get_photo();
		$.preloadImages('/img/actions/'+actions.current+'.png');

		if (isIE)
	    $('.office img').delay(actions.delay).slideUp('slow', function(){
		    $(this).attr('src', '/img/actions/'+actions.current+'.png').slideDown('slow');
		    setTimeout(function(){ actions.rand(); }, 0);
	    });
		else
	    $('.office img').delay(actions.delay).fadeOut('slow', function(){
		    $(this).attr('src', '/img/actions/'+actions.current+'.png').fadeIn('slow');
		    setTimeout(function(){ actions.rand(); }, 0);
	    });
	}
}
$.preloadImages(['/img/actions/2.png','/img/actions/3.png','/img/actions/4.png','/img/actions/5.png','/img/actions/6.png']);


function fadeActions(){
  	$('.line-red-in p').fadeOut('slow', function(){
		$(this).fadeIn('slow');
		setTimeout(fadeActions, 6000);
	});
}

function add_sravnit(article){
		if (article!='' && article!=undefined){
  		var cookie_value = getCookie('sravnit');
  		if (cookie_value==undefined || !cookie_value || cookie_value == null) cookie_value = '';
  		var reg = new RegExp(article+"\,","g");
  		cookie_value = cookie_value.replace(reg,"");
  		cookie_value += article+',';
        addCookie('sravnit', cookie_value, 30, '/');
        close_message('sravnit');
        }
}


var lang = {
'basket': "Добавить товар в корзину",
'sravnit': "Добавить товар к сравнению",
'new': "Данный товар является новинкой в каталоге",
'high': "Данные часы выполнены в наивысшем качестве, сопоставимом с оригиналом",
'sale': "Данный товар продается по сниженной цене",
'hit': "Данный товар является одним из лидеров продаж"
}
