/* load css for thickbox */
var cssPath = "/zone/js/thickbox/thickbox.css";
var cssElement;
a = document.createElement('link');
a.setAttribute('rel', 'stylesheet');
a.setAttribute('href', cssPath);
a.setAttribute('type', 'text/css');
document.getElementsByTagName('head')[0].appendChild(a);


///* load js for addthis */
//var jsElement = document.createElement('script');
//jsElement.setAttribute('language', 'javascript');
//jsElement.setAttribute('src', 'http://s7.addthis.com/js/250/addthis_widget.js?pub=xa-4a6ef7c649840ff5');
//jsElement.setAttribute('type', 'text/javascript');
//document.getElementsByTagName('head')[0].appendChild(jsElement);


function openGamezone(shortcut, input, domain){
    // input should be the domain country used e.g. 'at', 'de' ...
    
    var pwlink = "http://www.premiumpromotions.at/IndexServlet?quelle=";
    
    if (domain != null && domain != undefined) {
        pwlink = "http://" + domain + "/IndexServlet?quelle=";
    }
    
    // hardencoded solution for salzburg.com needed for ÖWA
    //if(shortcut=='sana' && domain == undefined && domain == null) {
    //	pwlink="http://premiumpromotions.salzburg.com/IndexServlet?quelle=";
    //} else	    
    //------ needed for compatibility with older versions of this script ------
    if (input == 2) 
        pwlink = "http://www.premiumpromotions.ch/IndexServlet?quelle=";
    else 
        if (input == 3) 
            pwlink = "http://www.premiumpromotions.de/IndexServlet?quelle=";
        else 
            if (input == 4) 
                pwlink = "http://www.premiumpromotions.cz/IndexServlet?quelle=";
            else 
                if (input == 5) 
                    pwlink = "http://www.premiumpromotions.nl/IndexServlet?quelle=";
                else 
                    if (input == 6) 
                        pwlink = "http://www.premiumpromotions.com/IndexServlet?quelle=";
                    //-------------------------------------------------------------------------				        	      
                    else 
                        if (input != null && String(input).match(/[a-z]{2,3}/) == String(input)) 
                            pwlink = "http://www.premiumpromotions." + input + "/IndexServlet?quelle=";
    
    if (shortcut == 'powe') {
        //alert("input=" + input + ", pwlink=" + pwlink); 
        //alert("String(input).match(/[a-z]{2,3}/)=" + String(input).match(/[a-z]{2,3}/));
    }
    
    if ((shortcut != null) && (shortcut != 'undefined')) 
        pwlink += shortcut;
    
    //alert(pwlink);	    	    
    
    var tmp01 = unescape(document.location.href); //unescape necessary for netscape
    if ((tmp01 != null) && (tmp01 != 'undefined') && (tmp01 != '')) {
        if (tmp01.indexOf('?') != -1) {
            tmp01 = tmp01.split('?');
            if (tmp01[1] != '') 
                pwlink += "&" + tmp01[1];
        }
    }
    
    var t = new Date().getTime();
    pwlink += "&ts=" + t;

    //alert(pwlink);	    	    
    
    if ((parent.powerwinning != null) && (parent.powerwinning != 'undefined')) {
        //alert('parent.powerwinning.location.href=pwlink');
        parent.powerwinning.location.href = pwlink;
    }
    else {
        //alert('self.premiumpromotions=' + self.premiumpromotions);
        if ((parent.premiumpromotions != null) && (parent.premiumpromotions != 'undefined')) {
            parent.premiumpromotions.location.href = pwlink;
            //alert('parent.premiumpromotions.location.href=pwlink');
        }
    }
}

function ppzCreateZoneLink(quelle, url){

    var uri = ppzParseUri(url);
    var t = new Date().getTime();
    var pplink = uri.protocol + "://" + uri.authority + "/IndexServlet?quelle=" + quelle + "&ts=" + t;
    for (key in uri.queryKey) {
        pplink += "&" + key + "=" + uri.queryKey[key];
    }
    
    return pplink;
}

function ppzCreateGameZoneLink(quelle, url){

    var uri = ppzParseUri(url);
    var t = new Date().getTime();
    var pplink = uri.protocol + "://" + uri.authority + "/IndexServlet?quelle=" + quelle + "&landing=fun&ts=" + t;
    for (key in uri.queryKey) {
        pplink += "&" + key + "=" + uri.queryKey[key];
    }
    
    return pplink;
}

function ppzStartPromInParent(promId, params){
    winW = 0;
    winH = 0;
    
    if (parseInt(navigator.appVersion) > 3) {
        if (navigator.appName == "Netscape") {
            winW = window.innerWidth;
            winH = window.innerHeight;
        }
        else 
            if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
                winW = document.documentElement.clientWidth;
                winH = document.documentElement.clientHeight;
            }
            else 
                if (document.body) { // other Explorers
                    winW = document.body.clientWidth;
                    winH = document.body.clientHeight;
                }
    }
    params['windowWidth'] = winW;
    params['windowHeight'] = winH;
    params['parentCall'] = true;
    params['partnerDomain'] = document.domain;
    
    return window.frames["premiumpromotions"].ppzStartProm(promId, params);
}

function ppzGetDomain(){
    return document.domain;
}

function ppzParseUri(str){
    var o = ppzParseUri.options, m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), uri = {}, i = 14;
    
    while (i--) 
        uri[o.key[i]] = m[i] || "";
    
    uri[o.q.name] = {};
    uri[o.key[12]].replace(o.q.parser, function($0, $1, $2){
        if ($1) 
            uri[o.q.name][$1] = $2;
    });
    
    return uri;
};

ppzParseUri.options = {
    strictMode: false,
    key: ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"],
    q: {
        name: "queryKey",
        parser: /(?:^|&)([^&=]*)=?([^&]*)/g
    },
    parser: {
        strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
        loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
    }
};

//function ppzAddthis_open(obj, desc, url, title){
//    return addthis_open(document, desc, url, title);
//}
//
//function ppzAddthis_close(){
//    return addthis_close();
//}
//
//function ppzAddthis_sendto(){
//    return addthis_sendto();
//}


