window.onload = vipeLoad;

function vipeLoad() {
    vipe_landingPageURL = "http://www.vipepower.com/Company/";
    vipe_qsp = new QSP();
    vipe_vk = vipe_qsp.param('v');
    vipe_height = vipe_qsp.param('vipe_height', '680'); 
    vipe_autoplay = vipe_qsp.param('vipe_autoplay', '1');
    var d = new Date();

    vipe_iframe_code = "<iframe id=vipeIframe style='margin-left:-10px;border:none;height:" +
        vipe_height + "px;' frameborder='0' border='0' width='610' src='" + 
        vipe_landingPageURL + 
        vipe_vk + 
        "?cu=1&time=" + d.getMilliseconds() +
        "&autoplay=" + 
        vipe_autoplay + 
        "'></iframe>";

    try {
        document.getElementById('right_side_content').innerHTML = vipe_iframe_code;
    } catch(e) {
        alert("Failed to Load Vipe Iframe: " + e);
    }
}

function QSP() { 
    this.params = {};
    
    var qs = location.search.substring(1, location.search.length);
    if (qs.length == 0) return;

    qs = qs.replace(/\+/g, ' ');
    var args = qs.split('&'); 
    
    for (var i = 0; i < args.length; i++) {
        var pair = args[i].split('=');
        var name = decodeURIComponent(pair[0]);
        var value = (pair.length==2)
            ? decodeURIComponent(pair[1])
            : name;
        
        this.params[name] = value;
    }
}

QSP.prototype.param = function(key, default_) {
    var value = this.params[key];
    return (value != null) ? value : default_;
}


