﻿
/* GENERAL */

function ToggleDisplay(DivID){
    var div = document.getElementById(DivID);  
    if(div.style.display == "none"){
        div.style.display = "block";
    }else{
        div.style.display = "none";
    }
}


function PopUpLink(Url, Title, Width, Height){
	window.open(Url, Title, 'menubar=0,resizeable=1,scrollbars=1,width=' + Width + ',height=' + Height);
}


function Trim(Value) {
	return Value.replace(/^\s+|\s+$/g,"");
}

function FormatCurrency(value, prefix, suffix) {
    value = value.toString();

    if (value.indexOf('.') > 0) {
        if (value.indexOf('.') != (value.length - 3)) {
            //add trailing 0 e.g. from 12.5 to 12.50
            value = value + "0";
        }
    } else {
        value = value + ".00";
    }

    //trim long numbers e.g. 12.25000000001 (Math.round does not work as it will change this to 12.26)
    value = value.substring(0, value.indexOf('.')+3);

    return prefix + value + suffix;
}

/* This function is req'd for all pages that use
the NonCMS master page */
function OnResponseEnd(sender, args){
    OnNextClick();
}

function GetParameterByName(strName){
    var params = document.URL.split('?')[1].split('&');
    
    for(var i=0; i<params.length; i++){
        if (params[i].split('=')[0] == strName){
            params = params[i].split('=')[1];
            break;
        }
    }
    
    return params;
}


function OpenHtmlValidationLink(){
    window.open(GetHtmlValidationLink(), 'WebcodaW3C_XHTML');
    return false;
}
function GetHtmlValidationLink(){
    return "http://validator.w3.org/check?uri=" + window.location + "%2F&charset=(detect+automatically)&doctype=Inline&group=0&user-agent=W3C_Validator%2F1.606";
}

function OpenCssValidationLink(){
    window.open("http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fwww.webcoda.com.au%2F&profile=css21&usermedium=all", 'WebcodaW3C_CSS');
    return false;
}

function Login(link){
    window.location = "/login/admin.aspx?ReturnUrl=" + window.location + "&cmd=quickedit";
    return false;
}
