//document.frmregistration.login.value="";
//document.frmregistration.password.value="";
 function replace_plus(text)
	{
        return text.replace('+',' ');
	}	 
	//get_cookie('USERNAME');
function get_cookie(Name) 
	{
		
		var search = Name+"="	
		var returnvalue = "";
		//alert(document.cookie.length);
		if (document.cookie.length > 0) {
			offset = document.cookie.indexOf(search)
			// if cookie exists //
			//alert(offset);
			if (offset != -1) {
				offset += search.length
				// set index of beginning of value
				end = document.cookie.indexOf(";", offset);
				// set index of end of cookie value
				if (end == -1) end = document.cookie.length;
				returnvalue=unescape(document.cookie.substring(offset, end));
				
					var a 	=returnvalue.length;
					for(i=0;i<a;i++)
					{
						returnvalue=replace_plus(returnvalue);
					}
			}
		}
		
		return returnvalue;
	}
function readCookie(name) 
{
	var nameEQ = name + "=";
	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;
}

	function delCookie(name) {
//document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" + "; path=/";
	setcookie(name, "", time() - 3600 , "/", "ibnlive.com");
} 					


function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
  
  document.cookie = cookie_string;
}


function Get_Cookie1( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}

function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie1( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function validate_frm_login()
{
	
	if(document.frmregistration.login.value=='')
	{
		alert('Please enter username');
		return false;
	}
	if(document.frmregistration.password.value=='')
	{
		alert('Please enter password');
		return false;
	}
}

//0-logid,1-username,2-fname,3-lname,4-email,5-country,6-newsletter,7-postcomment
function get_cookie_variable(str,pos)
{
	var arr_cookie=str.split("**");
	var name=arr_cookie[pos];
	return name;
}