// JavaScript Document
  function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );
//alert(today.getTime());

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );
//alert(expires_date);
document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );


}

  function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}


 function getRequestParameter( name ) {
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( document.referrer );
if( results == null )
return "";
else
return results[1];
}


//alert( Get_Cookie( 'userextn' ))

// if(!extn){
//
//var myArray = [];
//myArray[0]= 'google';
//myArray[1]= 'yahoo';
//myArray[2]= 'bing';
//myArray[3]= 'aol';
//myArray[4]= 'lycos';
//myArray[5]= 'alltheweb';
//myArray[6]='altavista';
//myArray[7]='looksmart';
//myArray[8]='infoseek';
//myArray[9]='facebook';
//myArray[10]='twitter';
//myArray[11]='youtube';
//myArray[12]='mattresspolice';
//myArray[13]='hgtv';
//myArray[14]='latexmattress';
//myArray[15]= 'amazon';
//myArray[16]= 'nextag';
//myArray[17]='bizrate';
//
//
//var extnarray = [];
//extnarray[0]= '10000';
//extnarray[1]= '11000';
//extnarray[2]= '12000';
//extnarray[3]= '13000';
//extnarray[4]= '14000';
//extnarray[5]= '15000';
//extnarray[6]= '16000';
//extnarray[7]= '17000';
//extnarray[8]= '18000';
//extnarray[9]= '40000';
//extnarray[10]= '41000';
//extnarray[11]= '42000';
//extnarray[12]= '70000';
//extnarray[13]= '71000';
//extnarray[14]= '72000';
//extnarray[15]= '30000';
//extnarray[16]= '31000';
//extnarray[17]='32000';
//
//
//for(var i=0; i<myArray.length; i++) {
//
//if (document.referrer.indexOf(myArray[i]) > -1)
//{
//extn=extnarray[i];
//
//if(i==1){
//var val23 = getRequestParameter( 'p' );
//}else{
//var val23= getRequestParameter( 'q' );
//}
//
//
//
//}
//
//
//}
//
//if(!extn){
// if(document.referrer!=''){
//  extn='8888';
//}else{
//extn='9999';
//
//}
//}
//
//}


if ( Get_Cookie( 'userextn' ) ) 
{
	val=Get_Cookie( 'userextn' );
	
	if(val=='9009'){
	
	val1='10000';
	
	}
	else if(val=='9010'){
	
	val1='11000';

	
	}
	else if(val=='9011'){
	val1='12000';
	
	}
	else if(val=='9012'){
	
	val1='30000';
	
	}
	else if(val=='9013'){
	
	val1='31000';
	}
	else if(val=='9014'){
	val1='13000';
	
	}
	else if(val=='9015'){
	val1='32000';
	}
	else{
	val1=val;
	}
	varval=val1;
	document.getElementById("extension").innerHTML=val1;

}
else
{

		var today = new Date();
		today.setTime( today.getTime() );
		
		var expires = 30 * 1000 * 60 * 60 * 24;
		
		
		var expires_date1 = new Date( today.getTime() );
		var aaa=expires_date1.toUTCString() 
		
		
		
		Set_Cookie( 'userextn', extn, '30', '/', '', '' );
		Set_Cookie( 'keyword', val23, '30', '/', '', '' );
		Set_Cookie( 'expiry-time',expires_date1, '30', '/', '', '' );
		
		val=extn;
		varval=val;
	   document.getElementById("extension").innerHTML=val;
}


 if(!Get_Cookie( 'keyword' )){
Set_Cookie( 'keyword', val23, '30', '/', '', '' );
}
if(!Get_Cookie( 'expiry-time' )){
Set_Cookie( 'expiry-time',expires_date1, '30', '/', '', '' );
}


var fpath=document.location.pathname;

if(fpath=='/checkout_payment.php'){
    	
	var days = 0;
	var difference = 0;
	
	if ( Get_Cookie( 'expiry-time' ) ){ 
	var yest =  new Date(Get_Cookie('expiry-time'));
	}
	else{
	var yest = new Date();
	
	}
	
	var today = new Date();
		
	difference =  today - yest;
	
	days = Math.round(difference/(1000*60*60*24));
	hours=parseInt(difference/(1000*60*60));
	minutes = Math.round(difference/(1000*60));
	if(minutes > 60){
	minutes = Math.round(minutes-(hours*60))
	
	}
	if(hours > 24){
	hours = Math.round(hours-(days*24))
	
	}
	
	Set_Cookie( 'duration-days', days, '0', '/', '', '' );
	Set_Cookie( 'duration-hours', hours, '0', '/', '', '' );
	Set_Cookie( 'duration-minutes', minutes, '0', '/', '', '' );
	

}



var message="";

///////////////////////////////////

function clickIE4(){

if (event.button==2){

alert(message);

return false;

}

}



function clickNS4(e){

if (document.layers||document.getElementById&&!document.all){

if (e.which==2||e.which==3){

//alert(message);

return false;

}

}

}



if (document.layers){

document.captureEvents(Event.MOUSEDOWN);

document.onmousedown=clickNS4;

}

else if (document.all&&!document.getElementById){

document.onmousedown=clickIE4;

}



document.oncontextmenu=new Function("return false")




