//--------Print Window code

function printWindow(){
   bV = parseInt(navigator.appVersion)
   if (bV >= 4) window.print()
}

//--------Style Switcher Code

function setActiveStyleSheet(title) {
   var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }

  return null;
 
}

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 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;
}

window.onload = function(e) {
  openWindowRemote();
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
  
//document.switcher.name(title).checked = true;
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
//   alert(title);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
//setActiveStyleSheet(title);


//--------Tell-a-friend popup code

function popTAFwin() {
theUrl = 'http://s116541872.onlinehome.us/html/tellafriend.asp?refer='+ window.location + '&title=' +document.title+ '&';
window.open(theUrl,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=385,height=400');
}
function openPopup(name, url, height, width, menubar, location, toolbar, scrollbars, resizable){
	var tmpPopup;
	var strProperties = "menubar=" + menubar + ",location=" + location + ",toolbar=" + toolbar + ",scrollbars=" + scrollbars + ",resizable=" + resizable + ",width=" + width + ",height=" + height;
	tmpPopup = window.open(url, name, strProperties);
	tmpPopup.focus();
}

//--------Validate email form
function checkvalid()
{
// check to see if the field is blank
if (document.getElementById('First').value.length == 0)   {
alert("Please enter your first name.");
return false;
}
if (document.getElementById('Last').value.length == 0)   {
alert("Please enter your last name.");
return false;
}
if (document.getElementById('Email').value.length == 0)   {
alert("Please enter your email address.");
return false;
}
if (document.getElementById('County').value.length == 0)   {
alert("Please enter your county (It helps us reduce unnecessary notifications).");
return false;
}
else {

document.emailform.submit();
}
}
// date.setTime(date.getTime()+(days*24*60*60*1000));
//    var expires = "; expires="+date.toGMTString();

//--------Ezine open once popup code


var popunder=new Array();
popunder[0]='html/ezinepop.html';

function get_cookie(Name){
var search=Name+'=';
var returnvalue='';
if(document.cookie.length>0){
offset=document.cookie.indexOf(search);
if(offset!=-1){
	offset+=search.length;
	end=document.cookie.indexOf(';',offset);
if(end==-1)
	end=document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset,end))
}
}
return returnvalue;
}

function openWindowRemote(){
//alert(popunder[0]);
if (get_cookie('popunder')=='')
{
document.cookie="popunder=yes";
win2=window.open(popunder[0],'',"width=385,height=444,scrollbars=no,resizable=no,toolbar=no,menubar=no,status=no,location=no");
var SCRwidth  = (window.screen.width-200)/2;var SCRheight = (window.screen.height-300)/2;
//win2.moveTo(SCRwidth, SCRheight);
win2.focus();
}
}
