/* 
     File:        icSystemUtils.js
     Created:     2003-04-16
     Modified:    2003-08-13
     Copyright:   Copyright (c) InfoCaption AB 2003
     Author:      Peter Jäderlund
     Description: InfoCaption System Utilities
*/

var mainPath = location.href;


// --------------------------------------------------------------------------------------------------------------
// Initialize folder URL's etc
function icInitializeMainPath() {
	var iPos = mainPath.lastIndexOf("?");

    // Remove parameters
    if (iPos != -1) {
        mainPath = mainPath.substring(0, iPos);
    }

    // Remove document name (lead in URL only remaining part)
    iPos = mainPath.lastIndexOf("/");
    mainPath = mainPath.substring(0, iPos + 1);
}


// --------------------------------------------------------------------------------------------------------------
// General pixel converter (return the integer, remove "px" if it exists in the string)
// (Normal strToInt cannot be used)
function getIntPixel(sRes) {
    // Remove px  
    try {
        var i = sRes.indexOf('px', 0);
        if (i > 0) { sRes = sRes.substring(0, i); }
        return sRes * 1; // "StrToInt" Convert to integer!!!
    } catch (e) {
       return sRes;
    }
}


// --------------------------------------------------------------------------------------------------------------
// Routine to add a url to favorites
function addToFavorites(bookmarkUrl, bookmarkTitle){
    if (document.all) {
        if (bookmarkTitle == '') {
            window.external.AddFavorite(bookmarkUrl);
        } else {
            /*alert(bookmarkUrl);
            alert(bookmarkTitle);*/
            window.external.AddFavorite(bookmarkUrl, bookmarkTitle);
        }
    } else {
        alert('Error: document.all not supported!');
    }
}


