var PERIOD = 30000;//30 sec
var APP_HOME = document.location.protocol+"//"+document.location.host + "/app";
var $ = jQuery.noConflict();

$(document).ready(function(){
	$('.nav-inner>ul>li','#nav').bind("mouseenter mouseleave",function(){
		$(this).toggleClass('hover');
	});
	$('.free-label').bind("mouseenter mouseleave",function(){
		$('.nav-inner>ul>li:last','#nav').toggleClass('hover');
	});
	
	var isSearchInput = false;
	$("#searchform #s").bind("focus",function(){
		var regex = new RegExp( "[?&]s=([^&#]*)" );
		if(!regex.exec( window.location.href )) {
			$(this).val('');	
		}
		isSearchInput = true;
	});
	$("#searchform").bind("submit",function(){
		var regex = new RegExp( "[?&]s=([^&#]*)" );
		if(regex.exec( window.location.href )) {
			isSearchInput = true;
		}
		regex = new RegExp( "[?&]d=([^&#]*)" );
		var f = '';
		if( f = regex.exec( window.location.href )) {
			$("#searchform input[name=d]").val(f[1]);
		}
		if( $("#searchform #s").val().length<3 || !isSearchInput ) {
			alert("Please input at least 3 symbols into search box");
			return false;
		}
	});
	
	if (typeof(ping) !== 'undefined') {
		ping(PERIOD, APP_HOME);
	}
	if (typeof(FB) !== 'undefined') {
		FB.init({appId: '', status: true, cookie: true, xfbml: true});
	}
})


