﻿// JScript File
var pagenavigation = "";
var dropdownitemstimer="";
var buttonid="";
var CalendarCurrentMonth = "";
var calendarTimer = "";
var heroBoxTimer = "";
var four11buttonId = "";
var heroInfoBoxTop = "450px;";

var pageimageindex = -1;
var pageimages = new Array();
var pageimagetimer = "";


var billboardindex = -1;
var billboards = new Array();
var billboardtimer = "";

var four11buttons = new Array();
four11buttons["on"] = new Image();
four11buttons["off"] = new Image();
four11buttons["on"].src = "images/SFBF_411HeaderSelectionButton_Hover.jpg";
four11buttons["off"].src = "images/SFBF_411HeaderSelectionButton_Default.jpg";

var contactusbuttons = new Array();
contactusbuttons["on"] = new Image();
contactusbuttons["off"] = new Image();
contactusbuttons["on"].src = "images/ContactUsButton_Hover.jpg";
contactusbuttons["off"].src = "images/ContactUsButton_Default.jpg";

var caringbuttons = new Array();
caringbuttons["on"] = new Image();
caringbuttons["off"] = new Image();
caringbuttons["on"].src = "images/SFBF_CaringBridgeButton_Hover.jpg";
caringbuttons["off"].src = "images/SFBF_CaringBridgeButton_Default.jpg";

var crossbuttons = new Array();
crossbuttons["on"] = new Image();
crossbuttons["off"] = new Image()
crossbuttons["on"].src = "images/SFBF_HeroesNavigationButton_Hover.jpg";
crossbuttons["off"].src = "images/SFBF_HeroesNavigationButton_Default.jpg";

var facebuttons = new Array();
facebuttons["on"] = new Image();
facebuttons["off"] = new Image();
facebuttons["on"].src = "images/SFBF_FacebookButton_Hover.jpg";
facebuttons["off"].src = "images/SFBF_FacebookButton_Default.jpg";

var morebuttons = new Array();
morebuttons["on"] = new Image();
morebuttons["off"] = new Image();
morebuttons["on"].src = "images/MoreButton_On.jpg";
morebuttons["off"].src = "images/MoreButton_Off.jpg";

var mouseposition = new Array();

var navigationbuttons = new Array();
navigationbuttons["on"] = new Image();
navigationbuttons["on"].src ="images/SFBF_NavigationButton_Hover.jpg";
navigationbuttons["off"] = new Image();
navigationbuttons["off"].src = "images/SFBF_NavigationButton_Default.jpg";

var recyclebuttons = new Array();
recyclebuttons["on"] = new Image();
recyclebuttons["off"] = new Image();
recyclebuttons["on"].src = "images/SFBF_RecycleHeaderSelectionButton_Hover.jpg";
recyclebuttons["off"].src = "images/SFBF_RecycleHeaderSelectionButton_Default.jpg";

var searchbutton = new Array();
searchbutton["on"] = new Image();
searchbutton["off"] = new Image();
searchbutton["on"].src = "images/SFBF_Search_RightHand_Hover.jpg";
searchbutton["off"].src = "images/SFBF_Search_RightHand_Default.jpg";


var sponsoradindex = -1;
var sponsorads = new Array();
var sponsoradtimer = "";

var swapbuttons = new Array();
swapbuttons["morebutton"] = new Array();
swapbuttons["morebutton"]["on"] = new Image();
swapbuttons["morebutton"]["off"] = new Image();
swapbuttons["morebutton"]["on"].src = "images/MoreButton_On.jpg";
swapbuttons["morebutton"]["off"].src = "images/MoreButton_Off.jpg";

swapbuttons["vcfcard"] = new Array();
swapbuttons["vcfcard"]["on"] = new Image();
swapbuttons["vcfcard"]["off"] = new Image();
swapbuttons["vcfcard"]["on"].src = "images/VCFCardLogo_On.jpg";
swapbuttons["vcfcard"]["off"].src = "images/VCFCardLogo_Off.jpg";


var topbuttons = new Array();
topbuttons["on"] = new Image();
topbuttons["off"] = new Image();
topbuttons["on"].src = "images/SFBF_HeaderSelectionButton_Hover.jpg";
topbuttons["off"].src = "images/SFBF_HeaderSelectionButton_Default.jpg";

var pauserotatebutton = new Array();
pauserotatebutton["on"] = new Image();
pauserotatebutton["off"] = new Image();
pauserotatebutton["on"].src = "images/Pause_Small_On.png";
pauserotatebutton["off"].src = "images/Pause_Small.png";

var playrotatebutton = new Array();
playrotatebutton["on"] = new Image();
playrotatebutton["off"] = new Image();
playrotatebutton["on"].src = "images/Play_Small_On.png";
playrotatebutton["off"].src = "images/Play_Small.png";

var vcfcardid = "";
var vcfcard = new Array();
vcfcard[1] = new Image();
vcfcard[0] = new Image();
vcfcard[0].src ="images/aboutUs/VCFCardLogo_Off.jpg";
vcfcard[1].src="images/aboutUs/VCFCardLogo_On.jpg";


function showGoogleMap(mapaddress)
{
    var linkurl="http://maps.google.com?q=";
    if(mapaddress != "")
        linkurl +=mapaddress;
}

function billboardChange(selectorid)
{
    //alert("Starting the change");
    if(billboardtimer != "")
        window.clearTimeout(billboardtimer);
    var currentbillboard = "imageselector_" + billboardindex;
    if(billboardindex !=-1)
        document.getElementById(currentbillboard).className = "imageselector";
    billboardindex=parseInt(selectorid) -1;
    billBoardStartTimer();
}

function billBoardStartTimer()
{
    var billboarditem = new Array();
    var currentbillboard = "imageselector_" + billboardindex;
    if(billboardindex !=-1)
        document.getElementById(currentbillboard).className = "imageselector";
    billboardindex += 1;
    if(billboardindex >= billboards.length)
        billboardindex = 0;
    billboarditem = billboards[billboardindex].split("','");
    billBoardSwitch(billboarditem[0], billboarditem[1], billboarditem[2], parseInt(billboarditem[4]));
    currentbillboard = "imageselector_" + billboardindex;
    document.getElementById(currentbillboard).className = "imageselectorhot";
    if(parseInt(billboarditem[4]) == 0)
    {
        billboardtimer=window.setTimeout("billBoardStartTimer()", parseInt(billboarditem[3]));
        document.getElementById("playpausebutton").title = "Pause";
        document.getElementById("playpausebutton").src = pauserotatebutton['off'].src;
    }
    else
    {
        document.getElementById("playpausebutton").title = "Play";
        document.getElementById("playpausebutton").src = playrotatebutton['off'].src;
        billboards[billboardindex] = billboarditem[0].toString() + "','" + billboarditem[1].toString() + "','" + billboarditem[2].toString() + "','" + billboarditem[3].toString() + "','" + "0";
    }
} 

function billBoardSwitch(lnkurl, adtype, imagename, autostart)
{
    if(adtype.toLowerCase() == "video")
    {
        if(autostart == 0)
        {
            adtype = "preview";
        }
        else
            adtype = "video";
    }
    getBuildBoardItem(imagename, adtype, lnkurl, "billboardholder");
}

function buttonHover(buttonid, switchposition, elementID)
{
    if(buttonid != "caring" && buttonid != "facebook" && buttonid != "contactus" && buttonid != "recycle" && buttonid != "411button" && buttonid != "playpausebutton")
    {
        document.getElementById(buttonid).src = topbuttons[switchposition].src;
    }
    else if(buttonid == "caring")
    {
        document.getElementById(buttonid).src = caringbuttons[switchposition].src;
    }
    else if(buttonid == "contactus")
    {
        document.getElementById(buttonid).src = contactusbuttons[switchposition].src;
    }
    else if(buttonid == "recycle")
    {
        document.getElementById(buttonid).src = recyclebuttons[switchposition].src;
    }
    else if(buttonid == "411button")
    {
        if(switchposition == "on")
        {
            four11buttonId=elementID;
        }
        document.getElementById(four11buttonId).src = four11buttons[switchposition].src;
        if(switchposition == "on")
            showherobox();
    }
    else if(buttonid == "playpausebutton")
    {
        var buttonTitle = document.getElementById(buttonid).title;
        switch(buttonTitle.toLowerCase())
        {
            case "play":
                document.getElementById(buttonid).src = playrotatebutton[switchposition].src;
                break;
            case "pause":
                document.getElementById(buttonid).src = pauserotatebutton[switchposition].src;
                break;
        }
    }
    else
    {
        document.getElementById(buttonid).src = facebuttons[switchposition].src;
    }
}

function changedivcolor(elementid, switchposition)
{
    var setcolor = "#ffffff";
    if(switchposition == "on")
        setcolor = "#cccccc";
    document.getElementById(elementid).style.backgroundColor = setcolor;
}

function clearTextbox(elementid, starttext)
{
    var elementText = document.getElementById(elementid).value;
    if(elementText == starttext)
        document.getElementById(elementid).value = "";
}

function showCalendar(calendardate, column, row)
{
    cancelCalendarTimer();
    getCalendarDisplay(calendardate);
    document.getElementById("calendardisplaywindow").className="calendarshown";
    document.getElementById("calendardisplaywindow").style.top = (215 + (parseInt(row) * 24)) + "px";
    document.getElementById("calendardisplaywindow").style.left = (50 + (parseInt(column) * 26)) + "px";
}

function cancelCalendarTimer()
{
        window.clearTimeout(calendarTimer);
        calendarTimer = "";
}

function showherobox()
{
    cancelHeroTimer();
    document.getElementById("heroinfobox").className="herosinfoshown";
    //document.getElementById("heroinfobox").style.top = heroInfoBoxTop;
}

function cancelHeroTimer()
{
        window.clearTimeout(heroBoxTimer);
        heroBoxTimer = "";
}

function closeHeroBox()
{
    cancelHeroTimer();
    document.getElementById("heroinfobox").className="herosinfohidden";
    buttonHover('411button', 'off');
}

function closeHeroBoxTimer()
{
    heroBoxTimer = window.setTimeout("closeHeroBox()", 750);
}


function closeCalendar()
{
    cancelCalendarTimer();
    document.getElementById("calendardisplaywindow").className="calendarhidden";  
}

function closeCalendarTimer()
{
    calendarTimer = window.setTimeout("closeCalendar()", 750);  
}

function closeList(elementid)
{
    dropdownitemstimer=window.setTimeout("closeTheList()", 2000);
}

function closeTheList()
{
   document.getElementById("formitemsdropdown").className="formitemsdropdownhidden"; 
   document.getElementById(buttonid).src="images/DarkBrownArrow_closed.jpg";
}


function getCalendarDisplay(datDisplayDate)
{
    var myDiv;
    var myHeight;
    var myWidth;
    var myLabel;
    var xmlHttp;
    var myPageString;
    var myResponse;
    var displayMonth;

    myDiv = document.getElementById("calenderdisplayinner");
    myDiv.scrollTop;
    myDiv.innerHTML = "";
    try
    {   
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                alert("Your browser does not support AJAX!"); 
                return false;      
            }
        }
    }

    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            myResponse = xmlHttp.responseText
            myResponse = myResponse.substring(0, myResponse.indexOf("<!DOCTYPE ") - 1);
            myDiv.innerHTML = myResponse;
        }
    }

    myPageString = "calendarbuilder.aspx?currentDate=" + datDisplayDate;
    xmlHttp.open("GET", myPageString , true);
    xmlHttp.send(null);      
    return false;
}

function getCalendar(direction)
{
    var myDiv;
    var myHeight;
    var myWidth;
    var myLabel;
    var xmlHttp;
    var myPageString;
    var myResponse;
    var displayMonth;

    try{   
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                alert("Your browser does not support AJAX!"); 
                return false;      
            }
        }
    }

    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            myResponse = xmlHttp.responseText
            myResponse = myResponse.substring(0, myResponse.indexOf("<!DOCTYPE ") - 1);
            displayMonth = myResponse.substring(13, myResponse.indexOf("</datedisplay>")); 
            CalendarCurrentMonth = myResponse.substring(myResponse.indexOf("<currentdate>") + 13, myResponse.indexOf("</currentdate>"));
            myResponse = myResponse.substring(myResponse.indexOf("<table"));
            myDiv = document.getElementById("mycalendar");
            myLabel = document.getElementById("calendarmonth");
            myDiv.innerHTML = myResponse;
            //myDiv.firstChild.nodeValue = myResponse;
            myLabel.firstChild.nodeValue = displayMonth;    
        }
    }

    myPageString = "calendarbuilder.aspx?month=" + CalendarCurrentMonth + "&direction=" + direction;
    xmlHttp.open("GET", myPageString , true);
    xmlHttp.send(null);      

    return false;
}

function getBuildBoardItem(imageName, imageType, linkUrl, divcontainer)
{
    var myDiv;
    var myHeight;
    var myWidth;
    var myLabel;
    var xmlHttp;
    var myResponse;

    myDiv = document.getElementById(divcontainer);
    myDiv.scrollTop;
    myDiv.innerHTML = "";
    try
    {   
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                alert("Your browser does not support AJAX!"); 
                return false;      
            }
        }
    }

    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            myResponse = xmlHttp.responseText
            myResponse = myResponse.substring(0, myResponse.indexOf("<!DOCTYPE ") - 1);
            if(imageType.toLowerCase()=="video")
            {
                var movieContainer = document.createElement("div")
                movieContainer.className = "billboardmoviecontainer";
                movieContainer.id = "mymoviecontainer";
                myDiv.appendChild(movieContainer);
                var newScript = document.createElement("script");
                newScript.type = "text/javascript";
                newScript.language = "javascript";
                newScript.text = myResponse;
                movieContainer.appendChild(newScript);
                eval(movieContainer.getElementsByTagName("script")[0].text);
                loadScript("Script/autorun_mcmp_0.8.js", movieContainer);
            }
            else
                myDiv.innerHTML = myResponse;
        }
    }

    myPageString = "buildBillboardItem.aspx?imageType=" + imageType + "&imageName=" + imageName + "&linkUrl=" + linkUrl;
    xmlHttp.open("GET", myPageString , true);
    xmlHttp.send(null);      
    return false;
}
function startTheMovie(movieName)
{
    if(billboardtimer != "")
        window.clearTimeout(billboardtimer);
    document.getElementById("playpausebutton").title = "Play";
        document.getElementById("playpausebutton").src = playrotatebutton['off'].src;
    getBuildBoardItem(movieName, "video", "", "billboardholder");
}
function loadScript(url, insDiv)
{
    var newScript = document.createElement("script");
    newScript.type = "text/javascript";
    newScript.language = "javascript";
    if(newScript.readyState)
    {
        newScript.onreadystatechange = function()
        {
            if(newScript.readyState == "loaded" || newScript.readyState == "complete")
            {
                newScript.onreadystatechange = null;
                insDiv.innerHTML += automccode();
            }
        };
    }
    else
    {
        newScript.onload = function()
        {
            insDiv.innerHTML += automccode();
        }
    }
    newScript.src="Script/autorun_mcmp_0.8.js";
    insDiv.appendChild(newScript);
}
/*
function GetCoordinates(e) 
{
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	
	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
	mouseposition["x"]=posx;
	mouseposition["y"]=posy;
}*/

function navigationHover(buttonid, switchposition)
{
    var classname ="mainnav";
    if(buttonid != pagenavigation)
    {
        if(switchposition == "on")
            classname = "mainnavhot";
        if(buttonid == "navheros")
            document.getElementById("navheros").src = crossbuttons[switchposition].src;
        else
            document.getElementById(buttonid).src = navigationbuttons[switchposition].src;
                
        document.getElementById(buttonid + "link").className = classname;
    }
}

/*function pageHeightAdjustment()
{
        var leftheight;
        var rightheight;
        var height;
        rightheight = parseInt(document.getElementById("maincontent").offsetHeight);
        leftheight = parseInt(document.getElementById("leftcontent").offsetHeight);
        pageheight = parseInt(document.getElementById("pagecontainer").offsetHeight);
        //alert(pageheight);
        if(leftheight > rightheight)
        {
            height = leftheight;
        }
        else
        {
            height = rightheight;
        }
        //height += 50;
        document.getElementById("maincontent").style.height=height + "px";
        document.getElementById("leftcontent").style.height=height + "px";
}*/

function pageImageStopTimer(selectorid)
{
    var pageimageitem = new Array();
    if(pageimagetimer != "")
        window.clearTimeout(pageimagetimer);
    pageimageitem = pageimages[selectorid].split("','");
    document.getElementById("imgProgramImage").src = pageimageitem[1];
}

function pageImageStartTimer()
{
    var pageimageitem = new Array();
    pageimageindex++;
    if(pageimageindex >= pageimages.length)
        pageimageindex = 0;
    pageimageitem = pageimages[pageimageindex].split("','");
    document.getElementById("imgProgramImage").src = pageimageitem[1];
    pageimagetimer=window.setTimeout("pageImageStartTimer()", parseInt(pageimageitem[2]));
}

function playPause(elementId)
{
    var playpause;
    var buttonName;
    playpause = document.getElementById(elementId);
    buttonName = playpause.title;
    if(buttonName.toLowerCase() == "play")
    {
        playpause.title = "Pause";
        document.getElementById("playpausebutton").src = pauserotatebutton['off'].src;
        billBoardStartTimer();
    }
    else
    {
        playpause.title = "Play";
        document.getElementById("playpausebutton").src = playrotatebutton['off'].src;
        window.clearTimeout(billboardtimer);
    }
}

function resetClosetheList()
{
    if(dropdownitemstimer != "")
    {
        window.clearTimeout(dropdownitemstimer);
    }
}

function searchHover(buttonid, switchposition)
{
   document.getElementById(buttonid).src = searchbutton[switchposition].src;
}

function sponsorAdStartTimer()
{
    var sponsoraditem = new Array();
    sponsoradindex += 1;
    if(sponsoradindex >= sponsorads.length)
        sponsoradindex = 0;
    sponsoraditem = sponsorads[sponsoradindex].split("','");
    sponsorAdSwitch(sponsoraditem[0], sponsoraditem[1], sponsoraditem[2]);
    sponsoradtimer=window.setTimeout("sponsorAdStartTimer()", parseInt(sponsoraditem[3]));
    
} 

function sponsorAdSwitch(lnkurl, adtype, imagename)
{
	if(adtype == "Tower")
	{
		document.getElementById("sponsorimage").className = "sponsortallbackground";
		document.getElementById("sponsor").className = "sponsortall";
		document.getElementById("sponsorimage").src ="images/SFBFSponsorsTowerAd.jpg";
	}
	else
	{
		document.getElementById("sponsorimage").className = "sponsorbackground";
		document.getElementById("sponsor").className = "sponsor";
		document.getElementById("sponsorimage").src ="images/SFBFSponsorsBoxAd.jpg";
	}
	document.getElementById("sponsorad").href = lnkurl;
	document.getElementById("sponsoradimg").src = "images/UploadedImages/" + imagename;
	//pageHeightAdjustment();
}


function closeTheCalendar()
{
    calendarTimer="";
    document.getElementById("calendardisplaywindow").className="calendarhidden";
}

function showList(elementid, position)
{
    if(position == 'on')
    {
        document.getElementById(elementid).src="images/DarkBrownArrow_Open.jpg";
        buttonid=elementid;
        document.getElementById("formitemsdropdown").className="formitemsdropdownshown";
    }
    else
    {
        //document.getElementById(elementid).src="images/DarkBrownArrow_closed.jpg";
        dropdownitemstimer=window.setTimeout("closeTheList()", 1000);
    }
}

function switchOnOff(buttonid, sisterbuttonid, switchposition, saveid)
{
    if(switchposition == "off")
    {
        var switchresult = document.getElementById(buttonid).id;
        //alert(switchresult);
        switchresult = switchresult.substr(switchresult.length -3);
        switchresult = switchresult.replace("_", "");
        //alert(switchresult);
        document.getElementById(buttonid).src= "images/ConsoleButtonOn.jpg";
        document.getElementById(buttonid).alt = "on";
        document.getElementById(sisterbuttonid).src="images/ConsoleButtonOff.jpg";
        document.getElementById(sisterbuttonid).alt = "off";
        document.getElementById(saveid).value = switchresult;
    }
}

function switchOnOffGroup(buttonid, switchposition, saveid, radcount)
{
    if(switchposition == "off")
    {
        var basecontrol = buttonid.substr(0, buttonid.lastIndexOf("~"));
        //alert(basecontrol + "\n" + buttonid);
        for(i = 0; i < parseInt(radcount); i++)
        {
            var testcontrol = basecontrol + "~" + i;
            var switchresult;
            if(testcontrol == buttonid)
            {
                document.getElementById(buttonid).src="images/ConsoleButtonOn.jpg";
                document.getElementById(buttonid).alt = "on";
                switchresult = document.getElementById(buttonid).title;
                document.getElementById(saveid).value = switchresult;
                //alert(switchresult);
            }
            else
            {
                document.getElementById(testcontrol).alt = "off";
                document.getElementById(testcontrol).src="images/ConsoleButtonOff.jpg";
            }
        }
    }
    else
    {
                document.getElementById(buttonid).src="images/ConsoleButtonOff.jpg";
                document.getElementById(buttonid).alt = "off";
                switchresult = 0;
                document.getElementById(saveid).value = switchresult;
                //alert(switchresult);
    }
    
}

function swapbuttonImages(buttonid, buttontype, switchposition)
{
    document.getElementById(buttonid).src = swapbuttons[buttontype][switchposition].src;
}








/****************************general functions **********************************************/

function isEmailValid(oSrc, args)
{
    args.IsValid = checkMail(args.Value);
}

function checkMail(email)
{
	var x = email;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x))
	{
		return true;
	}
	else 
		return false;
	
}//end of checkMail

function checknumbers(e)
{
	var keypressed;
	var returnvalue=true;
	if(window.event)
	{
		keypressed=e.keyCode;
	}
	else
	{
		keypressed=e.which;
	}
	if(keypressed <48 ||keypressed > 57)
	{
		returnvalue=false;
		if(keypressed==0 || keypressed==8 || keypressed==13 || keypressed == 45 || keypressed == 88 || keypressed == 120 || keypressed == 32)
			returnvalue=true;
	}
	else
		returnvalue=true;

	return returnvalue;
}//end of checknumbers

function isInteger(s)
{
	var i;
	var valid=true;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) 
            valid=false;
    }
    // All characters are numbers.
    return valid;
}//end of isInteger

function stripCharsInBag(s, bag)
{
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}//end of stripCharsInBag

function daysInFebruary (year)
{
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}//end of daysInFebruary

function DaysArray(n) 
{
	for (var i = 1; i <= n; i++) 
	{
		this[i] = 31;
		if (i==4 || i==6 || i==9 || i==11) 
		{
		    this[i] = 30;
		}
		if (i==2)
		{
		    this[i] = 29;
		}
    } 
    return this;
}//end of DaysArray

function isDate(dtStr)
{
    var dtCh="/";
	var daysInMonth = DaysArray(12);
	var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);
	var strMonth=dtStr.substring(0,pos1);
	var strDay=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);
	var valid=true;
	var minYear=1972;
	var maxYear=2100;
	strYr=strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) 
	    strDay=strDay.substring(1);
	if (strMonth.charAt(0)=="0" && strMonth.length>1) 
	    strMonth=strMonth.substring(1);
	for (var i = 1; i <= 3; i++) 
	{
		if (strYr.charAt(0)=="0" && strYr.length>1) 
		    strYr=strYr.substring(1);
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	if (pos1==-1 || pos2==-1)
	{
		valid=false;
	}
	if (strMonth.length<1 || month<1 || month>12)
	{
		valid= false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month])
	{
		valid= false;
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear)
	{
		valid= false;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false)
	{
		valid= false;
	}
    return valid;
}//end of isDate


// Removes leading and ending whitespaces
function trim( value ) 
{
	return LTrim(RTrim(value));
}

// Removes leading whitespaces
function LTrim( value ) 
{
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim( value ) 
{
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}


function showPos(e)
{
    e = (e) ? e : window.event;
    var element = (e.target) ? e.target: e.srcElement;
//    for(i = 0; i < e.srcElement.attributes.length; i++)
//    {
//        alert(e.srcElement.attributes[i].name);
//    }
        
    var left = element.offsetLeft;
    var top  = element.offsetTop;
    while(element=element.offsetParent)
    {
        left += element.offsetLeft;
        top  += element.offsetTop;
    }
    //alert("Left:"+left+"px Top:"+top+"px");
    heroInfoBoxTop = top+"px";
}





/************************************ Support for SHTML pages ***************************/

function MM_preloadImages(imagename)
{
	vcfcard[1].src =imagename;
}

function MM_swapImage(elementid,notathing, imagename, position)
{
	vcfcardid = elementid;
	document.getElementById(vcfcardid).src = vcfcard[position].src;
}

function MM_swapImgRestore()
{
	document.getElementById(vcfcardid).src = vcfcard[0].src;
}




