// website-test10
var slideHashA = [];
initializeSlideHashF();

function assignHashF(hashS1,hashS2){
    // delay for ie
    clearTimeout(delayHashTO);
    delayHashTO = setTimeout(function(){assignHashRealF(hashS1,hashS2);},50);
}

function assignHashRealF(hashS1,hashS2){
    // called from scrollF() and donateF() and bottomF()
    // hashS1 and hashS2 are never both passed during any one call
    var hrefA = location.href.split("#");
    //alert("1 assign: :"+hashS1+":"+hashS2+":"+window.location.hash+":");
    if(!hrefA[1]){
       // no hash assigned, yet.  initial hash
       //alert("1.5");
       // window.location.hash = '#' + numToStringF(index);
       window.location.hash = numToStringF(index);
       prevHashS = numToStringF(index);
    } else {
        hashA = hrefA[1].split("_");
        if(hashS1){
            prevHashS = hashS1;
            if(hashA[1]){
                //alert("2 assign: "+hashS1);
                window.location.hash = hashS1+"_"+hashA[1];
            } else {

                window.location.hash = hashS1;
                //alert("3 assign: "+window.location.hash);
            }
        }
        if(hashS2){
             //alert("4 ::"+hashS2+"::");
             previousBottomHashS = hashS2;
             window.location.hash = hashA[0]+"_"+hashS2;
        }
    }
    //alert("2 assign: :"+hashS1+":"+hashS2+":"+window.location.hash+":");
    fb_button(window.location.href);
}

function hashCheckF(){
    //alert("check:"+window.location.hash+":");
    var tempHashS = window.location.href.split("#")[1];
    if(tempHashS != prevHashS){

        prevHashS = tempHashS;
        var hashA = tempHashS.split("_");

        if(stringToNumF(hashA[0])){
            var indexNum = stringToNumF(hashA[0]);
            if(isNaN(indexNum)){
                indexNum = 1;
            }
            if(indexNum<=5 && index!=indexNum){
                index = indexNum;
                //alert("hashCheckF:"+tempHashS+":"+prevHashS+":");
                scrollF();
            }
        }
        if(previousBottomHashS!=hashA[1]){
            bottomF(hashA[1]);
            previousBottomHashS = hashA[1];
        }
    }
}

function initialHashF(){
    window.location.hash = '#' + numToStringF(index);
}

function initializeSlideHashF(){
    slideHashA[1] = "intro";
    slideHashA[2] = "malaria";
    slideHashA[3] = "what-we-are-doing";
    slideHashA[4] = "impact";
    slideHashA[5] = "take-action";
}
function stringToNumF(s){
    for(var i=1;i<slideHashA.length;i++){
        if(s==slideHashA[i]){
            return i;
        }
    }
    return 1;
}
function numToStringF(n){
   return slideHashA[n];
}
