<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">var ie = navigator.appVersion.match(/MSIE/) ? true : false;
var ff = navigator.appName.match(/Netscape/) ? true : false;
var ie8 = navigator.appVersion.match(/MSIE 8\.0/) ? true : false;

$(document).ready(function(){

	current_vote = 0;
	mouseover_vote = 0;
	$('.vote').mouseover(function(){
		for(i=1;i&lt;=5;i++){
			$('.vote[data-vote-id='+i+']').removeClass('vote'+mouseover_vote+'_active');
			$('.vote[data-vote-id='+i+']').removeClass('vote'+current_vote+'_active');
			$('.vote_description').hide();
		}
		mouseover_vote = $(this).attr('data-vote-id');
		for(i=1;i&lt;=mouseover_vote;i++){
			$('.vote[data-vote-id='+i+']').addClass('vote'+mouseover_vote+'_active');
			$('.vote_description.vote'+mouseover_vote).show();
		}
	});
	$('.vote').mouseout(function(){
		for(i=1;i&lt;=5;i++){
			$('.vote[data-vote-id='+i+']').removeClass('vote'+mouseover_vote+'_active');
			$('.vote_description.vote'+mouseover_vote).hide();
		}
		for(i=1;i&lt;=current_vote;i++){
			$('.vote[data-vote-id='+i+']').addClass('vote'+current_vote+'_active');
			$('.vote_description.vote'+current_vote).show();
		}
	});
	$('.vote').click(function(){
		current_vote = $(this).attr('data-vote-id');
		$('#vote_result').val(current_vote);
	});
	
	if (document.getElementById('what') != null) {
		$('#what').focus(function(){
			if (globalDefaultWhat == $(this).val()) /*$(this).val('');*/
			$(this).addClass("fadeout");
		}).blur(function(){
			$(this).removeClass("fadeout");
			if ($(this).val() == '') $(this).val(globalDefaultWhat);
			if($(this).val() != currentWhat) { 
				$("#searchForm").attr('action', globalDefaultSearchLink);
			}
		});
	}
	
	$("#what").keydown(function(event){
		if (event.keyCode &gt; 31 &amp;&amp; globalDefaultWhat == $(this).val()) {$(this).val(''); $(this).removeClass("fadeout");}
		if(event.keyCode == 13 &amp;&amp; !$('.autocomplete .ac_over').is(':visible')){
		    doCatalogSearch();
		  }
	});
	
	$("#where").keydown(function(event){
		if (event.keyCode &gt; 31 &amp;&amp; globalDefaultWhere == $(this).val()) {$(this).val('');$(this).removeClass("fadeout");}
		if(event.keyCode == 13 &amp;&amp; !$('.autocomplete .ac_over').is(':visible')){
	    doCatalogSearch();
	  }
	});
	
	if (document.getElementById('where') != null) {
		$('#where').focus(function(){
			if (globalDefaultWhere == $(this).val()) /*$(this).val('');*/
			$(this).addClass("fadeout");
		}).blur(function(){
			$(this).removeClass("fadeout");
			if ($(this).val() == '') $(this).val(globalDefaultWhere);
		});
	}

	if (document.getElementById('search_keyword') != null) {
		$('#search_keyword').focus(function(){
			if (document.getElementById('search_keyword').defaultValue == $(this).val()) $(this).val('');
		}).blur(function(){
			if ($(this).val() == '') $(this).val(document.getElementById('search_keyword').defaultValue);
		});
	}
	
	href();
	href2();
	href3();
	/*coupons_href();*/
	dlist_href();
	gallery_href();
	btn_href();
	hover();
	graph_hover();
	mlist_hover();
	this_hover();
	anlistHeight();
	tdHeight();
	filterHeight()
		
	$('#search .categories span').click(function() {
		if ($('#search .clist').is(':visible')) {
			$('#search .clist').slideUp();
			$(this).parents().find('.show').show();
			$(this).parents().find('.hide').hide();
			closeTopCats();
		} else {
			$('#search .clist').slideDown();
			$(this).parents().find('.show').hide();
			$(this).parents().find('.hide').show();
		}
	});
	
	if ($('#content:first').height() &gt; $('#new-coupons .content:first').height()) {
		$('#new-coupons .content:first').css({'min-height': $('#content:first').height() - 32});
	}
	
	/*if ($('#new-coupons li div:hover')) {
		$(this).addClass('active');
	} else {
		$(this).parents().find('a').css({'text-decoration': 'none'});
	}*/
	
	$("#new-coupons li div").hover(
	  function () {
		  $(this).addClass('active');
	  },
	  function () {
		  $(this).parents().find('a').css({'text-decoration': 'none'});
	  }
	);
	/*
	if ($('.new .left_2:first').height() &gt; $('.new .right_2:first').height()) {
		$('.new-twitters .wide-content:first').css({height: $('.new .left_2:first').height() - $('.new .right_2:first').height() + $('.new-twitters .wide-content:first').height()});
	} else {
		$('.new-comments .wide-content:first').css({height: $('.new .right_2:first').height() - $('.new .left_2:first').height() + $('.new-comments .wide-content:first').height()});
	}
	*/
	$('.show-block .show a').click(function(){
		$('.show-block .show').toggle();
		$('.show-block .show a').toggleClass('active');
		if ($(this).hasClass('active')) {
			$(this).parent().parent().find('.show-content').stop(false, true).slideDown();
		} else {
			$(this).parent().parent().find('.show-content').stop(false, true).slideUp();
		}
		return false;
	});
	
	$('.statistic .show a').click(function(){
		$(this).toggleClass('active');
		if ($(this).hasClass('active')) $(this).parent().parent().find('.show-content').stop(false, true).show();
		else {
			$(this).parent().parent().find('.show-content').stop(false, true).hide();
		}
		return false;
	});
	
	$('.doc_text .file_list ul li a').each(function(){
		if ($(this).height() &lt; '30') {
			$(this).addClass('fname-mrg');
		}
	});

	$('#review .choose_line .select ul li span.text').each(function(){
		if ($(this).height() &gt; '20') {
			$(this).addClass('sel-text-fix');
		}
	});
	
	$('.form .fname, #register_page span.label.link').each(function(){
		if ($(this).height() &gt; '20') {
			$(this).addClass('fname-mrg');
		}
	});
	
	fileReady = function(){
		$('.form input.browse').css({opacity: 0});
		if (ie) $('.form input.browse').css({filter: 'alpha(opacity = 0)'});
		$('.form input.browse').hover(function(){
			$(this).parent().find('a').addClass('hover');
		}, function(){
			$(this).parent().find('a').removeClass('hover');
		});
	}
	fileReady();
	fileChange = function(obj){
		$input = '#' + obj;
		$str = $($input).val();
		var fileName = $str.split("\\");
		$($input).parent().find('.file').val(fileName[fileName.length - 1]);
	}
	
	$('.form .added-image').each(function(){
		if ($(this).find('div').height() &gt; '20') {
			$(this).addClass('added-mrg');
		}
	});
	
	$('#window a.btn2').click(function(){
		var tt = document.getElementById('window');
		tt.style.display = 'none';
	});
	
	$('.top-rating h2').each(function(){
		if ($(this).height() &gt; '20') {
			$(this).addClass('h2-mrg');
		}
	});
	
	topBlockTitle();
	
	$('.top-rating .more-show').click(function(){
		$(this).toggleClass('active');
		if ($(this).hasClass('active')) {
			$(this).parent().find('ul.more').slideDown();
			$(this).hide();
			$(this).removeClass('active')
			$(this).parent().find('.more-href').show();
		}
		return false;
	});
	
	$('.top-rating .more-href').click(function(){
		$(this).toggleClass('active');
		if ($(this).hasClass('active')) {
			$(this).parent().find('ul.more').slideUp();
			$(this).hide();
			$(this).removeClass('active')
			$(this).parent().find('.more-show').show();
		}
		return false;
	});
	
	if ($('#tabs-content2 .right:first').height() &gt; $('#tabs-content2 .left:first').height()) {
		$('#tabs-content2 .left:first').css({height: $('#tabs-content2 .right:first').height()-32});
	}
	
	$('.mlist div').each(function(){
		if ($(this).height() &gt; '40') {
			$(this).addClass('mrow');
		}
	});
	
	$('.mlist input').each(function(){
		if ($(this).attr('checked')) {
			$(this).parent().addClass('sel');
		}
	});
	
	$('.mlist a').click(function(){
		/*if ($(this).parent().hasClass('sel'))
			return false;
		$(this).parent().parent().find('.sel').removeClass('sel')
		$(this).parent().addClass('sel');*/
	});

  $('.mlist &gt; div').click(function(){
		if ($(this).hasClass('sel'))
			return false;
		$(this).parent().find('.sel').removeClass('sel')
		$(this).addClass('sel');
	});
	
	$('div.btn').each(function(){
		if (($(this).height() &gt; '30') &amp;&amp; ($(this).height() &lt; '50')) {
			$(this).addClass('btn-2row');
		} else {
			if ($(this).height() &gt; '50') {
				$(this).addClass('btn-3row');
			}
		}
	});
	
	$('#filter form select').each(function(){
		if ($(this).attr('disabled')) {
			$(this).addClass('disabled');
		}
	});
	
	if ($('.open-announcement .desc .img-block').length != '0' ) {
		$('.open-announcement .desc .seller p').css({'padding-top': $('.open-announcement .desc .img-block').height() / 2 - 11});
	}
	
	$('.dlist .comment-block').each(function(){
		if ($(this).find('.img-block').length == '0') {
			$(this).addClass('no-image');
		}
	});
	
	$('.catalog .info-block .content div').css({'margin-right': $('.catalog .info-block a.btn2').width() + 40});
	
	$(".results-table .tbody .tr a").click(function(e){e.stopPropagation();});
	$('.results-table .tbody .tr').click( function (e) {
		if(!$(this).next().hasClass('expanded')){
			if($('#td-ajax').parent().attr('id')=='expanded-div'){
				$('.results-table .sel').removeClass('sel');
				$('#td-ajax').hide();
				$('#td-ajax').appendTo($('body'));
				$('.expanded').remove();
			};
			$(this).addClass('sel');
			$(this).after('&lt;div class="expanded"&gt;&lt;div class="expand" id="expanded-div"&gt;&lt;/div&gt;&lt;/div&gt;');
			$('#td-ajax').appendTo($('#expanded-div'));
			$('#td-ajax').slideDown();
		} else{
		$('#td-ajax').slideUp(function() {
			hideSlide();
		});		
		}
	});
	
	function hideSlide(){
		$('.results-table .sel').removeClass('sel');
		$('#td-ajax').hide();
		$('#td-ajax').appendTo($('body'));
		$('.expanded').remove();		
	}
	
	$('.coupons p a, .coupons img, .coupons .discount').click(function(){
		$('.coupons .sel').removeClass('sel');
		$(this).parent().parent().addClass('sel');
		var tt = document.getElementById('coupons-tools');
		$(this).parent().parent().find('.tools').append(tt);
		if (tt.style.display != 'block') {
			tt.style.display = 'block';
		}
	});
	
	$('#coupons-tools a.close-win').click(function(){
		var tt = document.getElementById('coupons-tools');
		tt.style.display = 'none';
	});
	
	$('.wlist-top').each(function(){
		if ($(this).find('.img').length == '0') {
			$(this).addClass('no-image');
		}
	});
	
	$('.pwin .close').click(function(){
		$('.pwin-popup').hide();
	});
	
	$('.map-block li.how a').click(function(){
		//$('.pwin-popup').show();
	});
	
	$('.route').css({'overflow-y': 'auto', 'overflow-x': 'hidden'});
	
	$('.overlay').css({'opacity': '0.7'});
	
	resizeMap();
	mapControls();

        $('.sms-popup .answ-no').click(function(){
            $(this).parent().parent().find('p').text("Pؤ“c pogas Nؤ“ nospieإ،anas parؤپdؤپs cits teksts.");
            $(this).parent().remove();
        });
        
        //WWW list screen shot popup
        $('.wlist .preview').mouseover(function(){
            var eTop = $(this).offset().top - $(window).scrollTop();
            var of = ($(this).offset().top);
            eTop = (of &gt; eTop) ? of - eTop + 20 : 20
            $('span',this).css('top','-'+(of-eTop)+'px');
            $('span',this).css('height',$(window).height() - 40);
						if ($('span',this).height() &gt; $(this).find('img').height()) {
							$(this).find('img').css('margin-top',($('span',this).height() - $(this).find('img').height()) / 2);
						}
        });
        $('.wlist .preview').mouseout(function(){
            $('span',this).css('top','0px');
        });
	
	$('.gallery li').each(function(k){
		if (!$(this).hasClass('watch-more')) {
			$(this).parent().addClass('only-image');
			if(k%5){} else {$(this).addClass('first');$(this).next().next().next().next().addClass('last')}
		}
	});
	
	$('ul.about li, .wlist .txt, #profile .user_pic .user_links').css({'word-wrap': 'break-word'});
	
	if($('.popup.search-popup .slide').length){
    var autoPlayTime = 4000;
    autoPlayTimer = setInterval(autoPlay, autoPlayTime);
    var yPosition=($('.popup.search-popup .slide').height()-$('.popup.search-popup .slide .next').height()) / 2;
    $('.popup.search-popup .slide .next').css('top',yPosition);
    $('.popup.search-popup .slide .previous').css('top',yPosition);
    $('.popup.search-popup .slide &gt; div &gt; div').each(function(i){
      slideboxTotalContent=i*$('.popup.search-popup .slide').width();
      $('.popup.search-popup .slide &gt; div').css('width',slideboxTotalContent+$('.popup.search-popup .slide').width());
    });
	}
	function autoPlay(){
		Slidebox('next');
	}
        
        $('.form-popup .close').click(function(){
		$('.form-popup').hide();
	});
});

$(window).resize(function(){
	resizeMap();
});

function resizeMap(){

	var topHeight = 1;
	topHeight += $('#wrapper.map-page #header').height()
		+ parseInt( $('#wrapper.map-page #header').css('padding-top') )
		
	$('.result-list').height( $(window).height() - topHeight - $('#wrapper.map-page .calculate-top').height() - $('#wrapper.map-page .calculate-bottom').height() + 3);
		
	var toolsHeight = 1;
	toolsHeight += $('#wrapper.map-page .right .tools').height()
		+ parseInt( $('#wrapper.map-page .right .tools').css('padding-top') )
		
	var resultsHeight = 1;
	resultsHeight += $('#wrapper.map-page .place').height()
		+ parseInt( $('#wrapper.map-page .place').css('padding-top') )
		+ parseInt( $('#wrapper.map-page .place').css('padding-bottom') )
		+ $('#wrapper.map-page .filter').height()
		+ parseInt( $('#wrapper.map-page .filter').css('padding-top') )
		+ parseInt( $('#wrapper.map-page .filter').css('padding-bottom') )
		+ $('#wrapper.map-page .pagination-top').height()
		+ parseInt( $('#wrapper.map-page .pagination-top').css('padding-top') )
		+ parseInt( $('#wrapper.map-page .pagination-top').css('padding-bottom') )
		+ $('#wrapper.map-page .pagination-bottom').height()
		+ parseInt( $('#wrapper.map-page .pagination-bottom').css('padding-top') )
		+ parseInt( $('#wrapper.map-page .pagination-bottom').css('padding-bottom') )
		+ $('#wrapper.map-page .bttn').height()
		+ parseInt( $('#wrapper.map-page .bttn').css('padding-top') )
		+ parseInt( $('#wrapper.map-page .bttn').css('padding-bottom') )
	
	$('#wrapper.map-page .map').height( $(window).height() - topHeight - toolsHeight + 4 );
	
	$('.route').height( $(window).height() - topHeight - $('#wrapper.map-page .btn-block').height() + 3 )
	
	if ($('#wrapper.map-page .count').length != '0' ) {
		topHeight +=
			$('#wrapper.map-page .count').height()
	}
	
	if ($('#wrapper.map-page .search-block').length != '0' ) {
		topHeight +=
			$('#wrapper.map-page .search-block').height()
			+ parseInt( $('#wrapper.map-page .search-block').css('padding-top') )
			+ parseInt( $('#wrapper.map-page .search-block').css('padding-bottom') );
	}
	
	$('.mlist').height( $(window).height() - topHeight + 3 );
	/*$('.result-list').height( $(window).height() - topHeight - resultsHeight - 3 );*/
	$('.mblock').height( $(window).height() - topHeight + 3 );
	
	var rezHeight = 1;
	rezHeight += parseInt( $('#wrapper.map-page #rezults').css('margin-top') )
		+ parseInt( $('#wrapper.map-page #rezults').css('padding-bottom') )
		
	$('#wrapper.map-page #rezults.addresses-list').height( $(window).height() - topHeight - rezHeight + 4);
	
}

// Big promo block animation
function Slidebox(slideTo,autoPlay){
    var animSpeed=1000; //animation speed
    //var easeType='easeInOutExpo'; //easing type
    var sliderWidth=$('.popup.search-popup .slide').width();
    var leftPosition=$('.popup.search-popup .slide &gt; div').css("left").replace('px', '');
    if( !$('.popup.search-popup .slide &gt; div').is(':animated')){
        if(slideTo=='next'){ //next
            if(autoPlay=='stop'){
                clearInterval(autoPlayTimer);
            }
            if(leftPosition==-slideboxTotalContent){
                $('.popup.search-popup .slide &gt; div').animate({left: 0}, animSpeed); //reset
								
            } else {
                $('.popup.search-popup .slide &gt; div').animate({left: '-='+sliderWidth}, animSpeed); //next
								
            }
        } else if(slideTo=='previous'){ //previous
            if(autoPlay=='stop'){
                clearInterval(autoPlayTimer);
            }
            if(leftPosition=='0'){
                $('.popup.search-popup .slide &gt; div').animate({left: '-'+slideboxTotalContent}, animSpeed); //reset
								
            } else {
                $('.popup.search-popup .slide &gt; div').animate({left: '+='+sliderWidth}, animSpeed); //previous
								
            }
        } else {
            var slide2=(slideTo-1)*sliderWidth;
            if(leftPosition!=-slide2){
                clearInterval(autoPlayTimer);
                $('.popup.search-popup .slide &gt; div').animate({left: -slide2}, animSpeed); //go to number
								
            }
        }
    }
}
	
function anlistHeight() {
	$('.anlist .first').each(function() {
		var h = $(this).find('h2').height() &gt; $(this).next().find('h2').height() ? $(this).find('h2').height() : $(this).next().find('h2').height();
		h = h &gt; $(this).next().next().find('h2').height() ? h : $(this).next().next().find('h2').height();
		h = h &gt; $(this).next().next().next().find('h2').height() ? h : $(this).next().next().next().find('h2').height();
		
		$(this).find('h2').height(h);
		$(this).next().find('h2').height(h);
		$(this).next().next().find('h2').height(h);
		$(this).next().next().next().find('h2').height(h);
	});
}
	
function tdHeight() {
	$('.results-table .c1').each(function() {
		var h = $(this).height() &gt; $(this).next().height() ? $(this).height() : $(this).next().height();
		h = h &gt; $(this).next().next().height() ? h : $(this).next().next().height();
		h = h &gt; $(this).next().next().next().height() ? h : $(this).next().next().next().height();
		h = h &gt; $(this).next().next().next().next().height() ? h : $(this).next().next().next().next().height();
		h = h &gt; $(this).next().next().next().next().next().height() ? h : $(this).next().next().next().next().next().height();
		h = h &gt; $(this).next().next().next().next().next().next().height() ? h : $(this).next().next().next().next().next().next().height();
		
		$(this).height(h);
		$(this).next().height(h);
		$(this).next().next().height(h);
		$(this).next().next().next().height(h);
		$(this).next().next().next().next().height(h);
		$(this).next().next().next().next().next().height(h);
		$(this).next().next().next().next().next().next().height(h);
	});
}

function topBlockTitle() {
	$('.top-block .first').each(function() {
		var h = $(this).find('.title').height() &gt; $(this).next().find('.title').height() ? $(this).find('.title').height() : $(this).next().find('.title').height();
		h = h &gt; $(this).next().next().find('.title').height() ? h : $(this).next().next().find('.title').height();
		
		$(this).find('.title').height(h);
		$(this).next().find('.title').height(h);
		$(this).next().next().find('.title').height(h);
	});
}

function href() {
	$('div.list li').click(function() {
		console.log("href");
		//window.location = $('a',this).attr('href');
	});
}

function href2() {
	$('#new-coupons li div').hover(function() {
		$(this).parent().addClass('hover');
	}, function() {
		$(this).parent().removeClass('hover');
	}).click(function() {
		console.log("href 2");
		//window.location = $('a',this.parent).attr('href');
	});
}

function href3() {
	$('.links div span').hover(function() {
		$(this).parent().parent().find('a.img').addClass('hover');
	}, function() {
		$(this).parent().parent().find('a.img').removeClass('hover');
	}).click(function() {
		console.log("href3");
		//window.location = $('a.img',this.parent).attr('href');
	});
}

/*function coupons_href() {
	$('.coupons .discount').hover(function() {
		$(this).parent().addClass('hover');
	}, function() {
		$(this).parent().removeClass('hover');
	}).click(function() {
		window.location = $('.link a',this.parent).attr('href');
	});
}*/

function dlist_href() {
	$('.dlist .img-block').click(function() {
		window.location = $(this).parent().parent().find('.tools a').attr('href');
	});
}

function gallery_href() {
	/*$('.gallery .img-block').click(function() {
		window.location = $('a',this).attr('href');
	});*/
}

function btn_href() {
	$('div.btn').click(function() {
		window.location = $('a',this).attr('href');
	});
}

function hover() {
	$('.links .tools a').hover(function() {
		$(this).parent().parent().find('a.img').addClass('hover');
	}, function() {
		$(this).parent().parent().find('a.img').removeClass('hover');
	});
}

function graph_hover() {
	$('.statistic .graph-block span').hover(function() {
		$(this).parent().addClass('hover');
	}, function() {
		$(this).parent().removeClass('hover');
	});
	$('.statistic .graph .count').hover(function() {
		$(this).parent().addClass('hover');
	}, function() {
		$(this).parent().removeClass('hover');
	});
}

function mlist_hover() {
	$('.mlist input').hover(function() {
		$(this).parent().addClass('hover');
	}, function() {
		$(this).parent().removeClass('hover');
	});
}

function this_hover() {
	$('.dlist').hover(function() {
		$(this).addClass('dlist-hover');
	}, function() {
		$(this).removeClass('dlist-hover');
	});
}

function label_middle() {
	$('.form .fname').each(function(){
		if ($(this).height() &gt; '20') {
			$(this).addClass('fname-mrg');
		}
	});
}

function filterHeight(){

	var fHeight = 1;
	fHeight += $('#filter .top').height()
		+ $('#filter .bottom').height()
		+ parseInt( $('#filter .content-block').css('padding-top') )
		+ parseInt( $('#filter .content-block').css('padding-bottom') )
		+ parseInt( $('#filter').css('margin-top') )
	
	if ($('.announcements .right_2').height() &gt; ($('#filter').height() - 22)) {
		$('#filter .content-block').css({height: $('.announcements .right_2').height() - fHeight + 2});
	}
	
}

function showSMS(o, event) {
	$('#sms-popup').show();
	$('#sms-popup .cont').css('top','200px');
	changeSmsCaptcha();
}

function showWin(o, event, text) {
	var tt = document.getElementById('window');
	if (tt.style.display != 'block') { 
		document.getElementById('window-text').innerHTML = text;
		document.getElementById('hnt').appendChild(tt);
		tt.style.display = 'block';
	}
	/*if(event!=null){
		var xy  = getMouseXY(event);
	} else {
		var opos=$(o).position();
		var xy = new Array();
		xy[0]=opos.left;
		xy[1]=opos.top;
	}*/
	//tt.style.left = xy[0] + 5 + 'px';
	//tt.style.top  = xy[1] + 12 + 'px';
	return tt;
}
function hideHint() {
	var tt = document.getElementById('hint');
	tt.style.display = 'none';
}
/* -------------- */
function getMouseXY(e) {
	var tempX = 0;
	var tempY = 0;
	var scrollxy = getScrollXY();
 
	if (!e) var e = window.event;
	if (e.clientX || e.clientY) {
		tempX = e.clientX + scrollxy[0];
		tempY = e.clientY + scrollxy[1];
	} else if (e.pageX || e.pageY) {
		tempX = e.pageX;
		tempY = e.pageY;
	}
	return [ tempX, tempY ];
}
function getScrollXY() {
	var scrOfX = typeof window.pageXOffset != 'undefined' ? window.pageXOffset:document.documentElement &amp;&amp; document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
	var scrOfY = typeof window.pageYOffset != 'undefined' ? window.pageYOffset:document.documentElement &amp;&amp; document.documentElement.scrollTop  ? document.documentElement.scrollTop  : document.body.scrollTop  ? document.body.scrollTop  : 0;
	return [ scrOfX, scrOfY ];
}
function findPosXY(obj) {
	var curleft = 0;
	var curtop  = 0;	
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop  += obj.offsetTop	
			obj = obj.offsetParent;
		}
	} else if (obj.x) {
		curleft += obj.x;
		curtop  += obj.y;
	}
	var res = new Array(curleft, curtop);
	return res;
}

function switchBottomMenu(type){
	switch(type){
		case 'all':
			var hide='about';
			break;
		case 'about':
			var hide='all';
			break;
	}
	$("#switch_"+hide).removeClass("sel");
	$("#switch_"+type).addClass("sel");
	$("#bottom_"+type).show();
	$("#bottom_"+hide).hide();
}

function equalHeight(group) {
	var tallest = 0;
	group.each(function() {
		var thisHeight = $(this).height();
		if(thisHeight &gt; tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}

equalHeight($("td.height"));

function doCatalogSearch(clearAddressCookie){
	clearAddressCookie = typeof clearAddressCookie !== 'undefined' ? clearAddressCookie : 1;
	var onlyDefault=0;
	var whereEmpty=0;
	var whatEmpty=0;
	var onlyEmpty=0;
	var combinedNothing=0;
	var emptyOptions = ["*"];
	if($("what").val() != currentWhat) { 
		$("#searchForm").attr('action', globalDefaultSearchLink);
	}
	if (defaultWhere == $('#where').val() &amp;&amp; defaultWhat == $('#what').val()){
		onlyDefault=1;
	}
	var where=$("#where").val();
	if(where.match(/^\*+$/)){
		whereEmpty=1;
	}
	if(where.match(/^[\'\"]+$/)){
		whereEmpty=1;
	}
	var what=$("#what").val();
	if(what.match(/^\*+$/)){
		whatEmpty=1;
	}
	if(what.match(/^[\'\"]+$/)){
		whatEmpty=1;
	}
	if(whereEmpty &amp;&amp; whatEmpty){
		onlyEmpty=1;
	}
	if((defaultWhere == $('#where').val() &amp;&amp; whatEmpty) || (defaultWhat == $('#what').val() &amp;&amp; whereEmpty)){
		combinedNothing=1;
	}
	if(onlyEmpty || combinedNothing){
		$("#where").val(defaultWhere);
	$("#what").val(defaultWhat);
	}
	if(onlyDefault || onlyEmpty || combinedNothing){
		return false;
	}
        //alert('tresty');
	if(clearAddressCookie){
		$.cookie('address_set', null, {path: '/'});
	}
        //$.cookie("address_set", "1"); 
	$("#searchForm").submit();
}

function mapControls(){
    var imgUrl;
    $('.map-controls a').hover(
        function () {
            imgUrl = $('img',this).attr('src').split('.');
            $('img',this).attr('src',imgUrl[0]+"-hover."+imgUrl[1]);
        }, 
        function () {
            $('img',this).attr('src',imgUrl[0]+"."+imgUrl[1]);
        }
    );
}

function downloadCuponChoose(id, lang){
	$("#cupon-id").val(id);
	$("#cupon-lang").val(lang);
	$("#coupons-tools").show();
}

function downloadCupon(action){
	var id=$("#cupon-id").val();
	var lang=$("#cupon-lang").val();
	var w=990;
	var h=600;
	var left = (screen.width/2)-(w/2);
	var top = (screen.height/2)-(h/2);
	var cupon=window.open('/bulk/save_cupon.php?id='+id+'&amp;lang='+lang+'&amp;action='+action, 'cuponWindow','menubar=0,resizable=1,left='+left+',top='+top+',width='+w+',height='+h);
}

function prepareSMS(o, event, sms_type, sms_company_id){
	$("#sms_type").val(sms_type);
	$("#sms_company_id").val(sms_company_id);
	$("#mobile-number").val("");
	$("#sms-success-message").html("");
	$("#sms-success-message").hide();
	$("#sms-fail-message").html("");
	$("#sms-fail-message").hide();
	showSMS(o, event);
	$("#mobile-number").focus();
}

function sendSMS(lang){
	$("#sms-success-message").hide();
	$("#sms-fail-message").hide();
	var phone=$("#mobile-number").val();
	var sms_type=$("#sms_type").val();
	var sms_company_id=$("#sms_company_id").val();
	var captcha=$("#sms-captcha").val();
	$.post("/ajax/sms.php", { "lang": lang, "action": "send", "sms_type": sms_type, "phone": phone, "sms_company_id":sms_company_id, "captcha": captcha},
	  function(data){
		if( data.ok == 1 ){
			if(data.success){
				$("#mobile-number").val("");
				$("#sms-success-message").html(data.msg);
				$("#sms-success-message").show();
			} else {
				$("#sms-fail-message").html(data.msg);
				$("#sms-fail-message").show();
			}
		}
		changeSmsCaptcha();
	  }
   , "json");
}

jQuery.timer = function(interval, callback, options) {
	var options = jQuery.extend({ reset: 500 }, options); // Create options for the default reset value
	var interval = interval || options.reset;
	
	if(!callback) { return false; }
	
	timer = function(interval, callback) {
		// Only used by internal code to call the callback
		this.internalCallback = function() { callback(self); };
	
		// Clears any timers
		this.stop = function() { clearInterval(self.id); };
		// Resets timers to a new time
		this.reset = function(time) {
			if(self.id) { clearInterval(self.id); }
			var time = time || options.reset;
			
			this.id = setInterval(this.internalCallback, time);
		};
		
		// Set the interval time again
		this.interval = interval;
		this.id = setInterval(this.internalCallback, this.interval);
		
		var self = this;
	};
	
	// Create a new timer object
	return new timer(interval, callback);
};

/**
 * jQuery.ScrollTo
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 *
 * @projectDescription Easy element scrolling using jQuery.
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 * Works with jQuery +1.2.6. Tested on FF 2/3, IE 6/7/8, Opera 9.5/6, Safari 3, Chrome 1 on WinXP.
 *
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * @id jQuery.scrollTo
 * @id jQuery.fn.scrollTo
 * @param {String, Number, DOMElement, jQuery, Object} target Where to scroll the matched elements.
 *	  The different options for target are:
 *		- A number position (will be applied to all axes).
 *		- A string position ('44', '100px', '+=90', etc ) will be applied to all axes
 *		- A jQuery/DOM element ( logically, child of the element to scroll )
 *		- A string selector, that will be relative to the element to scroll ( 'li:eq(2)', etc )
 *		- A hash { top:x, left:y }, x and y can be any kind of number/string like above.
*		- A percentage of the container's dimension/s, for example: 50% to go to the middle.
 *		- The string 'max' for go-to-end. 
 * @param {Number} duration The OVERALL length of the animation, this argument can be the settings object instead.
 * @param {Object,Function} settings Optional set of settings or the onAfter callback.
 *	 @option {String} axis Which axis must be scrolled, use 'x', 'y', 'xy' or 'yx'.
 *	 @option {Number} duration The OVERALL length of the animation.
 *	 @option {String} easing The easing method for the animation.
 *	 @option {Boolean} margin If true, the margin of the target element will be deducted from the final position.
 *	 @option {Object, Number} offset Add/deduct from the end position. One number for both axes or { top:x, left:y }.
 *	 @option {Object, Number} over Add/deduct the height/width multiplied by 'over', can be { top:x, left:y } when using both axes.
 *	 @option {Boolean} queue If true, and both axis are given, the 2nd axis will only be animated after the first one ends.
 *	 @option {Function} onAfter Function to be called after the scrolling ends. 
 *	 @option {Function} onAfterFirst If queuing is activated, this function will be called after the first scrolling ends.
 * @return {jQuery} Returns the same jQuery object, for chaining.
 *
 * @desc Scroll to a fixed position
 * @example $('div').scrollTo( 340 );
 *
 * @desc Scroll relatively to the actual position
 * @example $('div').scrollTo( '+=340px', { axis:'y' } );
 *
 * @dec Scroll using a selector (relative to the scrolled element)
 * @example $('div').scrollTo( 'p.paragraph:eq(2)', 500, { easing:'swing', queue:true, axis:'xy' } );
 *
 * @ Scroll to a DOM element (same for jQuery object)
 * @example var second_child = document.getElementById('container').firstChild.nextSibling;
 *			$('#container').scrollTo( second_child, { duration:500, axis:'x', onAfter:function(){
 *				alert('scrolled!!');																   
 *			}});
 *
 * @desc Scroll on both axes, to different values
 * @example $('div').scrollTo( { top: 300, left:'+=200' }, { axis:'xy', offset:-20 } );
 */
;(function( $ ){
	
	var $scrollTo = $.scrollTo = function( target, duration, settings ){
		$(window).scrollTo( target, duration, settings );
	};

	$scrollTo.defaults = {
		axis:'xy',
		duration: parseFloat($.fn.jquery) &gt;= 1.3 ? 0 : 1
	};

	// Returns the element that needs to be animated to scroll the window.
	// Kept for backwards compatibility (specially for localScroll &amp; serialScroll)
	$scrollTo.window = function( scope ){
		return $(window)._scrollable();
	};

	// Hack, hack, hack :)
	// Returns the real elements to scroll (supports window/iframes, documents and regular nodes)
	$.fn._scrollable = function(){
		return this.map(function(){
			var elem = this,
				isWin = !elem.nodeName || $.inArray( elem.nodeName.toLowerCase(), ['iframe','#document','html','body'] ) != -1;

				if( !isWin )
					return elem;

			var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem;
			
			return $.browser.safari || doc.compatMode == 'BackCompat' ?
				doc.body : 
				doc.documentElement;
		});
	};

	$.fn.scrollTo = function( target, duration, settings ){
		if( typeof duration == 'object' ){
			settings = duration;
			duration = 0;
		}
		if( typeof settings == 'function' )
			settings = { onAfter:settings };
			
		if( target == 'max' )
			target = 9e9;
			
		settings = $.extend( {}, $scrollTo.defaults, settings );
		// Speed is still recognized for backwards compatibility
		duration = duration || settings.speed || settings.duration;
		// Make sure the settings are given right
		settings.queue = settings.queue &amp;&amp; settings.axis.length &gt; 1;
		
		if( settings.queue )
			// Let's keep the overall duration
			duration /= 2;
		settings.offset = both( settings.offset );
		settings.over = both( settings.over );

		return this._scrollable().each(function(){
			var elem = this,
				$elem = $(elem),
				targ = target, toff, attr = {},
				win = $elem.is('html,body');

			switch( typeof targ ){
				// A number will pass the regex
				case 'number':
				case 'string':
					if( /^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ) ){
						targ = both( targ );
						// We are done
						break;
					}
					// Relative selector, no break!
					targ = $(targ,this);
				case 'object':
					// DOMElement / jQuery
					if( targ.is || targ.style )
						// Get the real position of the target 
						toff = (targ = $(targ)).offset();
			}
			$.each( settings.axis.split(''), function( i, axis ){
				var Pos	= axis == 'x' ? 'Left' : 'Top',
					pos = Pos.toLowerCase(),
					key = 'scroll' + Pos,
					old = elem[key],
					max = $scrollTo.max(elem, axis);

				if( toff ){// jQuery / DOMElement
					attr[key] = toff[pos] + ( win ? 0 : old - $elem.offset()[pos] );

					// If it's a dom element, reduce the margin
					if( settings.margin ){
						attr[key] -= parseInt(targ.css('margin'+Pos)) || 0;
						attr[key] -= parseInt(targ.css('border'+Pos+'Width')) || 0;
					}
					
					attr[key] += settings.offset[pos] || 0;
					
					if( settings.over[pos] )
						// Scroll to a fraction of its width/height
						attr[key] += targ[axis=='x'?'width':'height']() * settings.over[pos];
				}else{ 
					var val = targ[pos];
					// Handle percentage values
					attr[key] = val.slice &amp;&amp; val.slice(-1) == '%' ? 
						parseFloat(val) / 100 * max
						: val;
				}

				// Number or 'number'
				if( /^\d+$/.test(attr[key]) )
					// Check the limits
					attr[key] = attr[key] &lt;= 0 ? 0 : Math.min( attr[key], max );

				// Queueing axes
				if( !i &amp;&amp; settings.queue ){
					// Don't waste time animating, if there's no need.
					if( old != attr[key] )
						// Intermediate animation
						animate( settings.onAfterFirst );
					// Don't animate this axis again in the next iteration.
					delete attr[key];
				}
			});

			animate( settings.onAfter );			

			function animate( callback ){
				$elem.animate( attr, duration, settings.easing, callback &amp;&amp; function(){
					callback.call(this, target, settings);
				});
			};

		}).end();
	};
	
	// Max scrolling position, works on quirks mode
	// It only fails (not too badly) on IE, quirks mode.
	$scrollTo.max = function( elem, axis ){
		var Dim = axis == 'x' ? 'Width' : 'Height',
			scroll = 'scroll'+Dim;
		
		if( !$(elem).is('html,body') )
			return elem[scroll] - $(elem)[Dim.toLowerCase()]();
		
		var size = 'client' + Dim,
			html = elem.ownerDocument.documentElement,
			body = elem.ownerDocument.body;

		return Math.max( html[scroll], body[scroll] ) 
			 - Math.min( html[size]  , body[size]   );
			
	};

	function both( val ){
		return typeof val == 'object' ? val : { top:val, left:val };
	};

})( jQuery );


$(window).load(function() {

	$('.form .fname, #register_page span.label.link').each(function(){
		if ($(this).height() &gt; '20') {
			$(this).addClass('fname-mrg');
		}
	});
	 
});

var startedExactAddressForm = false;
var startedCountrySide = false;
var startedVillage = false;
var startedStreetAC = false;
var startedFreeHouseAC = false;
function selectField() {
	$(document).unbind('click.selectField');
	$(document).bind('click.selectField', function(e) {

		if ($(e.target).parents('.select').length &gt; 0)
		{return;}

		$('.select ul').hide();
	});

	var hasFocus = true;
	$('dt a').focus(function(e){
		/*$('.select ul').slideUp(100);*/
		var ddBox = $(this).parents('.select:first').find('ul:first');
		ddBox.slideDown(100);
		hasFocus = true;
	});

	/*bugging
	 *$('dt').blur(function(e){
		var ddBox = $(this).parents('.select:first').find('ul:first');
		setTimeout(function(){
			ddBox.slideUp(100)
		},100);
		hasFocus = true;
	});*/

	if ($('.select').size()) {

		$('dt a').click(function() {
			var ddBox = $(this).parents('.select:first').find('ul:first');

			if(hasFocus == false)
			{
				ddBox.slideUp(100);
				hasFocus = true;
			}else
			{
				ddBox.slideDown(100);
				hasFocus = false;
			}
		});

		$('dd ul a').click(function() {
			
			id = $(this).attr('id');
			$(this).parents('.select:first').find('dt a span').html($(this).text());
			//$(this).parents('.select:first').find('*[name=location]',s).val(id);
			var inp = $(this).parents('.select:first').parent().parent().find('input[type="hidden"]:first').val(id).change();
			$(this).parents('.select:first').find('ul').hide();
			hasFocus = true;
			if ($(this).parents('.select:first').parent().parent().find('input[type="hidden"]:first').attr('id') == 'comp_id') {
				//alert('validate company data click');
				checkField($(this).parents('.select:first').parent().parent().find('input[type="hidden"]:first'), true);
			}
			// This used in companies list output
			if ($('input[type="hidden"].comp_dropdown').length &gt; 0) {
				var setofPage = null;

				if (!id.search("distanceby_")) {
					$('#distanceby').val(id.replace('distanceby_', ''));
					setofPage = 1;
				}

				if (!id.search("cityby_")) {
					$('#cityby').val(id.replace('cityby_', ''));
					setofPage = 1;
				}

				if (!id.search("orderby_")) {
					$('#orderby').val(id.replace('orderby_', ''));
				}

				doExtraSearch(setofPage);
			}

			// This is used for map list output
			if ($('input[type="hidden"].map_list_orderby').length &gt; 0) {
				if (!id.search("orderby_")) {
					$('#orderby').val(id.replace('orderby_', ''));
				}
				changeOrder();
			}

			// This is used for company edit form
			if ($('input[type="hidden"].adr_edit_field').length &gt; 0 &amp;&amp; parseInt($('input[type="hidden"].adr_edit_field').val()) == 1) {
				if (!id.search("adr_country_")) {
					var new_val1 = id.replace('adr_country_', '');
					$('#country').val(new_val1);
					showExactAddressForm(new_val1);
				}
				else if (!id.search("adr_citydistrict_")) {
					var new_val2 = id.replace('adr_citydistrict_', '');
					$('#citydistrict').val(new_val2);
					$('#parish').parent().children().next().children().children().children().children().children().html(txtOptionSelect);
					$('#village').parent().children().next().children().children().children().children().children().html(txtOptionSelect);
					showCountrySide(new_val2, $('#country').val());
				}
				else if (!id.search("adr_parish_")) {
					var new_val3 = id.replace('adr_parish_', '');
					$('#parish').val(new_val3);
					$('#village').parent().children().next().children().children().children().children().children().html(txtOptionSelect);
					showVillage(new_val3);
				}
				else if (!id.search("adr_village_")) {
					var new_val4 = id.replace('adr_village_', '');
					$('#village').val(new_val4);
					cityORvillage = 'village';
					cityORvillageParent = new_val4;
					defineStreetAC();
				}
				else if (!id.search("adr_house_")) {
					$('#house').val(id.replace('adr_house_', ''));
				}
				else if (!id.search("adr_postal_")) {
					$('#postal').val(id.replace('adr_postal_', ''));
				}
				//selectField($('.select'));
			}
		});
	}

	//Disable page scrolling on pressed arrow key &amp; add controls to dropdown class="select" element
	$('.select').keydown(function(e) {

		$(this).find('ul:first').slideDown(100);
		var selectedLi = $(this).find('li.selected');
		var id = selectedLi.find('a').attr('id');
		
		this.allOK = function(){

			if( $(selectedLi).text() != '' )
			{
				$(this).find('dt a span').html($(selectedLi).text());
				$(this).parent().parent().find('input[type="hidden"]:first').val(id);
			}
			$(this).find('li.selected').removeClass('selected');
			$(this).find('ul').hide();
			hasFocus = true;
			if ($(this).parent().parent().find('input[type="hidden"]:first').attr('id') == 'comp_id') {
				//alert('validate company data on key');
				checkField($(this).parent().parent().find('input[type="hidden"]:first').attr('id'), true);
			}
			// This used in companies list output
			if ($('input[type="hidden"].comp_list_orderby').length &gt; 0 &amp;&amp; $('input[type="hidden"].comp_list_cityby').length &gt; 0) {
				if (!id.search("orderby_")) {
					$('#orderby').val(id.replace('orderby_', ''));
				}
				if (!id.search("cityby_")) {
					$('#cityby').val(id.replace('cityby_', ''));
				}
				if (!id.search("distanceby_")) {
					$('#distanceby').val(id.replace('distanceby_', ''));
				}
				doExtraSearch();
			}
			// This is used for map list output
			if ($('input[type="hidden"].map_list_orderby').length &gt; 0) {
				if (!id.search("orderby_")) {
					$('#orderby').val(id.replace('orderby_', ''));
				}
				changeOrder();
			}
			// This is used for company edit form
			if ($('input[type="hidden"].adr_edit_field').length &gt; 0 &amp;&amp; parseInt($('input[type="hidden"].adr_edit_field').val()) == 1) {
				if (!id.search("adr_country_")) {
					var new_val1 = id.replace('adr_country_', '');
					$('#country').val(new_val1);
					showExactAddressForm(new_val1);
				}
				else if (!id.search("adr_citydistrict_")) {
					var new_val2 = id.replace('adr_citydistrict_', '');
					$('#citydistrict').val(new_val2);
					$('#parish').parent().children().next().children().children().children().children().children().html(txtOptionSelect);
					$('#village').parent().children().next().children().children().children().children().children().html(txtOptionSelect);
					showCountrySide(new_val2, $('#country').val());
				}
				else if (!id.search("adr_parish_")) {
					var new_val3 = id.replace('adr_parish_', '');
					$('#parish').val(new_val3);
					$('#village').prev().children().children().children().children().children().children().html(txtOptionSelect);
					showVillage(new_val3);
				}
				else if (!id.search("adr_village_")) {
					var new_val4 = id.replace('adr_village_', '');
					$('#village').val(new_val4);
					cityORvillage = 'village';
					cityORvillageParent = new_val4;
					defineStreetAC();
				}
				else if (!id.search("adr_house_")) {
					$('#house').val(id.replace('adr_house_', ''));
				}
				else if (!id.search("adr_postal_")) {
					$('#postal').val(id.replace('adr_postal_', ''));
				}
				//selectField($('.select'));
			}
			return false;
		}

		this.selectDD = function(next)
		{
			var topX = next.position();
			var ul = next.parents('ul:first');
			var top = topX.top + ul.scrollTop();

			if(topX.top &lt;= 0 || topX.top &gt;= ul.height()){
				ul.scrollTop(top);
			}
		}
		

		var chcode = e.charCode || e.keyCode;

		switch (chcode) {
			//up
			case 40:
				e.preventDefault();
				if(selectedLi.length){
					if($(this).find('li.selected').next().length &gt; 0){
						$(this).find('li.selected').next().addClass('selected-temp');
						$(this).find('li.selected').removeClass('selected');
					}
					else{
						$(this).find('li:first').addClass('selected-temp');
						$(this).find('li.selected').removeClass('selected');
					}
					next = $(this).find('li.selected-temp').removeClass('selected-temp').addClass('selected');
				}
				else{
					next = $(this).find('li:first').addClass('selected');
				}
				var topX = next.position();
				var ul = next.parents('ul:first');
				var top = topX.top - ul.height() + ul.scrollTop()+next.height();
				if(topX.top&lt;0 || topX.top &gt; ul.height()-next.height()){
					ul.scrollTop(top);
				}

				return false;
				break;

			case 38://up

				e.preventDefault();
				if(selectedLi.length){
					if($(this).find('li.selected').prev().length &gt; 0){
						$(this).find('li.selected').prev().addClass('selected-temp');
						$(this).find('li.selected').removeClass('selected')
					}
					else{
						$(this).find('li:last').addClass('selected-temp');
						$(this).find('li.selected').removeClass('selected');
					}
					next = $(this).find('li.selected-temp').removeClass('selected-temp').addClass('selected');
				}
				else{
					next = $(this).find('li:first').addClass('selected');
				}
				this.selectDD(next);

				return false;
				break;

			case 13: //enter

				return this.allOK();
				break;

			case 32: //space
				e.preventDefault();
				return this.allOK();
				break;

			case 27: //esc
				$(this).find('ul').hide();
				hasFocus = true;
				break;

			default:
				if(e.ctrlKey || e.altKey || e.metaKey){
					return true;
				}

				if(!translit.cObject[lang][chcode] )
				{
					return true;
				}
				var letter = translit.cObject[lang][chcode];
				letter = letter.toLowerCase();

				

				var index = 0;
				if(selectedLi.length)
				{
					index = selectedLi.index();

					if(index == selectedLi.parent().find('li').length-1)
					{
						index = 0;
					}
				}
				var it = this;

				var next;
				$(this).find('li').each( function(k){
					
					if(k&lt;index)
					{
						return true;
					}
					var txt = $(this).text().toLowerCase().substring(0,1);
					if(txt == letter)
					{
						
						if($(this).hasClass("selected"))
						{
							return true;
						}
						next = $(this).addClass('selected');
						it.selectDD(next);
						$(it).find(".selected").not(next).removeClass("selected");
						return false;
					}
					if($(it).find('li').length-1 == k)
					{
						$(it).find('li').each( function(k){
							var txt = $(this).text().toLowerCase().substring(0,1);
							if(txt == letter)
							{
								next = $(this).addClass('selected');
								it.selectDD(next);
								$(it).find(".selected").not(next).removeClass("selected");
								return false;
							}
						});
					}
				});
				return false;
				break;
		}

	});
}
</pre></body></html>