var ns6 = (!document.all && document.getElementById);
var wordLang = "";
var WindowIsOpen = 0;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function clearSearchField() {

    var currentStr = document.getElementById('txtMasloolSearch').value;

    if (currentStr.indexOf("חפש", 0) != -1) {
        document.getElementById('txtMasloolSearch').value = '';
    }
}

function setCenterHeight() {
    var newHeight;
    var pathRight;

    if (!top.frames["iframeCenter"]) {
        return;
    }

    if (top.document.getElementById("iframeRight")) {
        pathRight = top.document.getElementById("iframeRight");
    }
    else {
        pathRight = top.document.getElementById("masterRight");
    }
    if (top.frames["iframeCenter"].document.body.scrollHeight < pathRight.height) {
        newHeight = pathRight.height;
    }
    else {
        newHeight = top.frames["iframeCenter"].document.body.scrollHeight;
    }
    // set the height of the iframe
    top.document.getElementById('iframeCenter').height = newHeight;

    // now set the height of the body itself.  this is for a style that was placed in the body, 
    // to create a line on the sides to reach the bottom of the page.
    top.frames["iframeCenter"].document.body.style.height = newHeight + "px";
}

function setMasterHeight() {
    var newHeight;
    var pathMain = top.document.getElementById("masterMain");
    var pathRight = top.document.getElementById("masterRight");
    top.document.getElementById("masterMain").style.height = "";
    top.document.getElementById("masterRight").style.height = "";
    if (pathMain.offsetHeight < pathRight.offsetHeight) {
        pathMain.style.height = pathRight.offsetHeight + 'px';
    }
    else {
        pathRight.style.height = pathMain.offsetHeight + 'px';
    }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function chooseBack() {

    try {
        if (top.loadedDefaultPg == true) {
            history.back();
        }
        else {
            loadSiteDefaultPage();
        }
    }
    catch (exception) {
        history.back();
    }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function checkPoll() {
    var poll = GetParamTop("poll");

    if (poll != "") {
        return "Seker/SekerResults.aspx?poll=" + poll + "&site=" + GetParamTop("site");
    }
    else {
        return "";
    }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function addSetDt(charBeforeParam, set_date) {
    if (top.needSetDt) {
        if (set_date == undefined || set_date == 'undefined' || set_date == '') {
            set_date = GetParam("set_date");
        }
        if (set_date != '') {
            return (charBeforeParam + "set_date=" + set_date);
        }
    }
    return "";
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function unicodeDelimited(tempstr) {
    var chrIndx;
    var str = '';

    for (chrIndx = 0; chrIndx < tempstr.length; chrIndx++) {
        str = str + "@" + tempstr.charCodeAt(chrIndx) + ";";
    }

    return str;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function Convert_Unicode(str) {
    tempStr = '';
    j = str.indexOf('&#');
    if (j >= 0) {
        while (j >= 0) {
            tempStr = tempStr + str.substring(0, j) + String.fromCharCode(str.substring(j + 2, j + 6));
            str = str.substring(j + 7, str.length);
            j = str.indexOf('&#');
            if (j < 0) { tempStr += str; }
        }
        str = tempStr;
    }
    if (str.indexOf('<br>') > 0) {
        str = del_br(str);
    }
    return str;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// <br> פונקציה המעלימה
function del_br(str) {

    j = str.indexOf('<br>');
    if (j > 0) {
        iLen = str.length;
        tempStr = '';
        while (j > 0) {
            j = str.indexOf('<br>');
            str = str.replace("<br>", "");
            if (j > 0)
                tempStr = tempStr + str.substring(0, j - 4);
            str = str.substring(j - 4, iLen);
        }
        str = tempStr + str;
    }
    return str;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function getFlashMovieObject(movieName) {
    if (window.document[movieName]) {
        return window.document[movieName];
    }
    if (navigator.appName.indexOf("Microsoft Internet") == -1) {
        if (document.embeds && document.embeds[movieName])
            return document.embeds[movieName];
    }
    else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
    {
        return document.getElementById(movieName);
    }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function doMasloolSearch() {
    clearSearchField(); //clear if still contains default text חפש...
    getMasloolSearchAction();  //this function is in each site's javascript
    document.getElementById("masloolSearchForm").submit();
    //clear for next search!
    document.getElementById('txtMasloolSearch').value = '';
    return false;
}

function doSearch() {
    getSearchAction();  //this function is in each site's javascript
    document.getElementById("searchForm").submit();
    return false;
}

function doSchedSearch() {
    getSchedSearchAction();  //this function is in each site's javascript
    document.getElementById("schedSearchForm").submit();
    return false;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function slowScrollTo(speed, currentScreenY, elementHeight) {
    var screenHeight = ns6 ? top.innerHeight : top.document.body.clientHeight;

    if ((screenHeight - currentScreenY) < elementHeight) {
        performScroll(0, speed, elementHeight);
    }
}

function performScroll(step, speed, limit) {
    var temp;
    if (step <= limit) {
        top.scrollBy(0, speed);
        temp = (step + speed) * 1;
        setTimeout("performScroll(" + temp + "," + speed + "," + limit + ")", 10);
    }
}

function slowScrollUp(step, speed, limit) {
    //	this function scrolls BACKWARDS, the speed MUST be a negative number!

    var temp;
    if (step >= limit) {
        top.scrollBy(0, speed);
        temp = (step + speed) * 1;
        setTimeout("slowScrollUp(" + temp + "," + speed + "," + limit + ")", 10);
    }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function openRSSWin() {
    var whichRss = "";
    if (top.subsiteRss == undefined) {
        try {
            whichRss = subsiteRss;
        }
        catch (exception) { }  
    }
    else { whichRss = top.subsiteRss; }
    if (whichRss == 'undefined' || whichRss == undefined || whichRss == "") {
        NewWinParamId('http://www.iba.org.il/rss/', '541', '450', 'rssWin', 'yes', 'yes');
    }
    else {
        NewBrowserMax('http://www.iba.org.il/rss/' + whichRss);
    }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//MEDIA FUNCTIONS

function MediaWithParams(type, site_code, entity_code, urlStr) {
    var strLink = '?';

    switch (type) {
        case 'radioLive':
            if (strLink.length > 1) strLink += '&';
            strLink += 'liveRadio=' + site_code;
            break;

        case 'radioRecorded':
            if (strLink.length > 1) strLink += '&';
            switch (site_code) {
                case 136: // 'מהדורות רשת ב
                    strLink += 'mahadura=yes';
                    break;

                case 131: // רק"ע foreign languages
                    strLink += 'foreign=yes';
                    break;

                case 151: // arabic
                    strLink += 'arabic=yes';
                    break;

                default:
                    if (site_code != 0) {
                        strLink += ('recorded=' + site_code);
                    }
            }
            break;

        case 'tvRecorded':
            break;

        case 'tvLive':
            if (strLink.length > 1) strLink += '&';
            strLink += 'liveTv=yes';
            break;

        default:
            if (site_code == 137) {
                if (strLink.length > 1) strLink += '&';
                strLink += 'site=137&page=150';
            }
            else {
                if (urlStr != '') {

                    CastupOnly(urlStr);
                    return;
                }
            }
    }

    if (urlStr != '') {
        //	This function opens the media Window for a specific url.
        //	Open and play right away!

        //	The url must come as ONE parameter string.  An & would break it up.	

        //var mediaUrl = replaceStr(replaceStr(urlStr,"&amp;","91zA81"),"&","91zA81");
        if (strLink.length > 1) strLink += '&';
        //strLink += 'broadcastUrl=' + mediaUrl;
        strLink += 'broadcastUrl=' + createUrl(urlStr);
    }

    mediaWindow(strLink);

}

function shareUrl(u)
{
    var tmpUrl = replaceStr(u,"http://","");
    tmpUrl = replaceStr(tmpUrl, "?", "--");
    tmpUrl = replaceStr(tmpUrl, "&", "__");
    return tmpUrl;
}

function createUrl(mUrl) {
    var tempUrl = replaceStr(mUrl, ":", "%3A");
    tempUrl = replaceStr(tempUrl, "/", "%2F");
    tempUrl = replaceStr(tempUrl, ".", "%2E");
    tempUrl = replaceStr(tempUrl, "?", "%3F");
    tempUrl = replaceStr(tempUrl, "&", "91zA81");
    tempUrl = replaceStr(tempUrl, "&amp;", "91zA81");
    tempUrl = replaceStr(tempUrl, "=", "%3D");
    return tempUrl;
}

function MediaLiveRadioForSite(site_code) {

    //	This function calls the media Window for a specific site.
    //	The media window gets the url for this site, and plays right away!

    strLink = '?liveRadio=' + site_code;

    mediaWindow(strLink)

}

// this must be the same in webgolesh!!!
var cuWinTypes = { "regular": 0, "mondial": 1, "popAudio": 2, "miniEpl": 3 };
var cuWinStyles = new Array(); // (w,h,mediaLnkColor,mediaLnkBgColor)
cuWinStyles[0] = new Array(320, 285, '#CB0001', '#F0F0F0');
cuWinStyles[1] = new Array(502, 462, '#C1C0C0', '#303030');
cuWinStyles[2] = new Array(508, 251, '#C1C0C0', '#303030');
cuWinStyles[3] = new Array(502, 462, '#C1C0C0', '#303030');

function CastupOnly(strWindowAddrss, titleStr, showLinkToMediaCenter, winType) {
    var str = strWindowAddrss;
    var linkHeight = 30;
    var title = ">iba - Israel Broadcasting Authority";  /* the > is here because otherwise .net forces a new row. */
    var linkToMediaCenter = "";
    var siteWinType = "";

    //get the window type desired for this window.  If a specific type is sent
    //as a parameter then use that.  Otherwise check if a variable was set in the
    //specific site.  If yes, use that one, otherwise - default is 0.
    if (winType == undefined || winType == "") {
        //variable located in individual site javascript - if needed
        if (top.cuOnlyWinType == undefined) 
        {
            try {
                siteWinType = cuOnlyWinType;
            }
            catch (exception) { }
        }
        else
        { siteWinType = top.cuOnlyWinType; }
        if (siteWinType != undefined && siteWinType != "") {
            winType = siteWinType;
        }
        else {
            winType = "regular";
        }
    }
    var winStyleIndex = cuWinTypes[winType];
    var w = cuWinStyles[winStyleIndex][0];
    var mediaH = cuWinStyles[winStyleIndex][1];
    var mediaLnkColor = cuWinStyles[winStyleIndex][2];
    var mediaLnkBgColor = cuWinStyles[winStyleIndex][3];

    var windowH = mediaH;

    if (titleStr != undefined && titleStr != "") {
        title = titleStr;
    }

    if (showLinkToMediaCenter == undefined || showLinkToMediaCenter) {
        windowH += linkHeight;

        linkToMediaCenter = "<div style=padding-top:7px;padding-bottom:10px;text-align:center;" +
	                                    "text-decoration:underline;cursor:pointer;cursor:hand;" +
	                                    "font-size:12px;font-family:arial;" +
	                                    "color:" + mediaLnkColor + ";background-color:" + mediaLnkBgColor + ";" +
	                            " onclick=\"var win2=open('http://www.iba.org.il/','','width='+screen.availWidth+',height='+screen.availHeight+',top=0,left=0,scrollbars=yes,location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes');win2.opener=self;\"" +
	                            " dir=rtl>למרכז השידורים :: To the IBA Broadcasts Center</div>";
    }

    var LeftPosition = (screen.width) ? (screen.width - w) / 2 : 100;
    var TopPosition = (screen.height) ? (screen.height - windowH) / 2 : 100;

    var sMarkup = "<html><head><tit" + "le>" + title + "</title>" +
                  "<SCR" + "IPT langauge='javascript'>var cuSrc='" + strWindowAddrss + "';<\/SCR" + "IPT>" +
                  "</head><body style=background-color:#F0F0F0;margin:0px;>" +
                  "<iframe id='CastUpIframe' name='CastUpIframe' align='center'" +
                  " width=" + w + " height=" + mediaH +
                  " frameborder=0 scrolling=no>&#160;</iframe>" +
                  "<iframe id='cuTicketIFrame' name='cuTicketIFrame' width='0' height='0' src='CUTicket.aspx'>&#160;</iframe>" +
                  linkToMediaCenter + "</body></html>";

    win = window.open("blank.htm", "castup", "width=" + w + ",height=" + windowH +
	                                ",top=" + TopPosition + ",left=" + LeftPosition +
	                                ",scrollbars=no,directories=no,menubar=no,toolbar=no,resizable=no");

    win.document.write(sMarkup);

    win.opener = self;
}

function mediaWindow(strWindowAddrss) {
    NewBrowserMax("http://www.iba.org.il/" + strWindowAddrss);
    //	NewBrowserMax("http://devweb1/website/broadcasts.asp" + strWindowAddrss);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function galleryZoom(mypic, title) {
    NewWindowScroll('general/html/PictureZoom.htm?picture=' + mypic + '&title=' + escape(title), 450, 400, 'yes')
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function linkPnimi(entity, lang) {
    NewWindowScroll("iba.aspx?type=simple&entity=" + entity + "&lang=" + lang, 600, 400, 'yes');
}

function linkPrint(lang, printPgW) {
    var pgW = 700;
    if (printPgW != undefined) {
        pgW = printPgW;
    }
    if (lang == 'arabic') {
        NewWinParamId('general/html/printPageArabic.html', pgW, 460, 'printPg', 'no', 'yes');
    }
    else {
        NewWinParamId('general/html/printPage.html', pgW, 460, 'printPg', 'no', 'yes');
    }
}

function linkSendFriend(lang, linkFromPage) {
    if (lang == 'arabic') {
        NewWinParamId('general/html/sendToFriendArabic.html?linkFromPage=' + linkFromPage, 320, 351, 'sendToFriend', 'no', 'no');
    }
    else {
        NewWinParamId('general/html/sendToFriend.html?linkFromPage=' + linkFromPage, 320, 351, 'sendToFriend', 'no', 'no');
    }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function NewWindowScroll(mypage, w, h, scroll) {
    //This function creates a window that stands alone --> not connected to parent
    //	each time the function is called it CREATES A NEW WINDOW

    //mypage - URL (-Link)
    //w - width
    //h - height
    //scroll - yes/no
    LeftPosition = (screen.width) ? (screen.width - w) / 2 : 100; TopPosition = (screen.height) ? (screen.height - h) / 2 : 100;
    settings = 'width=' + w + ',height=' + h + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
    win = open(mypage, '', settings);
    win.opener = self;
    if (win.focus) { win.focus(); }
}

function NewWinParamId(mypage, w, h, winId, resize, scroll) {
    //This function creates a window that stands alone --> not connected to parent
    //   it is created with a unique id.  Any time the function is called with 
    //   the same id, it will switch the contents 
    //	 of the window ===>  NOT CREATING A NEW WINDOW

    //mypage - URL (-Link)
    //w - width
    //h - height
    //winId - popup window id
    //resize - yes/no
    //scroll - yes/no

    try {
        if (win) {
            win.close();
        }
    }
    catch (exception) {
    }

    LeftPosition = (screen.width) ? (screen.width - w) / 2 : 100; TopPosition = (screen.height) ? (screen.height - h) / 2 : 100;
    settings = 'width=' + w + ',height=' + h + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=' + resize;
    win = open(mypage, winId, settings);
    if (win.focus) { win.focus(); }
}

function PopUpElections() {
    //This function creates a window that stands alone --> not connected to parent
    //   it is created with a unique id.  Any time the function is called with 
    //   the same id, it will switch the contents 
    //	 of the window ===>  NOT CREATING A NEW WINDOW

    //mypage - URL (-Link)
    //w - width
    //h - height
    //winId - popup window id
    //resize - yes/no
    //scroll - yes/no

    try {
        if (win) {
            win.close();
        }
    }
    catch (exception) {
    }

    w = 526;

    if (screen.height > 600) {
        h = 700;
    }
    else {
        h = 470;
    }
    LeftPosition = (screen.width) ? (screen.width - w) / 2 : 100; TopPosition = (screen.height) ? (screen.height - h) / 2 : 100;
    settings = 'width=' + w + ',height=' + h + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
    win = open("http://www.iba.org.il/Seker/SekerElection.aspx", "Elections", settings);
    if (win.focus) { win.focus(); }
}

function NewBrowserMax(mypage) {
    // this function does not set the focus to itself
    // like the other ones.
    // it opens in a max sized window
    // the id for the window is '' and not null, so that
    // each page will open a new window, not replace the 
    // one opened before.

    settings = 'width=' + screen.availWidth + ',height=' + screen.availHeight + ',top=0,left=0,scrollbars=yes,location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes';
    win = open(mypage, '', settings);
    win.opener = self;
}

//compatibility with webgolesh
function NewBrowserWindow(mypage, w, h) {
    NewBrowserSmall(mypage, w, h);
}

function NewBrowserSmall(mypage, w, h) {
    // this function does not set the focus to itself
    // like the other ones.
    // it opens in a max sized window
    // the id for the window is '' and not null, so that
    // each page will open a new window, not replace the 
    // one opened before.

    LeftPosition = (screen.width) ? (screen.width - w) / 2 : 100; TopPosition = (screen.height) ? (screen.height - h) / 2 : 100;
    settings = 'width=' + w + ',height=' + h + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=yes,location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes';
    win = open(mypage, '', settings);
    win.opener = self;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function imgOn(imgName) // Function to 'activate' images
{
    if (document.images) {
        document[imgName].src = eval(imgName + "on.src");
    }
}

function imgOff(imgName) // Function to 'deactivate' images.
{
    if (document.images) {
        document[imgName].src = eval(imgName + "off.src");
    }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function printPage(id) {
    document.getElementById(id).style.visibility = 'hidden';
    window.print();
    document.getElementById(id).style.visibility = 'visible';
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function GetParamTop(name) {
    return searchForParam(top.queryStr, name);
}

function GetParam(name) {
    //		this function checks if a parameter exists.
    return searchForParam(document.location.search, name);
}

function searchForParam(strParam, name) {
    //		this function checks if a parameter exists.	  	

    var start = strParam.indexOf("?" + name + "=");

    if (start < 0) start = strParam.indexOf("&" + name + "=");

    if (start < 0) return '';

    start += name.length + 2;

    var end = strParam.indexOf("&", start) - 1;

    try {
        if (end < 0) {
            end = strParam.length;
        }
    }
    catch (exception) {
        return ''
    }

    var result = strParam.substring(start, end);
    var result = '';

    for (var i = start; i <= end; i++) {
        var c = strParam.charAt(i);
        result = result + (c == '+' ? ' ' : c);
    }

    return unescape(result);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function textCounter(whichField, maxLimit) {
    //  Check the length of an input box.  If too long...trim it!

    var field = document.getElementById(whichField)
    if (field.value.length > maxLimit - 1) {
        field.value = field.value.substring(0, maxLimit - 1);
    }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function removeBR(whichStr) {
    while (whichStr.search("<br>") != -1) {
        whichStr = whichStr.replace("<br>", " ");
    }
    return whichStr;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function startCu(urlToPlay, pathToFrame, scroll) {
    top.cuSrc = urlToPlay;
    pathToFrame.getElementById('cuTicketIFrame').src = "CUTicket.aspx?Scroll=" + scroll;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function startBlink(speedBlink) {
    blinkingInterval = setInterval("doBlink()", speedBlink);
}

function doBlink() {
    var blink = document.all.tags("blink")
    for (var i = 0; i < blink.length; i++) {
        blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "";
    }
}

function stopBlinkTag() {
    clearInterval(blinkingInterval);
    var blink = document.all.tags("blink")
    for (var i = 0; i < blink.length; i++) {
        blink[i].style.visibility = "";
    }
}

function startBlinkSpans(speedBlink) {
    blinkingSpansInterval = setInterval("doBlinkSpans()", speedBlink);
}

function doBlinkSpans() {
    var blink = document.getElementsByName("blink");
    for (var i = 0; i < blink.length; i++) {
        blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "";
    }
}

function stopBlinkSpans() {
    clearInterval(blinkingSpansInterval);
    var blink = document.getElementsByName("blink");
    for (var i = 0; i < blink.length; i++) {
        blink[i].style.visibility = "";
    }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

var objBlink;
var blinkInterval = 0;

function blinkObj(whichOne, speed) {
    if (blinkInterval != 0) {
        stopBlink()
    }
    objBlink = whichOne;
    blinkInterval = setInterval("doBlinkObj()", speed);
}

function stopBlink() {
    clearInterval(blinkInterval);

    try {
        objBlink.style.visibility = '';
    }
    catch (exception) { }
}

function doBlinkObj() {
    if (objBlink.style.visibility == 'hidden') {
        objBlink.style.visibility = '';
    }
    else {
        objBlink.style.visibility = 'hidden';
    }
}

var oldContent;

function blinkTxt(whichOne, speed) {
    oldContent = document.getElementById(whichOne).innerHTML;
    setInterval("doBlinkTxt('" + whichOne + "')", speed);
}

function doBlinkTxt(whichOne) {
    if (document.getElementById(whichOne).innerHTML == '&nbsp;') {
        document.getElementById(whichOne).innerHTML = oldContent;
    }
    else {
        document.getElementById(whichOne).innerHTML = '&#160;';
    }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function checkEmail(emailAddr) {
    var strudel = emailAddr.indexOf("@")
    var comma = emailAddr.indexOf(",")
    var space = emailAddr.indexOf(" ")
    var period = emailAddr.lastIndexOf(".") + 1
    var emailLen = emailAddr.length

    if ((strudel > 0)
   	     && (comma == -1)
   	     && (space == -1)
   	     && (emailLen - period >= 2)
   	     && (emailLen - period <= 4)
   	     && (emailLen != 0)) {
        return true;
    }
    else {
        return false;
    }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function replaceStr(string, text, by) {
    var stringLength = string.length
    var textLength = text.length;
    if ((stringLength == 0) || (textLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0, textLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0, i) + by;

    if ((i + textLength) < stringLength)
        newstr += replaceStr(string.substring(i + textLength, stringLength), text, by);

    return newstr;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function showArchive() {
    NewWinParamId('general/html/archive.html', 692, 500, 'archive', 'yes', 'yes');
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function hinuhit() {
    var use800 = 0;

    if (screen.height == 600) {
        if (screen.width == 800) {
            use800 = 1;
        }
    }
    if (screen.height == 480) {
        if (screen.width == 640) {
            use800 = 1;
        }
    }

    if (use800 == 1) {
        NewBrowserMax('http://www.iba.org.il/eduradio/hinuhit_800.htm');
    }
    else {
        NewBrowserMax('http://www.iba.org.il/eduradio/');
    }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

var currentColor;

function changeColor(whichOne, color1, color2, speed) {
    currentColor = color1;
    setInterval("doChangeColor('" + whichOne + "','" + color1 + "','" + color2 + "')", speed);
}

function doChangeColor(whichOne, color1, color2) {
    if (currentColor == color1) {
        document.getElementById(whichOne).style.color = color2;
        currentColor = color2;
    }
    else {
        document.getElementById(whichOne).style.color = color1;
        currentColor = color1;
    }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function startBannerTimer(strBannerName, btnOn, btnOff) {
    var bannerObj = document.getElementsByName(strBannerName);
    
    if (btnOn > "") {
        var bannerBtnObj = document.getElementsByName("Btn" + strBannerName);
    }
    
    if (bannerObj.length > 1) {
        bannerObj[0].style.display = '';
        if (btnOn > "") {
            bannerBtnObj[0].src = btnOn;
            bannerBtnObj[0].onclick = "";
            bannerBtnObj[0].onmouseover = "";
            bannerBtnObj[0].onmouseout = "";
        }
        setInterval("switchBanner('" + strBannerName + "','" + btnOn + "','" + btnOff + "')", 7000);
    }
    else {
        document.getElementById(strBannerName).style.display = '';
        if (btnOn > "") {
            document.getElementById("Btn" + strBannerName).src = btnOn;
            document.getElementById("Btn" + strBannerName).onclick = "";
            document.getElementById("Btn" + strBannerName).onmouseover = "";
            document.getElementById("Btn" + strBannerName).onmouseout = "";
        }
    }
}

function switchBanner(strWhichOne, btnOn, btnOff, specificIndx) {
    var bannerObj = document.getElementsByName(strWhichOne);

    if (btnOn > "") {
        var bannerBtnObj = document.getElementsByName("Btn" + strWhichOne);
    }

    var indx;
    for (indx = 0; indx < bannerObj.length; indx++) {
        if (bannerObj[indx].style.display == '') {
            break;
        }
    }

    var newOne;
    if (specificIndx != undefined) {
        newOne = specificIndx;
    }
    else {
        newOne = indx + 1;
        if (newOne >= bannerObj.length) {
            newOne = 0;
        }
    }
    
    // if this is not the first time the loop is running, then hide the last banner.
    // otherwise, everything will be display:none, and the indx will be more than the length
    if (indx < bannerObj.length) {
        bannerObj[indx].style.display = 'none';
        
        if (btnOn > "") {
            bannerBtnObj[indx].src = btnOff;
            bannerBtnObj[indx].onmouseover = function() { this.src = btnOn; };
            bannerBtnObj[indx].onmouseout = function() { this.src = btnOff; };
            bannerBtnObj[indx].onclick = function() { getLoopBanner(this); };
        }
    }
    bannerObj[newOne].style.display = '';
    if (btnOn > "") {
        bannerBtnObj[newOne].src = btnOn;
        bannerBtnObj[newOne].onmouseover = "";
        bannerBtnObj[newOne].onmouseout = "";
        bannerBtnObj[newOne].onclick = "";
    }

}

function getLoopBanner(objNewBanner) {
    var id = objNewBanner.id;
    var strBannerName = id.substring(3);
    var btnOn = eval("BtnOn" + strBannerName);
    var btnOff = eval("BtnOff" + strBannerName);

    var bannerBtnObj = document.getElementsByName(id);
    var indx;
    for (indx = 0; indx < bannerBtnObj.length; indx++) {
        if (bannerBtnObj[indx] == objNewBanner) {
            break;
        }
    }
    switchBanner(strBannerName, btnOn, btnOff, indx);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function checkForRtl(firstWord) {
    var boolRtl = false;
    var tempWord;

    tempWord = ConvertUnicodeStr(firstWord);

    for (i = 0; i < tempWord.length; i++) {
        if ((tempWord.charCodeAt(i) > 1487) && (tempWord.charCodeAt(i) < 1515)) {
            boolRtl = true;
            wordLang = "hebrew";
            break;
        }

        if ((tempWord.charCodeAt(i) > 1536) && (tempWord.charCodeAt(i) < 1791)) {
            boolRtl = true;
            wordLang = "arabic";
            break;
        }
    }
    return boolRtl;
}

function setDirection() {
    try { document.getElementById("innerMainTbl").dir = "rtl"; } catch (exception) { }

    try { document.getElementById("innerTdMainTtl").align = "left"; } catch (exception) { }
    try { document.getElementById("innerSpanMainTtl").align = "left"; } catch (exception) { }
    try { document.getElementById("innerTableMainTtl").align = "left"; } catch (exception) { }
    try { document.getElementById("innerMainTtl").dir = "ltr"; } catch (exception) { }
    try { document.getElementById("innerMainTtl").align = "left"; } catch (exception) { }
    try { document.getElementById("floatInnerMain").style.styleFloat = "left"; } catch (exception) { }
    try { document.getElementById("floatInnerMain").style.cssFloat = "left"; } catch (exception) { }
    try { document.getElementById("mainTtlMedia").align = "right"; } catch (exception) { }
    try { document.getElementById("mainTtlMedia").style.styleFloat = "left"; } catch (exception) { }
    try { document.getElementById("mainTtlMedia").style.cssFloat = "left"; } catch (exception) { }
    try { document.getElementById("mainTtlMedia").style.paddingLeft = "7px"; } catch (exception) { }
    try { document.getElementById("innerAuthorTtl").dir = "ltr"; } catch (exception) { }
    try { document.getElementById("innerAuthorTtl").align = "left"; } catch (exception) { }
    try { document.getElementById("innerAuthorTtl").style.paddingLeft = "10px"; } catch (exception) { }

    try { document.getElementById("innerSummary").dir = "ltr"; } catch (exception) { }
    try { document.getElementById("innerSummary").align = "left"; } catch (exception) { }
    try { document.getElementById("innerSummary").style.paddingLeft = "10px"; } catch (exception) { }

    try { document.getElementById("innerSecondaryTtl").dir = "ltr"; } catch (exception) { }
    try { document.getElementById("innerSecondaryTtl").align = "left"; } catch (exception) { }
    try { document.getElementById("innerSecondaryTtl").style.paddingLeft = "10px"; } catch (exception) { }

    try { document.getElementById("innerDetailsTtl").dir = "ltr"; } catch (exception) { }
    try { document.getElementById("innerDetailsTtl").align = "left"; } catch (exception) { }
    try { document.getElementById("innerDetailsTtl").style.paddingLeft = "10px"; } catch (exception) { }

    try { document.getElementById("innerLinkPnimiTtl").dir = "ltr"; } catch (exception) { }
    try { document.getElementById("innerLinkPnimiTtl").align = "left"; } catch (exception) { }
    try { document.getElementById("innerLinkPnimiTtl").style.paddingLeft = "10px"; } catch (exception) { }

    try {
        var linkObj = document.getElementsByName("innerLinkPnimi");
        for (linkIndx = 0; linkIndx < linkObj.length; linkIndx++) {
            linkObj[linkIndx].dir = "ltr";
            linkObj[linkIndx].align = "left";
            linkObj[linkIndx].style.paddingLeft = "10px";
        }
    }
    catch (exception) { }

    try { document.getElementById("innerLinkExtTtl").dir = "ltr"; } catch (exception) { }
    try { document.getElementById("innerLinkExtTtl").align = "left"; } catch (exception) { }
    try { document.getElementById("innerLinkExtTtl").style.paddingLeft = "10px"; } catch (exception) { }

    try {
        var linkObj = document.getElementsByName("innerLinkExt");
        for (linkIndx = 0; linkIndx < linkObj.length; linkIndx++) {
            linkObj[linkIndx].dir = "ltr";
            linkObj[linkIndx].align = "left";
            linkObj[linkIndx].style.paddingLeft = "10px";
        }
    }
    catch (exception) { }

    try { document.getElementById("innerDateTtl").dir = "ltr"; } catch (exception) { }
    try { document.getElementById("innerDateTtl").align = "left"; } catch (exception) { }
    try { document.getElementById("innerDateTtl").style.paddingLeft = "10px"; } catch (exception) { }

    try { document.getElementById("innerPrintTtl").align = "left"; } catch (exception) { }
    try { document.getElementById("innerPrintTtl").style.paddingLeft = "10px"; } catch (exception) { }

    try { document.getElementById("innerBackTtl").style.paddingLeft = "10px"; } catch (exception) { }
}

function setDirectionList(firstWord, whichEntity, pointImg) {
    if (checkForRtl(firstWord)) { return; }

    try { document.getElementById("tblList" + whichEntity).dir = "rtl"; } catch (exception) { }
    try { document.getElementById("tblList" + whichEntity).style.paddingLeft = "3px"; } catch (exception) { }

    try { document.getElementById("tdListText" + whichEntity).dir = "ltr"; } catch (exception) { }
    try { document.getElementById("tdListText" + whichEntity).align = "left"; } catch (exception) { }

    try { document.getElementById("tdListPic" + whichEntity).align = "left"; } catch (exception) { }

    try { document.getElementById("imgArrow" + whichEntity).src = pointImg; } catch (exception) { }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function setDirectionFirstBig(firstWord, whichEntity) {
    if (checkForRtl(firstWord)) { return; }

    try { document.getElementById("firstBigPicDesc").dir = "ltr"; } catch (exception) { }
    try { document.getElementById("firstBigPicDesc").align = "left"; } catch (exception) { }
    try { document.getElementById("firstBigPicDesc").style.paddingLeft = "5px"; } catch (exception) { }

    try { document.getElementById("tdFirstBigText").dir = "ltr"; } catch (exception) { }
    try { document.getElementById("tdFirstBigText").align = "left"; } catch (exception) { }
    try { document.getElementById("tdFirstBigText").style.paddingLeft = "3px"; } catch (exception) { }

    try { document.getElementById("spanFirstBigMain").align = "left"; } catch (exception) { }

    try { document.getElementById("mediaFirstBig").dir = "ltr"; } catch (exception) { }
    try { document.getElementById("mediaFirstBig").align = "left"; } catch (exception) { }

    try { document.getElementById("allAttachMedia" + whichEntity).align = "right"; } catch (exception) { }
}

function setDirectionLeftSmall(firstWord, whichEntity) {
    if (checkForRtl(firstWord)) { return; }

    try { document.getElementById("tblLeftSmall").dir = "rtl"; } catch (exception) { }

    try { document.getElementById("tdLeftSmallText").dir = "ltr"; } catch (exception) { }
    try { document.getElementById("tdLeftSmallText").align = "left"; } catch (exception) { }
    try { document.getElementById("tdLeftSmallText").style.paddingLeft = "4px"; } catch (exception) { }

    try { document.getElementById("spanLeftSmallMain").align = "left"; } catch (exception) { }

    try { document.getElementById("mediaLeftSmall").dir = "ltr"; } catch (exception) { }
    try { document.getElementById("mediaLeftSmall").align = "left"; } catch (exception) { }
    try { document.getElementById("mediaLeftSmall").style.paddingRight = "5px"; } catch (exception) { }

    try { document.getElementById("allAttachMedia" + whichEntity).align = "right"; } catch (exception) { }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function ConvertUnicodeStr(str) {
    var tempStr = '';
    var resultStr = str;
    var j = resultStr.indexOf('&#');

    if (j >= 0) {
        while (j >= 0) {
            tempStr = tempStr + resultStr.substring(0, j) + String.fromCharCode(resultStr.substring(j + 2, j + 6));
            resultStr = resultStr.substring(j + 7, resultStr.length);
            j = resultStr.indexOf('&#');
        }
        resultStr = tempStr;
    }

    return resultStr;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

var divIndx;

function startSwitchItems(numSeconds) {
    divIndx = 0;
    switchItem();
    setInterval("switchItem()", (1000 * numSeconds));
}

function switchItem() {
    var divObj = document.getElementsByName("divSwitchItem");
    divIndx++;
    if (divIndx == divObj.length) {
        divIndx = 0;
    }
    document.getElementById("tdSwitchItemContainer").innerHTML = divObj[divIndx].innerHTML;
}

function genStartSwitchItems(numSeconds, whichOne) {
    document.getElementById("indxSwitchItem" + whichOne).innerHTML = 0;
    genSwitchItem(whichOne);
    setInterval("genSwitchItem('" + whichOne + "')", (1000 * numSeconds));
}

function genSwitchItem(whichOne) {
    var divObj = document.getElementsByName("divSwitchItem" + whichOne);
    var tmpIndx = parseInt(document.getElementById("indxSwitchItem" + whichOne).innerHTML);
    tmpIndx++;
    if (tmpIndx == divObj.length) {
        tmpIndx = 0;
    }
    document.getElementById("tdSwitchItemContainer" + whichOne).innerHTML = divObj[tmpIndx].innerHTML;
    document.getElementById("indxSwitchItem" + whichOne).innerHTML = tmpIndx;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//THE NEXT LINES OF CODE ARE FOR AN EXPANDING WINDOW:

// INITIALIZATION:
animatedWindow = new Object();

// CONFIGURATION:

animatedWindow.startWidth = 100;
animatedWindow.startHeight = 100;

animatedWindow.endWidth = 640;
animatedWindow.endHeight = 480;

animatedWindow.bgColor = '#FFFFFF';

animatedWindow.increment = 50;

animatedWindow.frameRate = 50;

animatedWindow.location = false;
animatedWindow.menubar = false;
animatedWindow.resizable = false;
animatedWindow.scrollbars = false;
animatedWindow.status = false;
animatedWindow.toolbar = false;

// MAIN:

animatedWindow.winIndex = 0;
animatedWindow.windows = new Array();

/* ----- EXPLANATIONS OF THE OPENING FIELDS  --------------

EXAMPLE: openAnimatedWindow('myfile.html',200,200,640,480,'red')
	
openAnimatedWindow(URL,STARTWIDTH,STARTHEIGHT,ENDWIDTH,ENDHEIGHT,BGCOLOR,
INCREMENT,FRAMERATE,POSX,POSY,LOCATION,MENUBAR,RESIZABLE,SCROLLBARS,STATUS,TOOLBAR)

URL		    = An optional string that specifies the URL. 
A blank window will be displayed if this argument is left blank.
STARTWIDTH	= An optional number that specifies the starting width.
STARTHEIGHT	= An optional number that specifies the starting height.
ENDWIDTH	= An optional number that specifies the ending width.
ENDHEIGHT	= An optional number that specifies the ending height.
BGCOLOR	    = An optional string that specifies the initial background color of the
window before the window has finished resizing and the URL has loaded.
INCREMENT	= An optional number that specifies the growth distance per frame.
FRAMERATE 	= An optional number that specifies the number of frames per second.
POSX		= An optional number that specifies the X position.
POSY		= An optional number that specifies the Y position.
LOCATION	= An optional boolean that specifies the location feature.
MENUBAR	    = An optional boolean that specifies the menubar feature.
RESIZABLE	= An optional boolean that specifies the resizable feature.
SCROLLBARS	= An optional boolean that specifies the scrollbars feature.
STATUS      = An optional boolean that specifies the status feature.
TOOLBARS	= An optional boolean that specifies the toolbars feature.  
-------------------------- */

function isBlank(OBJ) {
    if (OBJ == null) OBJ = '';
    OBJ += '';
    var trimList = ' \f\n\r';
    while (OBJ.length > 0 && trimList.indexOf(OBJ.charAt(0)) != -1) OBJ = OBJ.substring(1);
    while (OBJ.length > 0 && trimList.indexOf(OBJ.charAt(OBJ.length - 1)) != -1) OBJ = OBJ.substring(0, OBJ.length - 1);
    return (OBJ == '') ? true : false;
}

function isBoolean(STR) {
    return (STR == true || STR == false) ? true : false;
}

function openAnimatedWindow(URL, STARTWIDTH, STARTHEIGHT, ENDWIDTH, ENDHEIGHT, BGCOLOR, INCREMENT, FRAMERATE, POSX, POSY, LOCATION, MENUBAR, RESIZABLE, SCROLLBARS, STATUS, TOOLBAR) {
    if (isBlank(STARTWIDTH)) STARTWIDTH = animatedWindow.startWidth;
    if (isBlank(STARTHEIGHT)) STARTHEIGHT = animatedWindow.startHeight;
    if (isBlank(ENDWIDTH)) ENDWIDTH = animatedWindow.endWidth;
    if (isBlank(ENDHEIGHT)) ENDHEIGHT = animatedWindow.endHeight;
    if (isBlank(BGCOLOR)) BGCOLOR = animatedWindow.bgColor;
    if (isBlank(INCREMENT)) INCREMENT = animatedWindow.increment;
    if (isBlank(FRAMERATE)) FRAMERATE = animatedWindow.frameRate;
    if (isBlank(POSX)) POSX = (screen.width) ? (screen.width - ENDWIDTH) / 2 : 100;
    if (isBlank(POSY)) POSY = (screen.height) ? (screen.height - ENDHEIGHT) / 2 : 100; ;
    if (isBlank(LOCATION)) LOCATION = animatedWindow.location;
    if (isBlank(MENUBAR)) MENUBAR = animatedWindow.menubar;
    if (isBlank(RESIZABLE)) RESIZABLE = animatedWindow.resizable;
    if (isBlank(SCROLLBARS)) SCROLLBARS = animatedWindow.scrollbars;
    if (isBlank(STATUS)) STATUS = animatedWindow.status;
    if (isBlank(TOOLBAR)) TOOLBAR = animatedWindow.toolbar;
    var winFeaturesStr = 'width=' + STARTWIDTH + ',height=' + STARTHEIGHT;
    winFeaturesStr += ',left=' + POSX + ',screenX=' + POSX + ',top=' + POSY + ',screenY=' + POSY;
    if (isBoolean(LOCATION)) winFeaturesStr += (LOCATION) ? ',location=yes' : ',location=no';
    if (isBoolean(MENUBAR)) winFeaturesStr += (MENUBAR) ? ',menubar=yes' : ',menubar=no';
    if (isBoolean(RESIZABLE)) winFeaturesStr += (RESIZABLE) ? ',resizable=yes' : ',resizable=no';
    if (isBoolean(SCROLLBARS)) winFeaturesStr += (SCROLLBARS) ? ',scrollbars=yes' : ',scrollbars=no';
    if (isBoolean(STATUS)) winFeaturesStr += (STATUS) ? ',status=yes' : ',status=no';
    if (isBoolean(TOOLBAR)) winFeaturesStr += (TOOLBAR) ? ',toolbar=yes' : ',toolbar=no';
    var thisWinIndex = animatedWindow.winIndex;
    animatedWindow.winIndex++;
    animatedWindow.windows[thisWinIndex] = new Object();
    animatedWindow.windows[thisWinIndex].winObj = window.open('', '', winFeaturesStr);
    animatedWindow.windows[thisWinIndex].winObj.document.bgColor = BGCOLOR;
    animatedWindow.windows[thisWinIndex].winObj.focus();
    animatedWindow.windows[thisWinIndex].frameRate = FRAMERATE;
    animatedWindow.windows[thisWinIndex].url = URL;
    animatedWindow.windows[thisWinIndex].endWidth = ENDWIDTH;
    animatedWindow.windows[thisWinIndex].endHeight = ENDHEIGHT;
    animatedWindow.windows[thisWinIndex].angle = Math.atan2(ENDHEIGHT - STARTHEIGHT, ENDWIDTH - STARTWIDTH);
    animatedWindow.windows[thisWinIndex].distZ = Math.sqrt(Math.pow(ENDHEIGHT - STARTHEIGHT, 2) + Math.pow(ENDWIDTH - STARTWIDTH, 2));
    animatedWindow.windows[thisWinIndex].incX = Math.cos(animatedWindow.windows[thisWinIndex].angle) * INCREMENT;
    animatedWindow.windows[thisWinIndex].incY = Math.sin(animatedWindow.windows[thisWinIndex].angle) * INCREMENT;
    animatedWindow.windows[thisWinIndex].incZ = INCREMENT;
    animatedWindow.windows[thisWinIndex].roundedX = STARTWIDTH;
    animatedWindow.windows[thisWinIndex].roundedY = STARTHEIGHT;
    animatedWindow.windows[thisWinIndex].currentX = STARTWIDTH;
    animatedWindow.windows[thisWinIndex].currentY = STARTHEIGHT;
    animatedWindow.windows[thisWinIndex].currentZ = 0;
    resizeAnimatedWindow(thisWinIndex);
}

function resizeAnimatedWindow(WININDEX) {
    var animateWinObj = animatedWindow.windows[WININDEX];
    if (animateWinObj.currentZ + animateWinObj.incZ < animateWinObj.distZ) {
        animateWinObj.currentX += animateWinObj.incX;
        animateWinObj.currentY += animateWinObj.incY;
        animateWinObj.currentZ += animateWinObj.incZ;
        var incX = Math.round(animateWinObj.currentX) - animateWinObj.roundedX;
        animateWinObj.roundedX += incX;
        var incY = Math.round(animateWinObj.currentY) - animateWinObj.roundedY;
        animateWinObj.roundedY += incY;
        animateWinObj.winObj.resizeBy(incX, incY);
        window.setTimeout('resizeAnimatedWindow(' + WININDEX + ')', animateWinObj.frameRate);
    }
    else {
        var incX = animateWinObj.endWidth - animateWinObj.roundedX;
        var incY = animateWinObj.endHeight - animateWinObj.roundedY;
        animateWinObj.winObj.resizeBy(incX, incY);
        if (!isBlank(animateWinObj.url)) animateWinObj.winObj.location.href = animateWinObj.url;
    }
}

//END OF THE CODE FOR AN EXPANDING WINDOW
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//Move Pics Start

function movePicPrev(whichEnt) {
    var totalPics = parseInt(document.getElementById("picCnt" + whichEnt).value);
    var currentIndx = parseInt(document.getElementById("picIndx" + whichEnt).value);

    if (currentIndx == 1) {
        return;
    }

    currentIndx--;

    getPicInfo(whichEnt, currentIndx);

    if (currentIndx == 1) {
        SetEnablePicBtn(whichEnt, "Prev", false);
    }
    if (currentIndx == (totalPics - 1)) {
        SetEnablePicBtn(whichEnt, "Next", true);
    }
    document.getElementById("picIndx" + whichEnt).value = currentIndx;
}

function movePicNext(whichEnt) {
    var totalPics = parseInt(document.getElementById("picCnt" + whichEnt).value);
    var currentIndx = parseInt(document.getElementById("picIndx" + whichEnt).value);

    if (currentIndx == totalPics) {
        return;
    }

    currentIndx++;

    getPicInfo(whichEnt, currentIndx);

    if (currentIndx == 2) {
        SetEnablePicBtn(whichEnt, "Prev", true);
    }
    if (currentIndx == totalPics) {
        SetEnablePicBtn(whichEnt, "Next", false);
    }
    document.getElementById("picIndx" + whichEnt).value = currentIndx;
}

function movePicRand(whichEnt) {

    var totalPics = parseInt(document.getElementById("picCnt" + whichEnt).value);
    var currentIndx = parseInt(document.getElementById("picIndx" + whichEnt).value);

    var newIndx = getRandomNumber(currentIndx, totalPics)
    //alert ("newIndx = " + newIndx)

    getPicInfo(whichEnt, newIndx);

    if (newIndx == 1) {
        SetEnablePicBtn(whichEnt, "Prev", false);
    }

    if (newIndx == (totalPics - 1)) {
        SetEnablePicBtn(whichEnt, "Next", true);
    }

    //do fade

    document.getElementById("picIndx" + whichEnt).value = newIndx;

    setTimeout("movePicRand(" + whichEnt + ")", 2000);
}

function getPicInfo(whichEnt, currentIndx) {
    var newPicInfo = eval("pic" + whichEnt + "Arr")[currentIndx - 1];

    // set the src for the picture.
    document.getElementById('IMG' + whichEnt).src = newPicInfo[0];

    // set the title for the picture.
    try {
        document.getElementById('RECT' + whichEnt).title = Convert_Unicode(newPicInfo[1]);
    }
    catch (exception) {
        document.getElementById('IMG' + whichEnt).title = Convert_Unicode(newPicInfo[1]);
    }

    // set the bottom description
    try {
        document.getElementById("picDesc" + whichEnt).innerHTML = newPicInfo[2];
    }
    catch (exception) { }
}

function SetEnablePicBtn(whichEnt, direction, boolEnable) {
    var btnObj = document.getElementById('btnPic' + direction + whichEnt);

    if (boolEnable) {
        //btnObj.onclick = function() { eval('movePic' + direction)(whichEnt); };

        if (ns6) {
            btnObj.style.MozOpacity = 1;
            btnObj.style.cursor = "pointer";
        }
        else {
            btnObj.style.filter = "";
            btnObj.style.cursor = "hand";
        }
    }
    else {
        //btnObj.onclick = "";
        btnObj.style.cursor = "";

        if (ns6) {
            btnObj.style.MozOpacity = .15;
        }
        else {
            btnObj.style.filter = "alpha(opacity:15)";
        }
    }
}

//Move Pics End
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


function onlyNumeric(objEvent) {
    var keyCd = ns6 ? objEvent.which : objEvent.keyCode;

    if ((keyCd < 48) || (keyCd > 57)) {
        return false;
    }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function loadjscssfile(filename, filetype) {
    if (filetype == "js") { //if filename is a external JavaScript file
        var fileref = document.createElement('script')
        fileref.setAttribute("type", "text/javascript")
        fileref.setAttribute("src", filename)
    }
    else if (filetype == "css") { //if filename is an external CSS file
        var fileref = document.createElement("link")
        fileref.setAttribute("rel", "stylesheet")
        fileref.setAttribute("type", "text/css")
        fileref.setAttribute("href", filename)
    }
    if (typeof fileref != "undefined")
        document.getElementsByTagName("head")[0].appendChild(fileref)
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//added for sound animation

var agt = navigator.userAgent.toLowerCase();
var is_ie = (agt.indexOf('msie') != -1);

if (is_ie) {
    var agt_ie = agt.substring(agt.indexOf('msie') + 5);
    var is_major = parseInt(agt_ie);
}

function stopSound(o) {
    if (is_major >= 4 && eval('document.' + o)) {
        var e = eval('document.' + o);
        if (e.src && e.src != '' && e.ReadyState && e.ReadyState >= 4) {
            e.stop();
        }
    }
}

function playSound(o) {
    if (is_major >= 4 && eval('document.' + o)) {
        var e = eval('document.' + o);
        if (e.src && e.src != '' && e.ReadyState && e.ReadyState >= 4) {
            if (is_major >= 5) {
                e.play();
            }
            else {
                e.run();
            }
        }
    }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion() {
    var version;
    var axo;
    var e;

    // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

    try {
        // version will be set for 7.X or greater players
        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
        version = axo.GetVariable("$version");
    } catch (e) {
    }

    if (!version) {
        try {
            // version will be set for 6.X players only
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");

            // installed player is some revision of 6.0
            // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
            // so we have to be careful. 

            // default to the first public version
            version = "WIN 6,0,21,0";

            // throws if AllowScripAccess does not exist (introduced in 6.0r47)		
            axo.AllowScriptAccess = "always";

            // safe to call for 6.0r47 or greater
            version = axo.GetVariable("$version");

        } catch (e) {
        }
    }

    if (!version) {
        try {
            // version will be set for 4.X or 5.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = axo.GetVariable("$version");
        } catch (e) {
        }
    }

    if (!version) {
        try {
            // version will be set for 3.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = "WIN 3,0,18,0";
        } catch (e) {
        }
    }

    if (!version) {
        try {
            // version will be set for 2.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            version = "WIN 2,0,0,11";
        } catch (e) {
            version = -1;
        }
    }

    return version;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer() {
    // NS/Opera version >= 3 check for Flash plugin in plugin array
    var flashVer = -1;

    if (navigator.plugins != null && navigator.plugins.length > 0) {
        if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
            var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
            var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
            var descArray = flashDescription.split(" ");
            var tempArrayMajor = descArray[2].split(".");
            var versionMajor = tempArrayMajor[0];
            var versionMinor = tempArrayMajor[1];
            var versionRevision = descArray[3];
            if (versionRevision == "") {
                versionRevision = descArray[4];
            }
            if (versionRevision[0] == "d") {
                versionRevision = versionRevision.substring(1);
            } else if (versionRevision[0] == "r") {
                versionRevision = versionRevision.substring(1);
                if (versionRevision.indexOf("d") > 0) {
                    versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
                }
            }
            var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
        }
    }
    // MSN/WebTV 2.6 supports Flash 4
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
    // WebTV 2.5 supports Flash 3
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
    // older WebTV supports Flash 2
    else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
    else if (isIE && isWin && !isOpera) {
        flashVer = ControlVersion();
    }
    return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {
    versionStr = GetSwfVer();
    if (versionStr == -1) {
        return false;
    } else if (versionStr != 0) {
        if (isIE && isWin && !isOpera) {
            // Given "WIN 2,0,0,11"
            tempArray = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
            tempString = tempArray[1]; 		// "2,0,0,11"
            versionArray = tempString.split(","); // ['2', '0', '0', '11']
        } else {
            versionArray = versionStr.split(".");
        }
        var versionMajor = versionArray[0];
        var versionMinor = versionArray[1];
        var versionRevision = versionArray[2];

        // is the major.revision >= requested major.revision AND the minor version >= requested minor
        if (versionMajor > parseFloat(reqMajorVer)) {
            return true;
        } else if (versionMajor == parseFloat(reqMajorVer)) {
            if (versionMinor > parseFloat(reqMinorVer))
                return true;
            else if (versionMinor == parseFloat(reqMinorVer)) {
                if (versionRevision >= parseFloat(reqRevision))
                    return true;
            }
        }
        return false;
    }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function AC_AddExtension(src, ext) {
    if (src.indexOf('?') != -1)
        return src.replace(/\?/, ext + '?');
    else
        return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) {
    var str = '';
    if (isIE && isWin && !isOpera) {
        str += '<object ';
        for (var i in objAttrs) {
            str += i + '="' + objAttrs[i] + '" ';
        }
        str += '>';
        for (var i in params) {
            str += '<param name="' + i + '" value="' + params[i] + '" /> ';
        }
        str += '</object>';
    }
    else {
        str += '<embed ';
        for (var i in embedAttrs) {
            str += i + '="' + embedAttrs[i] + '" ';
        }
        str += '> </embed>';
    }

    document.write(str);
}

function AC_FL_RunContent() {
    var ret =
    AC_GetArgs
    (arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
    AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent() {
    var ret =
    AC_GetArgs
    (arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
    AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType) {
    var ret = new Object();
    ret.embedAttrs = new Object();
    ret.params = new Object();
    ret.objAttrs = new Object();
    for (var i = 0; i < args.length; i = i + 2) {
        var currArg = args[i].toLowerCase();

        switch (currArg) {
            case "classid":
                break;
            case "pluginspage":
                ret.embedAttrs[args[i]] = args[i + 1];
                break;
            case "src":
            case "movie":
                args[i + 1] = AC_AddExtension(args[i + 1], ext);
                ret.embedAttrs["src"] = args[i + 1];
                ret.params[srcParamName] = args[i + 1];
                break;
            case "onafterupdate":
            case "onbeforeupdate":
            case "onblur":
            case "oncellchange":
            case "onclick":
            case "ondblclick":
            case "ondrag":
            case "ondragend":
            case "ondragenter":
            case "ondragleave":
            case "ondragover":
            case "ondrop":
            case "onfinish":
            case "onfocus":
            case "onhelp":
            case "onmousedown":
            case "onmouseup":
            case "onmouseover":
            case "onmousemove":
            case "onmouseout":
            case "onkeypress":
            case "onkeydown":
            case "onkeyup":
            case "onload":
            case "onlosecapture":
            case "onpropertychange":
            case "onreadystatechange":
            case "onrowsdelete":
            case "onrowenter":
            case "onrowexit":
            case "onrowsinserted":
            case "onstart":
            case "onscroll":
            case "onbeforeeditfocus":
            case "onactivate":
            case "onbeforedeactivate":
            case "ondeactivate":
            case "type":
            case "codebase":
            case "id":
                ret.objAttrs[args[i]] = args[i + 1];
                break;
            case "width":
            case "height":
            case "align":
            case "vspace":
            case "hspace":
            case "class":
            case "title":
            case "accesskey":
            case "name":
            case "tabindex":
                ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i + 1];
                break;
            default:
                ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i + 1];
        }
    }
    ret.objAttrs["classid"] = classid;
    if (mimeType) ret.embedAttrs["type"] = mimeType;
    return ret;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function NewWindowId(mypage, w, h, resize, scroll) {
    //mypage - URL (-Link)
    //w - width
    //h - height
    //resize - yes/no
    //scroll - yes/no

    if (WindowIsOpen) {
        WindowIsOpen.close();
    }
    LeftPosition = (screen.width) ? (screen.width - w) / 2 : 100; TopPosition = (screen.height) ? (screen.height - h) / 2 : 100;
    settings = 'width=' + w + ',height=' + h + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=' + resize;
    WindowIsOpen = open(mypage, 'WindowPopUp', settings);
    if (WindowIsOpen.focus) { WindowIsOpen.focus(); }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function switchPage(pageNum, itemsPerPage) {
    // Switch pages (when paging is activated)

    // pageNum==0 : view All

    var minIndex = (pageNum - 1) * itemsPerPage;
    var maxIndex = (pageNum) * itemsPerPage;

    var itemsArray = document.getElementsByName("itemIndex");
    var totItems = itemsArray.length;
    var spacesArray = document.getElementsByName("spaceIndex");
    
    if (pageNum == 0) {
        minIndex = 0; maxIndex = totItems;
    }

    var i;

    // Change Display-state of items
    for (i = 0; i < totItems; i++) {

        if ((i >= minIndex) && (i < maxIndex)) {
            itemsArray[i].style.display = "";
            // Change Display-state of space lines (if exists)
            try {
                spacesArray[i].style.display = "";
            }
            catch (exception) { }
        }
        else {
            itemsArray[i].style.display = "none";
            // Change Display-state of space lines (if exists)
            try {
                spacesArray[i].style.display = "none";
            }
            catch (exception) { }
        }
    }

    // Change class of page-numbers
    var pageNumbersArray = document.getElementsByName("pageNumber");  // className

    if (pageNum != 0) {

        L = pageNumbersArray.length;

        for (i = 0; i < L; i++) {

            if (i == pageNum - 1) {
                pageNumbersArray[i].className = "pageNumberActive";
            }
            else {
                pageNumbersArray[i].className = "pageNumberNonActive";
            }

        }
    }
    top.scrollTo(0, 0);
}


function changeFreq(freq) {

    // Change the Freq menu
    var fm = document.getElementById("fm");
    var am = document.getElementById("am");

    switch (freq) {
        case "fm":
            fm.className = "FmOn";
            am.className = "AmOff";
            break;
        case "am":
            am.className = "AmOn";
            fm.className = "FmOff";
            break;
    }

    var fmItems = document.getElementsByName("freqLineFm");
    var amItems = document.getElementsByName("freqLineAm");

    var i;

    // Change the visibilty of items
    switch (freq) {
        case "fm":
            for (i = 0; i < fmItems.length; i++) {

                fmItems[i].style.display = "";
            }
            for (i = 0; i < amItems.length; i++) {
                amItems[i].style.display = "none";
            }
            break;
        case "am":
            for (i = 0; i < fmItems.length; i++) {
                fmItems[i].style.display = "none";
            }
            for (i = 0; i < amItems.length; i++) {
                amItems[i].style.display = "";
            }
            break;
    }
    try {
        setMasterHeight();
    }
    catch (exception)
    { }
}

function chooseLetter(classNm, whichLetter) {
    // release the old letter
    document.getElementById("lnk" + currentLetter).className = classNm + "InnerLetter";
    document.getElementById("lnk" + currentLetter).onclick = function() { chooseLetter(classNm, this.id.substring(3)); };

    // choose the new letter
    if (whichLetter != "") {
        document.getElementById("lnk" + whichLetter).className = classNm + "InnerLetterInPg";
        document.getElementById("lnk" + whichLetter).onclick = "";

        // if this boolean exists then this page has it's own letter table action
        // for example contacts staff
        var bUseSiteSpecific = false;
        try {
            bUseSiteSpecific = new Boolean(bUseSiteLetterTableAction);
        }
        catch (exception) { }
        if (bUseSiteSpecific) {
            siteLetterTableAction(whichLetter);
        }
        else {
            letterTableAction(whichLetter);
        }
    }
    currentLetter = whichLetter;
    try {
        setMasterHeight();
    }
    catch (exception)
    { }
}

function letterTableAction(whichLetter) {
    var letterObj = document.getElementsByName("divAlphabetContent");
    var indxLetter;
    for (indxLetter = 0; indxLetter < letterObj.length; indxLetter++) {
        if (document.getElementsByName("spanContentLetter")[indxLetter].innerHTML == whichLetter
            || whichLetter == 'All') {
            // set the display style for this letter
            letterObj[indxLetter].style.display = "";
        }
        else {
            letterObj[indxLetter].style.display = "none";
        }
    }
}
