﻿

/* LOCAL
var pathRoot = 'http://localhost:4373';
*/
/* SERVER */
var pathRoot = 'http://www.autorentalnews.com';

var axel = Math.random() + "";
var ord = axel * 1000000000000000000;

function PopUpWindow(page, window_name, window_width, window_height, window_features) {
    window_features = window_features + ", width=" + window_width + ", height=" + window_height;
    //document.CtrlWindow.close;
    OpenWin = window.open(page, window_name, window_features);
}

function PrintPopUp(page) {
    PopUpWindow(page, 'Print', 700, 600, 'toolbar=yes,menubar=yes,location=no,scrollbars=yes,resizable=yes');
}

function OpenPageFromPopUp(URL) {
    if (window.opener && !window.opener.closed) {
        window.opener.location = URL;
        window.close();
    }
    else {
        window.open(URL);
        window.close();
    }
    window.open(URL);
}

function BookmarkPage(pageName, url) {
    if (window.sidebar) { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(pageName, url, '');
    } else if (window.external) { // IE Favorite
        window.external.AddFavorite(url, pageName);
    }
    else if (window.opera && window.print) { // Opera Hotlist
        return true;
    }
    else {
        alert("Sorry! Your browser doesn't support this function.");
    }
}

var CountChars = function(fieldMaxLen, fieldObj, counterObj) {
    var text = fieldObj.val();
    var textlength = text.length;
    var leftCount = fieldMaxLen - textlength;
    if (leftCount < 0) {
        counterObj.removeClass("blue");
        counterObj.addClass("red");
        counterObj.text(Math.abs(leftCount) + " characters over the limit");
        counterObj.show().fadeOut("fast", function() { counterObj.fadeIn("fast") });
        return false;
    }
    else {
        counterObj.removeClass("red");
        counterObj.addClass("blue");
        counterObj.text(leftCount + " characters left");
        counterObj.show();
        return true;
    }
}