function GetXmlHttpObject() { 
    var objXMLHttp=null
        if (window.XMLHttpRequest) {
           objXMLHttp=new XMLHttpRequest()
        }
        else if (window.ActiveXObject) {
            objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
        }
    return objXMLHttp
} 
function validError(msg){
    wait.style.display = "none";
	alert (msg);
	return false;
}
function storeEmail(type) {
    wait = document.getElementById("wait" + type);
    wait.style.display = "";
	xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null) {
		return validError ("Your browser does not support AJAX.\nPlease enable HTTP requests or use a different browser.")
	}
	var fld = document.getElementById("email" + type);
	if (fld.value == ""){
	    return validError("Please check your input and resubmit.")
	}
	if (type == 0){
	    if (fld.value.search(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i) == -1){
	        return validError ("Please correct your email address and resubmit.");
	    }
	    url = "/email-insert.ashx?email=" + fld.value + "&text=" + type;
	}else{
	    if (fld.value.search(/^[0-9]{3}-?[0-9]{3}-?[0-9]{4}$/i) == -1){
	        return validError ("Please correct your cell phone number and resubmit.");
	    }
	    car = document.getElementById("car").value;
	    if (car == ""){
	        return validError ("Please select a cell phone carrier.");
	    }
	    url = "/email-insert.ashx?email=" + fld.value.replace(/-/g, "") + "@" + car + "&text=" + type;
	}
    xmlHttp.onreadystatechange = getResultAddRecord;
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
	
}
function getResultAddRecord() {
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
        if (xmlHttp.responseText.substr(0,1) == 1) {
            var type = xmlHttp.responseText.split("|")[1];
            storeComplete(type);
        }else{
            return validError ("There was an unexpected error, please try again.");
        }
    }
}
function storeComplete(type){
    wait.style.display = "none";
    if (type == 0){
        typeName = "email address";
        inpt = document.forms[0].elements["0"];
        inpt.value = "Email Address"
        inpt.style.color = '#AEAEAE';
    }else{
        typeName = "cell phone number";
        inpt = document.forms[0].elements["1"];
        inpt.value = "10-digit #"
        inpt.style.color = '#AEAEAE';
        slct = document.getElementById("car");
        slct.value = "";
        slct.style.color = '#AEAEAE';
    }
    alert("Thank you for submitting your " + typeName + ",\nwe'll let you know when the voting begins." );
}
function numeralsOnly(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode;
    if (charCode == 45) return true;
    else if (charCode > 57 || (charCode  > 31 && charCode < 48)) return false;
    else return true;
}
function inputColor(){
    inpt = document.getElementById("email0");
    if (inpt.value != 'Email Address') inpt.style.color = '#000000';
    inpt = document.getElementById("email1");
    if (inpt.value != '10-digit #') inpt.style.color = '#000000';
}
function selectColor(){
    slct = document.getElementById("car");
    if (slct.value == '') {
        slct.style.color = '#AEAEAE';
    }else{
        slct.style.color = '#000000';
    }
}
function startup(){
    inputColor();
    selectColor(); 
}

function showVideo() {
	document.getElementById("fadeCover").style.display = "block";
	$("#videoPop").fadeIn("slow");
}
function hideVideo() {
    document.getElementById("ytplayer").stopVideo();
    $("#videoPop").fadeOut("slow");
	document.getElementById("fadeCover").style.display = "none";
}


var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
function fixPNG(myImage) 
{
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	   myImage.outerHTML = strNewHTML	  
    }
}
var mediaArry = new Array();
for (i=0; i <17; i++)mediaArry[i]=new Array(3)

mediaArry[2][0]= "DetroitNews";
mediaArry[2][1]= "28";
mediaArry[2][2]= "The Little Town That Could<div>Detroit News</div>";

mediaArry[1][0]= "Advocate";
mediaArry[1][1]= "40";
mediaArry[1][2]= "It's an explosive idea. The ripple effect is very literal.<div>Stamford Advocate</div>";

mediaArry[0][0]= "MontrealGazette"
mediaArry[0][1]= "31"
mediaArry[0][2]= "Imagine a movie-set town with a drugstore, grocery store, coin laundry, working traffic lights, cinema, doctor's office, bank and library. Now, imagine that this town is indoors, completely safe and accessible only to those invited to come and play.<div>Montreal Gazzette</div>"

mediaArry[3][0]= "StarLedger"
mediaArry[3][1]= "36"
mediaArry[3][2]= "In a world where it's easy to be scared about our future, something like this gives you something to smile about.<div>New Jersey Star Ledger</div>"

mediaArry[4][0]="DetroitFree"
mediaArry[4][1]="30"
mediaArry[4][2]="Rebecca, diagnosed with cerebral palsy, has benefited from Friendship Circle programs for years, most notably the weekly visits a teen volunteer makes to her Bloomfield Township home.<div>Detroit Free Press</div>"

mediaArry[5][0]="PhiladelphiaInquirer"
mediaArry[5][1]="44"
mediaArry[5][2]="The Friendship Circle has been a balm for Seth who is on the Autistic Spectrum<div>Philadelphia Inquirer</div>"

mediaArry[6][0]="SunSentinel"
mediaArry[6][1]="37"
mediaArry[6][2]="Friendship Circle helps special needs youngsters<div>South Florida Sun-Sentinel</div>"

mediaArry[7][0]="PostGazette"
mediaArry[7][1]="34"
mediaArry[7][2]="Teenagers make special connections in Friendship Circle<div>Pittsburgh Post-Gazette</div>"

mediaArry[8][0]="MiamiHerlad"
mediaArry[8][1]="38"
mediaArry[8][2]="Bella is 4 and was born with a disability called global developmental delay. She spends most of her day in occupational and speech therapies. But for an hour and a half on Tuesday afternoons, the once-shy Bella gets to have fun and just be a normal kid.<div>Miami Herlad</div>"

mediaArry[9][0]="JerusalemPost"
mediaArry[9][1]="48"
mediaArry[9][2]="Friendship Circle is a wonderland for kids who have attention deficit disorders, autism, Down syndrome, cerebral palsy - anybody who feels awkward and anybody who just needs a friend.<div>Jerusalem Post</div>"

mediaArry[10][0]="SanDiego"
mediaArry[10][1]="48"
mediaArry[10][2]="Children with disabilities get social outlet in group<div>San Diego Union-Tribunre</div>"

mediaArry[11][0]="Agoura"
mediaArry[11][1]="48"
mediaArry[11][2]="Friendship Circle offers special programs<div>Agoura Hills Acorn</div>"

mediaArry[12][0]="NYDailyNews"
mediaArry[12][1]="25"
mediaArry[12][2]="You cannot believe the bonds that develop among the children and the teens<div>New York Daily News</div>"

mediaArry[13][0]="BostonHerald"
mediaArry[13][1]="62"
mediaArry[13][2]="Friendship lights up the season. Jewish teenagers aid youngsters with special needs<div>Boston Herald</div>"

//mediaArry[14][0]="NBCNightly"
//mediaArry[14][1]="104"
//mediaArry[14][2]="It's as if kids rule the world<div>NBC Nightly News</div>"

mediaArry[14][0]="JewishWeek"
mediaArry[14][1]="33"
mediaArry[14][2]="Like a stone cast into a pond, the ripple effect continues.<div>The Jewish Week</div>"

mediaArry[15][0]="JerseyNews"
mediaArry[15][1]="39"
mediaArry[15][2]="With the program's popularity leading to rapid expansion worldwide in the past decade<div>New Jersey News Transcript</div>"

mediaArry[16][0]="NewportBeach"
mediaArry[16][1]="57"
mediaArry[16][2]="In the past two years, the program has paired about 100 young volunteers with special-needs kids for outings and in-home visits. The program also organizes day camp programs for special-needs children.<div>Newport Beach Costa Mesa Daily Pilot</div>"


var testArry = new Array();
for (i=0; i <12; i++) testArry[i]=new Array(2)


testArry[0][0]="-53px"
testArry[0][1]="\"I am honored to acknowledge your commitment to the Friendship Circle. The noble dedication you have shown to children with special needs is inspiring.\"<span> &mdash; President Barack Obama</span>"

testArry[3][0]="left"
testArry[3][1]="\"It is my heartfelt privilege to recognize the volunteers for their compassionate commitment to the Michigan Friendship Circle.\"<span> &mdash; Michigan Governor Jennifer Granholm</span>"

testArry[9][0]="-212px"
testArry[9][1]="\"The Friendship Circle does absolutely incredible work.\"<span> &mdash; Representative Gary Peters</span>"

testArry[1][0]="-159px"
testArry[1][1]="\"Alyssa is like a kid in a candy shop when she goes to see her friends at Friendship Circle.\"<span> &mdash; Parent</span>"

testArry[4][0]="-106px"
testArry[4][1]="\"The Friendship Circle provided me with friends and truly made me feel special.\"<span> &mdash; Individual with Special Needs</span>"

testArry[6][0]="-53px"
testArry[6][1]="\"I am honored to acknowledge your commitment to the Friendship Circle. The noble dedication you have shown to children with special needs is inspiring.\"<span> &mdash; President Barack Obama</span>"

testArry[5][0]="-265px"
testArry[5][1]="\"It's like walking into a giant hug.\"<span> &mdash; Parent</span>"

testArry[10][0]="-318px"
testArry[10][1]="\"Once you go its hard to stop coming back because this place is truly special.\"<span> &mdash; Volunteer</span>"

testArry[2][0]="-530px"
testArry[2][1]="\"Thank you Friendship Circle for making my life complete.\"<span> &mdash; Volunteer</span>"

testArry[7][0]="-477px"
testArry[7][1]="\"Friendship Circle has taught me how to be a better person.\"<span> &mdash; Volunteer</span>"

testArry[8][0]="-371px"
testArry[8][1]="\"Thanks for providing a special place for a special child.\"<span> &mdash; Parent</span>"

testArry[11][0]="-424px"
testArry[11][1]="\"Friendship Circle has provided a place for my students to experience personal growth.\"<span> &mdash; Special Education Teacher</span>"

var currentMedia = 0;
var currentTest = 0;
function toggleTest(ctr){
    $("#mediaCont").fadeOut("slow"); 
}
function toggleMedia(){
    var $mediaCont = $("#mediaCont");
    if ($.browser.msie && $.browser.version <= 6 ) $mediaCont.css("background-color", "#FFFFFF");
    $mediaCont.fadeTo("slow", ".15", function(){ 
        $mediaCont.css("background-image","url(/images/media" + mediaArry[currentMedia][0] + ".jpg)");
        $mediaCont.css("padding-top", mediaArry[currentMedia][1] + "px");
        $mediaCont.html(mediaArry[currentMedia][2]);
        $mediaCont.fadeTo('slow', "1");
    }); 
}
function toggleTest(){
    var $testCont = $("#testCont");
    var $testPic = $("#testPic");
    var $peopleItemInner = $("#peopleItemInner");
    $testCont.fadeTo("slow", ".15", function(){
        $testPic.css("background-position", testArry[currentTest][0] + " top");
        $peopleItemInner.html(testArry[currentTest][1]);
        $testCont.fadeTo('slow', "1");
    });     
}

function changeMedia() {
	currentMedia = (currentMedia == mediaArry.length-1 ? 0 : currentMedia + 1);
    toggleMedia();
}
function changeTest() {
	currentTest =(currentTest == testArry.length-1 ? 0 : currentTest + 1);
	toggleTest();
}
function startTimers() {  
    testTimer = setInterval(changeTest, 7000); 
    mediaTimer = setInterval(changeMedia, 7000); 
}
startTimers();
$(document).ready(function () {
    var $testCont = $("#testCont");
    $testCont.hover(function() {
        clearInterval(testTimer);},
        function() {
            testTimer =  setInterval( "changeTest()", 7000 );
    });
    var $mediaCont = $("#mediaCont");
    $mediaCont.hover(function() {
        clearInterval(mediaTimer);},
        function() {
            mediaTimer =  setInterval( "changeMedia()", 7000 );
    });
});





