/* function for pop-out-of frames*/
if (window!= top)
top.location.href=location.href

/* Rollover Script */
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}


if (document.images)
{
channel1 = new Image(54,20)
channel1.src = "http://www.redcross-saginaw.org/images/home2b.gif"
channel2 = new Image(65,20)
channel2.src = "http://www.redcross-saginaw.org/images/about2b.gif"
channel4 = new Image(101,20)
channel4.src = "http://www.redcross-saginaw.org/images/press2b.gif"
channel5 = new Image(59,20)
channel5.src = "http://www.redcross-saginaw.org/images/contact2b.gif"
}

/*blubar rollovers*/
if(navigator.appName == "Microsoft Internet Explorer" &&
parseInt(navigator.appVersion) >= 4){
	ie4 = true;
}
else {
	ie4 = false;
}

function changeColor(){
	if(ie4){
		what = window.event.srcElement;
		if(what.className == "nav"){
			if(what.style.color == "#ffffff"){
				what.style.color = "#003366";
			}
			else {
				what.style.color = "#ffffff";
			}
		}
		else {}
	}
}

document.onmouseover = changeColor;
document.onmouseout = changeColor;

/*form check script*/
function checkform(form) {
  return(
  validateZip(form.zip)
  )
}

function validateZip(myfield) {
  if (notNull(myfield.value)) {
  if(isDigits(myfield.value))
	 {
		 if (isSize(myfield.value,5))  return true
	 }
	}
  myfield.focus()
  alert("Invalid zip code. Please enter 5-digit zip code.")
  return false
}

function notNull(str) {
  if (str.length == 0 )  return false
  else   return true
}

function isSize(str, size) {
  if (str.length == size)   return true
  else  return false
}

function isDigits(str) {
  var i
  for (i = 0; i < str.length; i++) {
  mychar = str.charAt(i)
  if (mychar < "0" || mychar > "9")  return false
  }
  return true
}

function stripNonDigits(str) {
  var i
  var newstring = ""
  for (i = 0;  i < str.length; i++) {
  mychar = str.charAt(i)
  if (isDigits(mychar))   newstring += mychar
  }
  return newstring
}


function openWindow_2() {
  window.open("","x","toolbar=no,location=no, directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=500,left=20,top=20");

}

function openWindow_fires() {
  window.open("","x","toolbar=no,location=no, directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=620,height=470");

}

function newWindow_safety(newContent)
 {
  winContent = window.open(newContent, 'nextWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=577,height=475')         
 }
 
function popUp(filename, dimensions) {
	window.open(filename, '', dimensions);
}

// *********************************************************************************************************************
// this is the cookie and function for the popup for Red Cross Connect.
// It will load on-exit from the site by reading the URL string and looking for a change.
// It will set a cookie so that this will not occur again for 24 hours.
// We may want to set a cookie or read a cookie from RCConnect so that once a user is signed up they will never see this $#@&* popup again.

function checkExitRCC()
{ 
strCookie = document.cookie;
  if (strCookie.indexOf("RCConnectPopup=True") < 0)
  {
    theDate = new Date();
    theDay = theDate.getDate() + 1;      // gets the day of the month
    if (theDay > 28) {
      theDay = theDay - 28;
      theMonth = theDate.getMonth() + 1;
      theDate.setMonth(theMonth);
    };
   theDate.setDate(theDay);              // sets the day of the month
    strDate = theDate.toGMTString();
    document.cookie = "RCConnectPopup=True;path=/;expires=" + strDate;
	var win = window.open("","","width=5,height=5,top=-50,left=-50");
	win.blur();
	win.document.write("<script>");
	win.document.write("setTimeout(\'checkDomain()\',1000);\n");
	win.document.write("function checkDomain(){ ");
	win.document.write("try {");
	win.document.write("if(window.opener) var x = window.opener.location.href;\n");
	win.document.write("self.close();}");
//	win.document.write("catch(e){window.open(\'http://www.redcross.org/metadata/rcconnect/signup.htm\',\'\',\'width=300,height=250,resizable=yes, scrollbars=no\'); self.close();}");
	win.document.write("catch(e){window.open(\'http://www.redcross.org/email/1minute/330x300exit.htm\',\'\',\'width=332,height=302,resizable=yes, scrollbars=no\'); self.close();}");
	win.document.write("}");
	win.document.write("<\/script>");
	}
}

// end cookie and function set up for RCConnect
// *************************************************************************************************************8

/// OpenSurvey()checks for cookie BFcookie1 ///
/// if BFcookie1 does not exist		    ///
/// calls randomThree() function            ///
/// function openSurvey() {
///	strCookie = document.cookie;
///  	if (strCookie.indexOf("BFcookie1") <0 )
///	randomThree();
///}

/// generates a random number between 0-2 		    ///
/// if number(nth) equals 2, calls the checkExit() function ///
/// function randomThree() {
///	var nth = 2;
///	var rnd = Math.floor(Math.random() * nth) + 1;
///	if (rnd == 2) {
///     		checkExit();
///	}
///}

/// checks to see if user has left redcross.org domain or has closed the browser	///
/// if this is true then the function fires a popup to the visitor			///
/// popup is located at http://www.redcross.org/email/1minute/330x300.htm	///
/// popup sets the BFcookie1 cookie so the randomThree() function never fires again	///
//function checkExit()
//{ 
//strCookie = document.cookie;
//  if (strCookie.indexOf("OMUDonePopup=True") < 0)
//  {
 //   theDate = new Date();
 //   theDay = theDate.getDate() + 1;      // gets the day of the month
//    if (theDay > 28) {
 //     theDay = theDay - 28;
//      theMonth = theDate.getMonth() + 1;
//      theDate.setMonth(theMonth);
//    };
//   theDate.setDate(theDay);              // sets the day of the month
//    strDate = theDate.toGMTString();
//    document.cookie = "OMUDonePopup=True;path=/;expires=" + strDate;
//	var win = window.open("","","width=5,height=5,top=-50,left=-50");
//	win.blur();
//	win.document.write("<script>");
//	win.document.write("setTimeout(\'checkDomain()\',1000);\n");
//	win.document.write("function checkDomain(){ ");
//	win.document.write("try {");
//	win.document.write("if(window.opener) var x = window.opener.location.href;\n");
//	win.document.write("self.close();}");
//	win.document.write("catch(e){window.open(\'http://www.redcross.org/email/1minute/330x300exit.htm\',\'\',\'width=332,height=302,resizable=yes, scrollbars=no\'); self.close();}");
//	win.document.write("}");
//	win.document.write("<\/script>");
//	}
//}

/// looks for a cookie written by the success page for OMU signup ... it writes a cookie that prevents subscribers from seeing the onunload popup if they are already subscribers ///

//function closeSubscribe() {
//	strCookie = document.cookie;
//  	if (strCookie.indexOf("OMUcookie1") <0 )
//	checkExit();
//}

/// 


