﻿var NumOfWhereToBuy = 7;

function loadRotatingBanner()
{ 
    //index1 = 0;
    index1 = Math.floor(Math.random()*NumOfWhereToBuy);
    
    listofimages = new Array(NumOfWhereToBuy);
    listofimages[0] = new Image()
    listofimages[0].src = "http://www.opti-ups.com/images/wheretobuy/logo_h100_42006.gif"
    listofimages[1] = new Image()
    listofimages[1].src = "http://www.opti-ups.com/images/wheretobuy/logo_h100_42006.gif"
    listofimages[2] = new Image()
    listofimages[2].src = "http://www.opti-ups.com/images/wheretobuy/logo_h100_42006.gif"
    listofimages[3] = new Image()
    listofimages[3].src = "http://www.opti-ups.com/images/wheretobuy/logo_h100_42006.gif"
    listofimages[4] = new Image()
    listofimages[4].src = "http://www.opti-ups.com/images/wheretobuy/Datavision_logo.gif"
    listofimages[5] = new Image()
    listofimages[5].src = "http://www.opti-ups.com/images/wheretobuy/altex.gif"
    listofimages[6] = new Image()
    listofimages[6].src = "http://www.opti-ups.com/images/wheretobuy/ICOMTECH-logo.gif"


    thetimer = setTimeout("changeimage()", 500);

} 

function changeimage()
{ 
    var d = new Date();

    index1 = index1 + 1
    if (index1 >= (NumOfWhereToBuy - 1))
    {
        index1 = 0 
    }
    imagesource = listofimages[index1].src + "?time=" + d.getTime();
    document.images["imgRotate"].src = imagesource
    thetimer = setTimeout("changeimage()", 5000);
} 

function TogglePanel(panelId,linkId)
{
	var panel = document.getElementById(panelId);
	var title = document.getElementById(linkId); 
	panel.style.display = (panel.style.display == "none") ? "block" : "none";
	title.className = (panel.style.display == "none") ? "FAQCollapsed" : "FAQExpanded";
}

function TrimSpace(strWord)
{
    return strWord.replace(/^\s*|\s*$/g,"");
}

function SearchClick(redirectLocation, textBoxID)
{
    var txtSearch = document.getElementById(textBoxID);
    var url = redirectLocation;
    
    if (txtSearch == null)
    {
        return true;
    }
    
    var searchText = txtSearch.value;
    
    if (TrimSpace(searchText).length <= 1) 
    {
        alert('Please enter at least 2 characters into the search box.');
        return false;
    }
        
    if ((searchText != null) && (searchText.length >= 2))
    {
        if (url.indexOf("?") < 0)
            url += "?";
        url += "text=" + escape(searchText);
    }
    
    location = url;
    return false;
}