var agt = navigator.userAgent.toLowerCase(); 

var is_major = parseInt(navigator.appVersion); 

var is_ie   = (agt.indexOf("msie") != -1); 
var is_ie3  = (is_ie && (is_major < 4)); 
var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );


var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) 
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) 
                && (agt.indexOf('webtv')==-1)); 
var is_nav2 = (is_nav && (is_major == 2)); 
var is_nav3 = (is_nav && (is_major == 3)); 
var is_nav4 = (is_nav && (is_major == 4)); 
var is_nav4up = (is_nav && (is_major >= 4)); 

function popNav(url,name,features) {

    if (is_ie3)
    {
        popBox = window.open(url,name,features);
    }else
    if (is_major >=3 )
    {
        popBox = window.open(url,name,features);
        popBox.focus();
    }
  
}

function GetCookie(name) {
	var i = 0, j, cend;     
	var cnam = name + "=";
	var cook = document.cookie;   
	while (i < cook.length) {    
		j = i + cnam.length;    
		if (cook.substring(i, j) == cnam){      
			cend = cook.indexOf(";", j);  
			cend = (cend == -1) ? cook.length : cend;  
			return unescape(cook.substring(j, cend));
		}   
		i = cook.indexOf(" ", i) + 1;    
		if (!i) break;   
	}  
	return '';
}

function DeleteCookie(name) {  
	var exp = new Date(666);  
	document.cookie = name + "=null; expires=" + exp;
}

function SetCookie(name, value, expires) {  
	document.cookie = name+ "=" +escape(value)+
	               "; expires=" +expires+ "; ";
}

function CookieDate(days){
	var expc = new Date();
	expc.setTime(expc.getTime()+(days*24*60*60*1000));
	return expc.toGMTString();
}

function jumpto(faqurl) {
	win = window.open(faqurl, "demo", "resizable,height=500,width=500,toolbar=no,menubar=no,scrollbars=yes,status=yes");
	win.focus();
}


function visitCount(){
	var cname   = 'Personal_counter_test';	

	// get cookie and convert it to number
	var count = GetCookie(cname)*1;

	// if cookie doesn't exist set count to 0
	// else increment count.
	if (count == null) count = 0 ;
	else count++;

	// set cookie
	SetCookie(cname, count, CookieDate(90));

	// since count is incremented subtract 1 and return it 
	return count - 1;
}


function redirect () { setTimeout("go_now()",0); }
function go_now ()   { window.location.href = "http://www.theammashop.org/cgi-bin/bookstore/books_and_gifts.cgi?cart_id=" + cart_id; }

function randnumb(lofield, hifield) {
	var lo = parseInt(lofield)
    var hi = parseInt(hifield) - 1
    var now = new Date()
    var rnd = 98726471 * (now.getTime() / ((now.getMinutes() + 1) * 1000))
    rnd = lo + Math.floor(rnd % (hi - lo))
	return rnd
}

rand1 = Math.round(randnumb('1', '1000000'));
rand2 = Math.round(randnumb('3', '9999'));
cart_id = rand1 + rand2/10000;

function today()
{
// Array of day names
var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");

// Array of month Names
var monthNames = new Array(
"January","February","March","April","May","June","July","August","September","October","November","December");

var now = new Date();
document.write(dayNames[now.getDay()] + ", " + monthNames[now.getMonth()] + " " + now.getDate() + ", 19" + now.getYear());

}
