/* 
This script is ownership of wetter.com AG and is protected by public laws.
It is permitted to use, copy or change this script.
 */


var lnk = {
    base: "",
    fileTypes: ["htm", "html", "php"],
    fileType: "",
    gInstance: null,
    init: function(googleInstance){
        this.gInstance = googleInstance;
    },
    to: function(pathParts, basePath, tracking){
        if(basePath != null){
            if(basePath.lastIndexOf("/") != basePath.length-1){ basePath += "/"; }
            if(basePath.indexOf("http://") < 0){ basePath = "http://" + basePath }
            this.base = basePath;
        }else{
            this.base = "http://" + window.location.host + "/";
        }
        var path = this.base;
        for(var ia = 0; ia < this.fileTypes.length; ia++){
            if (pathParts[pathParts.length-1] == this.fileTypes[ia]){ this.fileType = "." + pathParts[pathParts.length-1]; }
        }
        for (var i = 0; i < pathParts.length; i++){
            if(this.fileType != "" && i == pathParts.length-2){ path += pathParts[i] + this.fileType; break; }else{ path += pathParts[i] + "/"; }
        }
        //alert(encodeURI(path));
        if(tracking != null){
            tracking.unshift('_trackEvent');
            this.gInstance.push(tracking);
        }
        location.href=encodeURI(path);
    }
}
