var Site = {

	em: function() {

		document.write('<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#105;&#110;&#102;&#111;&#64;&#100;&#101;&#99;&#111;&#114;&#111;&#115;&#115;&#101;&#101;&#108;&#46;&#98;&#101;">&#105;&#110;&#102;&#111;&#64;&#100;&#101;&#99;&#111;&#114;&#111;&#115;&#115;&#101;&#101;&#108;&#46;&#98;&#101;</a>');

	},

	gcf: function(parent) {

		// define parent id
		var parent_id = parent.attr('class');
		parent_id = parent_id.replace(/\D/g,'');

		if(parent_id) {

			jQuery.get(
				'/assets/bin/services.php',
				{a:'gcf',p:parent_id},
				function(html) {

					// append html
					parent.append(html);

					// autoselect first field
					jQuery('input[type="text"]:first',parent).select();

				}
			);

		}

	},

	ts: function(e) {

		if(e.which == 13) form.search.submit();

	},

	tsi: function(q,s) {

	    if(q=='focus') { if(jQuery.trim(jQuery('input[name="q"]').val())==s) jQuery('input[name="q"]').attr('value',''); }
	    else { if(jQuery.trim(jQuery('input[name="q"]').val())=='') jQuery('input[name="q"]').attr('value',s); }

	}

};

// execute some scripts when document is loaded
jQuery(document).ready(function(){

	// home
	if(jQuery('body#home').length) {

		jQuery('#slideshow-wrapper .slideshow ul').bxSlider({auto:true,mode:'fade',pager:true,pause:4000,speed:2000,controls:false});

		// fix p height
		var max_p=0;
		jQuery('#content .lay4col .col').each(function(){if(jQuery('p',this).height()>max_p)max_p=jQuery('p',this).height();});
		jQuery('#content .lay4col .col p').css({height:max_p+'px'});

	}

	// search - bind events
	jQuery('input[name="q"]').bind('focus',function(){Site.tsi('focus',LNG.defaultKeyword);});
	jQuery('input[name="q"]').bind('blur',function(){Site.tsi('blur',LNG.defaultKeyword);});
	jQuery('input[name="q"]').bind('keyup',function(){Site.ts(event);});

	// autocomplete
	jQuery('input[name="q"]').autocomplete('/assets/bin/services.php',{autoFill:false,max:10,selectFirst:false,selectOnly:true,extraParams:{a:'s',l:LNG.language}});
	jQuery('input[name="q"]').result(function(){this.form.submit();});

	// verosol
	jQuery('img.video-thumb[class*=verosol-]').each(function(){jQuery(this).parent().fancybox({padding:'20px',autoScale:false,transitionIn:'none',transitionOut:'none'});});

});
