// Hello! 

// jump menu

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// cookies

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=/";
}

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;
}


// coupons

var discnt = 0;   // no default percent discount

var coupons = new Array (  
  "DCTLN",               
  "TLNFF"               
);
var coupdc  = new Array (  
  35,
  40
);
var coupval = "()"; 

function ChkCoup () {    
var i;
  discnt = 0;            
  for (i=0; i<coupons.length; i++) {
    if (coupval == coupons[i]) {
      coupname = coupons[i];
	  discnt = coupdc[i];
	  createCookie('couponname',coupname,1);
	  createCookie('coupamt',discnt,1);
      document.getElementById('goodcoupon').style.display="block";
	  document.getElementById('nogoodcoupon').style.display="none";
	  document.getElementById('cookievalidate').style.display="none";
      return;
    }
  }
  document.getElementById('nogoodcoupon').style.display="block";
  document.getElementById('goodcoupon').style.display="none";
}

function Dollar (val) {      
var str,pos,rnd=0;
  if (val < .995) rnd = 1;  // for old Netscape browsers
  str = escape (val*1.0 + 0.005001 + rnd);  
  pos = str.indexOf (".");
  if (pos > 0) str = str.substring (rnd, pos + 3);
  return str;
}

function ReadForm (obj1) {  // apply the discount and include text fields
var amt,des;
  amt = obj1.baseamt.value*1.0;       // base amount
  des = obj1.basedes.value;           // base description
  
var savedcouponname = readCookie('couponname');
var savedcouonpamt = readCookie('coupamt');
  
  if (savedcouonpamt > 0) {               
    amt = Dollar (amt - (amt * savedcouonpamt/100.0));
    des = des + "  --  " + savedcouonpamt + "% discount (" + savedcouponname + ")";
	
  }

  obj1.amount.value = Dollar (amt);
  obj1.item_name.value = des;
}

function checkCookieStatus () {
	var savedcouponname = readCookie('coupamt');
	if (savedcouponname > 0)
	{
		document.getElementById('goodcoupon').style.display="block";
		document.getElementById('cookievalidate').style.display="none";
		}
}


// window pop

function NewWindow(mypage,windowName,width,height) {
	window.open(mypage,windowName,'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,width='+width+',height='+height+',resizable=0');
}

// centered window pop
// sample: <a href="newPage.html" onclick="CenteredWindow(this.href,'name','200','100','yes');return false">link</a>

var win = null;
function CenteredWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}


// text input fields -- clearing and resetting

function clickclear(thisfield, defaulttext) {
if (thisfield.value == defaulttext) {
thisfield.value = "";
}
}

function clickrecall(thisfield, defaulttext) {
if (thisfield.value == "") {
thisfield.value = defaulttext;
}
}

// show and hide divs
// sample: onClick="expandcontent('name of div')"

var previoustab=""
function expandcontent(cid){
if (document.getElementById){
if (previoustab!="")
document.getElementById(previoustab).style.display="none"
if (cid!=""){
document.getElementById(cid).style.display="block"
previoustab=cid
}
}
}

var previoussubtab=""
function expandsub(sid){
if (document.getElementById){
if (previoussubtab!="")
document.getElementById(previoussubtab).style.display="none"
if (sid!=""){
document.getElementById(sid).style.display="block"
previoussubtab=sid
}
}
}

// blur links  
// call onload or for singles just use onfocus="if(this.blur)this.blur()"

function BlurLinks(){
	if(document.getElementById){
    		lnks=document.getElementsByTagName('a');
    		for(i=0;i<lnks.length;i++){
    			lnks[i].onfocus=new Function("if(this.blur)this.blur()");
    		}
	}
}

// a preloader, if needed
// preload( '01.gif', '02.gif' ); 

function preload()
{ 
  var args = preload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

//  simple rollovers

function mSetup() {
	var img, sh, sn, sd
	for (var i = 0; (img = document.images[i]); i++) {
		if (img.getAttribute) {

			sn = img.getAttribute("src");
			sh = img.getAttribute("hsrc");
			sd = img.getAttribute("dsrc");

			if (sn != "" && sn != null) {
				img.n = new Image();
				img.n.src = img.src;
			
				if (sh != "" && sh != null) {
					img.h = new Image();
					img.h.src = sh;
					img.onmouseover = mSwapOn
					img.onmouseout  = mSwapOff
				}

				if (sd != "" && sd != null) {
					img.d = new Image();
					img.d.src = sd;
					img.onmousedown = mSwapDown
				}
			}
		}
	}
}

function mSwapOn() {
	this.src = this.h.src;
}

function mSwapOff() {
	this.src  = this.n.src;
}

function mSwapDown() {
	this.src  = this.d.src;
	this.temp = typeof(document.onmouseup) != 'undefined' && typeof(document.onmouseup) != 'unknown' ? document.onmouseup : "";
	mSwapUp.img = this;
	document.onmouseup = mSwapUp;
}

function mSwapUp() {
	var ths = mSwapUp.img;
	ths.src = ths.n.src;
	if (ths.temp) document.onmouseup = ths.temp;
}

window.onload = mSetup;