
/*  */

var toScroll=new Array()
var ie=document.all
var dom=document.getElementById
var firstNews_obj;
var secondNews_obj;

function newsScroll(name){
  var c=this; c.name=name; c.mc=0; c.i=2;
  return this;
}

newsScroll.prototype.addItem = function(text,link,font,fontSize,fontStyle){
  var c = this;
  if (link !=''){
    if (font != '')
      toScroll[c.mc]="<a href='"+link+"'><font face='"+font+"' size='"+fontSize+"' Class='"+fontStyle+"'>"+text+"</font></a>";
    else
      toScroll[c.mc]="<a href='"+link+"'><font Class='"+fontStyle+"'>"+text+"</font></a>";
  }
  else { 
    if (font != '')
      toScroll[c.mc]="<font face='"+font+"' size='"+fontSize+"' Class='"+fontStyle+"'>"+text+"</font>";
    else
      toScroll[c.mc]="<font Class='"+fontStyle+"'>"+text+"</font>";
  }
  c.mc++;
}

newsScroll.prototype.construct = function(){
  var c = this; theHeight=c.scrollerheight; thebgColor = c.scrollerbgcolor; theBackground =c.scrollerbackground; theDelay=c.scrollerdelay;
  scroll_obj=eval(c.name);        
  if (ie||dom){
    document.writeln('<div id="main2" style="position:relative;width:300;height:'+theHeight+';overflow:hidden;background-color:'+thebgColor+' ;background-image:url('+theBackground+')">')
    document.writeln('<div style="position:absolute;width:300;height:'+theHeight+';clip:rect(0 300 '+theHeight+' 0);left:0;top:0">')
    document.writeln('<div id="firstNews" style="position:absolute;width:300;left:0;top:1">')
    document.write(toScroll[0])
    document.writeln('</div>')
    document.writeln('<div id="secondNews" style="position:absolute;width:300;left:0;top:0;visibility:hidden">')
    document.write(toScroll[dyndetermine=(toScroll.length==1)? 0 : 1])
    document.writeln('</div>')
    document.writeln('</div>')
    document.writeln('</div>')
  }
}

newsScroll.prototype.move = function(whichdiv){
  var c = this; theDelay = c.scrollerdelay; theHeight = c.scrollerheight; 
  scroll_obj=eval(c.name);
  tdiv=eval(whichdiv)

  if (parseInt(tdiv.style.top)>0&&parseInt(tdiv.style.top)<=3){
    tdiv.style.top=0+"px"
    setTimeout("scroll_obj.move(tdiv)",theDelay)
    setTimeout("scroll_obj.move2(secondNews_obj)",theDelay)
    //document.write('Got Milk?')
  return
  }
  if (parseInt(tdiv.style.top)>=tdiv.offsetHeight*-2){
    tdiv.style.top=parseInt(tdiv.style.top)-2+"px"
    setTimeout("scroll_obj.move(tdiv)",100)
  }
  else {
    tdiv.style.top=parseInt(theHeight)+"px"
    tdiv.innerHTML=toScroll[c.i]
    if (c.i==toScroll.length-1)
      c.i=0
    else
      c.i++
  }
}

newsScroll.prototype.move2 = function(whichdiv){
  var c = this; theDelay = c.scrollerdelay; theHeight= c.scrollerheight;
  scroll_obj=eval(c.name);
  tdiv2=eval(whichdiv)

  if (parseInt(tdiv2.style.top)>0&&parseInt(tdiv2.style.top)<=2){
    tdiv2.style.top=0+"px"
    setTimeout("scroll_obj.move2(tdiv2)",theDelay)
    setTimeout("scroll_obj.move(firstNews_obj)",theDelay)
    return
  }
  if (parseInt(tdiv2.style.top)>=tdiv2.offsetHeight*-1){
    tdiv2.style.top=parseInt(tdiv2.style.top)-2+"px"
    setTimeout("scroll_obj.move2(secondNews_obj)",100)
  }
  else {
    tdiv2.style.top=parseInt(theHeight)+"px"
    tdiv2.innerHTML=toScroll[c.i]
    if (c.i==toScroll.length-1)
      c.i=0
    else
      c.i++
  }
}

newsScroll.prototype.startScroll = function(){
  var c = this;
  scroll_obj=eval(c.name);        
  
  if (toScroll.length >2)
    c.i = 2;
  else
    c.i = 0;
  
  firstNews_obj=ie? firstNews : document.getElementById("firstNews")
  secondNews_obj=ie? secondNews : document.getElementById("secondNews")
  setTimeout("scroll_obj.move(firstNews_obj)",c.scrollerDelay);
  secondNews_obj.style.top=theHeight;
  secondNews_obj.style.visibility='visible'
}


function NewWindow(mypage, myname, w, h, scroll, toolbar) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable,toolbar='+toolbar+''
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function getCookie(name) {
  var i  = 0;
  while (i < document.cookie.length) {
    var j = i + (name.length) + 1;
    if (document.cookie.substring(i,j) == name+"=") {
      var endstr = document.cookie.indexOf (";", j);
      if (endstr < j) endstr = document.cookie.length;
      return unescape(document.cookie.substring(j, endstr));
    }
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

var showsub = new Array();
var blocks = getCookie('showsub');
if (blocks != null) {
  var shown = blocks.split(":");
  for (var loop = 0; loop < shown.length; loop++) {
    var showitem = shown[loop];
    showsub[showitem] = showitem;
  }
}

function showsubs(item) {
  var bloc = document.getElementById('block'+item);
  if (bloc.style.display=="none") {
    bloc.style.display="";
    showsub[item] = item;
  } else {
    bloc.style.display="none";
    showsub[item] = null;
  }
  var cookie = null;
  for (var q = 0; q < showsub.length; q++) {
    if (showsub[q] != null) {
      cookie = (cookie != null) ? (cookie+":"+showsub[q]) : showsub[q];
    }
  }
  if (cookie != null) {
    var exp = new Date();
    exp.setTime(exp.getTime() + (3600000));
    var expstr = "; expires=" + exp.toGMTString();
    document.cookie = "showsub=" + escape(cookie) + expstr + "; path=/; domain=127.0.0.1;";
  } else if (getCookie("showsub")) {
    document.cookie = "showsub=:; expires = Thu, 01-Jan-70 00:00:01 GMT; path=/; domain=127.0.0.1;";
  }
}

function showdiv(item) { 
document.getElementById('google').className = "note visible";
}

function showInfo(item) { 
document.getElementById(item).className = "note visible";
}

function hideInfo(item) {
document.getElementById(item).className = "hidden";
}

// check new password for when customers want to change it.
function check_feed(theForm) {
	if (theForm.opass.value=="") {
  	warning="Please enter your old password.";
		alert(warning);
	  return false;
	}
	if (theForm.pass1.value=="") {
	  warning="Please enter your new password.";
		alert(warning);
	  return false;
	}
	if (theForm.pass1.value != theForm.pass2.value) {
  	warning="Passwords did not match, please try again.";
		alert(warning);
	  return false;
	}
		document.forms.theForm.submit();
}

function isEmailAddr(email) {
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0) {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
		result = true;
  }
  return result;
}

function check_email(theForm) {
	if (theForm.femail.value == "") {
    alert("Please enter a value for the 'Email' field.");
    theForm.femail.focus();
    return (false);
  }
  if (theForm.femail.value.length < 7) {
    alert("Please enter at least 7 characters in the 'email' field.");
    theForm.femail.focus();
    return (false);
  }
  if (!isEmailAddr(theForm.femail.value)) {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    theForm.femail.focus();
    return (false);
  }
	if (theForm.fcomments.value.length < 7) {
	  warning="Please enter your comments.";
		alert(warning);
	  return false;
	}
		document.forms.theForm.submit();
}

function check_zip() {
warning="";
if (document.shopcart.zcode.value.length != 5)
    warning=warning+"Please enter your 5-digit zip code";
	if (warning!="") {
		alert(warning);
		return false;
	}
  for (var i = 0; i < document.shopcart.zcode.value.length; i++) {
		var oneChar = document.shopcart.zcode.value.charAt(i)
		if (oneChar < "0" || oneChar > "9") {
    	alert("Please enter your 5-digit (numerical) zip code");
			return false;
		}
	}
}

function nozip() {
warning="";
if (document.shopcart.zcode.value.length != 7) {
    warning=warning+"Please enter your 5-digit zip code and calculate shipping charges please";
		alert(warning);
		return false;
	}
}

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}