var id;
var movestatus;

document.write ('<style>');
document.write ('#rightcolholder1 {margin-top: -336px;}');
document.write ('#rightcolholder2 {margin-top: -336px;}');
document.write ('#rightcolholder3 {margin-top: -246px;}');
document.write ('#rightcolholder4 {margin-top: -107px;}');
document.write ('</style>');

/* fill scroll bar with icons */
function scrollContentFill(ContainerId) {
	var scrollImageNames = new Array("logos_campbells","envelopes","logos_cutco","pendant","shop_gored_umbrella","tie","logos_jafra","shop_gored_brooch","logos_jiffylube","shop_gored_apron","logos_macys","shop_gored_travelmug","logos_merck","shop_gored_redshirt","logos_oceanspray","logos_perfumania","logos_prego","shop_gored_notebook","logos_riteaid","shop_gored_minitote","logos_supervalu","logos_swanson","shop_gored_cosmetics_bag","logos_swarovski","logos_yankee");	
	var iconCount = scrollImageNames.length;
	var scrollWidth = ((iconCount*70)+((iconCount-1)*21))+"px"
	document.getElementById(ContainerId).style.width = scrollWidth;
	
	var linkHTML = '';
	
	for (a=0; a<scrollImageNames.length; a++) {
			if (scrollImageNames[a].substring(0,4)=="logo")
			    linkHTML=linkHTML + '<a href="sponsor_programs.aspx"><img class="shopicon" src="images/shop/'+scrollImageNames[a]+'.gif"></a><img class="shopspacer" src="images/shop/spacer.gif">';
			else
			    linkHTML=linkHTML + '<a href="http://www.shopgored.com" target="_blank"><img class="shopicon" src="images/shop/'+scrollImageNames[a]+'.gif"></a><img class="shopspacer" src="images/shop/spacer.gif">';
		}
	document.getElementById(ContainerId).innerHTML = linkHTML;
	//alert(iconCount+", "+scrollWidth);
}

/* start scroll bar on top left */
function initialize() 
{
	scrollObj = document.getElementById("scrollinner").style;
	scrollObj.top = "0px";
	scrollObj.left = "0px";
}

/* stop moveit loop */
function stopit () 
{ 
	if (movestatus==1) 
	{
		window.clearTimeout(id);
		movestatus=0;
	}
}

/* move icon group stopping at the ends */
function moveit(dirx)
{ 
	w=525;
	document.getElementById("scroll").style.width=w;
	movestatus=1;
	menuscrollerwidth=parseInt(document.getElementById("scrollinner").style.width);
	menuscrollerwidth=(menuscrollerwidth-w)*-1;
	moveobj=document.getElementById("scrollinner").style;
	oldposx=parseInt(moveobj.left);
	newposx = oldposx + dirx;
	if (newposx >0) newposx=0;
	if (newposx <menuscrollerwidth) newposx=menuscrollerwidth;
	moveobj.left=newposx + "px";
	id=window.setTimeout('moveit('+dirx+')', 10);
}

function numCounterFormat() {
	var tmpNum = document.getElementById("counternumber").innerHTML;
	tmpNum= "<b>"+tmpNum.substring(8)+"</b>";
	document.getElementById("counternumber").innerHTML = tmpNum;
}

function embedVideo(container, movie, id, widthv, heightv) {
		tmpFlash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+widthv+'" height="'+heightv+'" id="goredmontage01" align="middle">';
		tmpFlash += '<param name="allowScriptAccess" value="sameDomain" />';
		tmpFlash += '<param name="allowFullScreen" value="false" />';
		tmpFlash += '<param name="movie" value="'+movie+'" />';
		tmpFlash += '<param name="quality" value="high" />';
		tmpFlash += '<param name="bgcolor" value="#ffffff" />';	
		tmpFlash += '<param name="wmode" value="transparent" />';
		tmpFlash += '<embed src="'+movie+'" quality="high" bgcolor="#ffffff" width="'+widthv+'" height="'+heightv+'" name="'+id+'" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent"/>';
		tmpFlash += '</object>';
		document.getElementById(container).innerHTML=tmpFlash;
}

var xmlhttp

function loadXMLDoc(url)
{
xmlhttp=null
url = "http://www.goredforwomen.org/hcu/files/counter.txt";
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
if (xmlhttp!=null)
  {
		xmlhttp.onreadystatechange=pullData;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
  }
else
  {
  	document.getElementById("counternumber").innerHTML="<b>(Sorry, couldn't load the latest count)</b>";
  }
}


function pullData()
{
// if xmlhttp shows "loaded"

if (xmlhttp.readyState==4)
  {
  if (xmlhttp.status==200)
    {
	xmlDoc = xmlhttp.responseText;
		//display data
		document.getElementById("counternumber").innerHTML = xmlDoc;
        numCounterFormat();

    }
  else
    {
    	document.getElementById("counternumber").innerHTML="<b>Problem retrieving data</b>";
    }
  }
}

								
								
								
function sidebarStretch(PageFormat) {
	
// topShift deals with the fact that the rightcolholder top is not the same as the rightcolx top.
// topShift is the intended difference between the two (marquee height, basically).

	if (PageFormat=="ektron_format0") {return; }

	if (PageFormat=="ektron_format1") topShift =100; 
	if (PageFormat=="ektron_format2") topShift =336; 
	if (PageFormat=="ektron_format3") topShift =246; 
	if (PageFormat=="ektron_format4") topShift =107; 
	if (PageFormat=="ektron_format5") topShift =107; 
	if (PageFormat=="ektron_format6") topShift =107; 

	sidebarHeight = document.getElementById("rightcolx").offsetHeight;
	document.getElementById("rightcolholder").style.height=(sidebarHeight-topShift)+"px";
}								
								
								
								
function postEmailReg(url)
{
xmlhttp=null;
var url = "emailreg_process.aspx";

params = validateEmailReg();

    if (params) {

// code for Mozilla, etc.
        if (window.XMLHttpRequest)
          {
          xmlhttp=new XMLHttpRequest()
          }
        // code for IE
        else if (window.ActiveXObject)
          {
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
          }
      
      
        if (xmlhttp!=null)
          {
            xmlhttp.onreadystatechange=confirmEmailReg;
            xmlhttp.open("POST",url,true);
            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xmlhttp.setRequestHeader("Content-length", params.length);
            xmlhttp.setRequestHeader("Connection", "close");
            xmlhttp.send(params);
          }
        else
          {
          alert("Your browser does not support this form")
          }
    }
}								
								
								
function confirmEmailReg()
{

//document.getElementById('statusmsg').innerHTML="Please Wait...";
//document.getElementById('status').style.top='20px';
//document.getElementById('status').style.display='block'; 

if (xmlhttp.readyState==4)
  {
  if (xmlhttp.status==200)
    {
    //alert ('Thank You for Registering with Go Red!');
	document.location.href="http://my.americanheart.org/sorp/registration/registration/goRed/confirmation.jsp?_requestid=13327";
	//result = xmlhttp.responseText;
	//document.getElementById('statusmsg').innerHTML=result;
    }
  else
    {
    alert('problem');
	//document.getElementById('statusmsg').innerHTML="Problem Retrieving Data";
    }
  }
}								
								
								
function validateEmailReg() {
var fnameStr = document.frmemailreg.fname.value.toString().substring(0,16);
var lnameStr = document.frmemailreg.lname.value.toString().substring(0,16);;
var emailStr = document.frmemailreg.email.value.toString().substring(0,255);;
var refurlStr = document.frmemailreg.refurl.value.toString().substring(0,255);;

//var objRegExp  =  /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;
var objRegExp  =  /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;

if(fnameStr == ""){alert("Please enter a first name."); return false;}
if(fnameStr == "enter first name"){alert("Please enter a first name."); return false;}
if(lnameStr == ""){alert("Please enter a last name."); return false;}
if(lnameStr == "enter last name"){alert("Please enter a last name."); return false;}
if(emailStr == ""){alert("Please enter an email address"); return false;}
if(emailStr == "enter email"){alert("Please enter an email address"); return false;}
if (!objRegExp.test(emailStr)) {
    alert("Please double-check the email address"); return false;
}

var params="";
params+="fname="+fnameStr;
params+="&";
params+="lname="+lnameStr;
params+="&";
params+="email="+emailStr;
params+="&";
params+="refurl="+refurlStr;

//alert(params);
    return params;
}								
														
														
function termsOpen(elementName) {

	objStyle = document.getElementById(elementName).style;
	if (objStyle.display=="none") {
		objStyle.display="block";
	} else {
		objStyle.display="none";	
	}
sidebarStretch(PageFormat);
}


function feedbackOpen(itemNumber)
{
	window.open('http://www.goredforwomen.org/grfw-tv/feedback.aspx?itemnumber='+itemNumber,'feedback','width=350, height=300, resizable=0, scrollbars=0, toolbar=0, location=0, directories=0, status=0, menubar=no, copyhistory=0');	
}


function feedbackClose()
{
    window.close('feedback');
}

var fieldDefaults = new Array();

function InitLabelField(field, label) {
    fieldDefaults[field.getAttribute("id")] = label;
    field.setAttribute("onblur", "FillLabelField(this);");
    field.setAttribute("onfocus", "EmptyLabelField(this);");
}

function FillLabelField(field) {
    if (field.value == "")
        field.setAttribute("value", fieldDefaults[field.getAttribute("id")]);
}

function EmptyLabelField(field) {
    if (field.value == fieldDefaults[field.getAttribute("id")])
        field.setAttribute("value", "");
}

function validateSubmit() {
    var field = document.getElementById("q");
    return !((field.value == fieldDefaults[field.getAttribute("id")]) || (field.value == ""));
}