﻿/*
* Animation script 
* 
* written by Alon Ashkenazi
* 
*/
function addCssClass(id, className) {
    document.getElementById(id).className += className;
}

function removeCssClass(id, className) {
    document.getElementById(id).className =
        document.getElementById(id).className.replace(className, '');
}

// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
function getInternetExplorerVersion()
{
    var rv = -1; // Return value assumes failure.
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) != null)
            rv = parseFloat(RegExp.$1);
    }
    return rv;
}

function checkBrowserVersion() {
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var ver = getInternetExplorerVersion();

        if (ver < 7) {
            alert("ממומלץ להשתמש בדפדפן מגרסא 7 ומעלה");
        }
    }
}

function pageLoaded(id) {
    checkBrowserVersion();
    document.getElementById(id).style.visibility = 'hidden';
    pageName = getPageName();
    var elementId = pageName + "Url";
    addCssClass(elementId, 'CurrentPage');
}

function getPageName() {
    var pageName = window.location.pathname;
    var pageName = pageName.substring(pageName.lastIndexOf('/') + 1);
    pageName = pageName.substring(0, pageName.lastIndexOf('.'));
    return pageName;
}

function pageUnloaded(id) {
    document.getElementById(id).style.visibility = 'visible';
}

function changeImageSource(id, imageUrl) {
    document.getElementById(id).src = imageUrl;
}

function changeHyperlinkSource(id, hrefUrl) {
    document.getElementById(id).href = hrefUrl;
}

function changeHyperlinkTitle(id, title) {
    document.getElementById(id).title = title;
}

function shareGoogle() {
    sharePath = encodeURIComponent(document.URL);
    tmpPath = "http://www.google.com/bookmarks/mark?op=edit&bkmk=" + sharePath + "&title=" + document.title;
    window.open(tmpPath);
}

function shareFaceBook() {
    sharePath = document.URL;
    newPath = encodeURIComponent(sharePath.replace("#", "%23"));
    tmpPath = "http://www.facebook.com/sharer.php?u=" + newPath;
    window.open(tmpPath);
    //alert(encodeURI(tmpPath));
}


