//This Functin is used for removing the space from the input Query for searching//
function trim(str)
{
	return str.replace(/^\s*|\s*$/g,"");
}

//This is used for mail vaildation//

function ValidateEmail(emailval)
{
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
			
			if(reg.test(emailval) == false) 
			{
              return false;
			}
			else
			return true;
}

function ValidateUrl(val) {
    var v = new RegExp();
    v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
	if (val.indexOf("http:")<=-1 && val.indexOf("https:")<=-1 && val.indexOf("ftp:")<=-1)
		return false;

	if (!v.test(val)) {
        
        return false;
    }
	return true;
} 

//This function is used to create the cookie. For creating the cookie we have to pass 3 perameter name ,value and time. //

function createCookie(name,value,days) 
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else 
		var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
	//alert(readCookie(name));

}
//This function is used when we want check whether the cookies has been created or not. For checking we have to pass the parameter 'name'. If incase it not created then first create it// 

function readCookie(name)
{
	var nameEQ = name + "=";
	//alert(nameEQ);  
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) 
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) 
			return c.substring(nameEQ.length,c.length);
	}
	return null;
}

// This is used to erased the cookie//

function eraseCookie(name) 
{
	createCookie(name,"",-1);
}

