﻿
function setStyle(obj, style, value) {
    getRef(obj).style[style] = value;
}

function getRef(obj) {
    return (typeof obj == "string") ?
			 document.getElementById(obj) : obj;
}

function getStyle(el, style) {
    if (!document.getElementById) return;

    var value = el.style[toCamelCase(style)];

    if (!value)
        if (document.defaultView)
        value = document.defaultView.
                 getComputedStyle(el, "").getPropertyValue(style);

    else if (el.currentStyle)
        value = el.currentStyle[toCamelCase(style)];

    return value;
}

/** toCamelCase(input)
* Converts string input to a camel cased version of itself.
* For example:
* toCamelCase("z-index"); // returns zIndex
* toCamelCase("border-bottom-style"); // returns borderBottomStyle.
*/
function toCamelCase(s) {
    for (var exp = toCamelCase.exp;
		exp.test(s); s = s.replace(exp, RegExp.$1.toUpperCase()));
    return s;
}
toCamelCase.exp = /-([a-z])/;


function GetIEversion() {
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { //test for MSIE x.x;
        var ieversion = new Number(RegExp.$1) // capture x.x portion and store as a number
        var IEversion
        if (ieversion >= 8)
            IEversion = "IE8"
        else if (ieversion >= 7)
            IEversion = "IE7"
        else if (ieversion >= 6)
            IEversion = "IE6"
        else if (ieversion >= 5)
            IEversion = "IE5"
    }
    else
        IEversion = "NA"
    return IEversion
}

    //window.onload = setStyle("logo", "backgroundColor", "blue");
    //window.onload = setStyle("locatortop", "marginTop", "-150%");
function setdynamicstyle() {
    var y = screen.height;
    var x = screen.width;
    var basevalue, margin, factor;

    var browser = (navigator.appName.indexOf("Microsoft") != -1) ? "IE" : "Non IE"

    //alert(x + " / " + y + " / " + x / y + " --> " + factor);
    switch (browser) {
        case "IE":
            basevalue = -163; //based on x = 1280
            break;
        case "Non IE":
            basevalue = -162; //based on x = 1280
            break;
    }
    factor = 1280 / x;
    if (GetIEversion == "IE8")
        { factor = factor * 1.245399; }
    margin = basevalue * factor;
    margin = margin + "%"
    setStyle("locatortop", "marginTop", margin);
    //alert(margin);
    if (factor == -1 && y <= 768) {
        setStyle("wrapleft", "paddingLeft", "1%");
        setStyle("floating", "marginRight", "1%");
    }
}
