﻿// WARNING: REAL ENVIRONMENT VERSION, DO NOT UPLOAD IT TO OTHER ENVIRONMENTS
// This file is different in each environment.
// The versions for the other environments are located in the parent folder and ext, pre and pro sibling folders.
// Changes made to this file should be replicated to the other versions.

///////////////////////
// API CONFIGURATION //
///////////////////////

//This should contain all the configuration values needed by the zedapi
//Many of these values are environment-specific
function zedapiconfig() {
}

zedapiconfig.prototype = {
    environment : 'real',
    domain : 'zed.com',
    proxyurl : 'AJAXProxy.ashx?url=',
    imagespath : 'http://api.zed.com/images/',
    cookies : {
        domain  : 'zed.com',
        backurl : 'backurl',
        ssopersistent : 'zeduser',
        ssosession    : 'zeduserSession',
        ssocookieurl  : 'http://api.zed.com/ops/ssocookie.aspx'
    },
    account : {
        bridgeurl    : 'http://api.zed.com/ops/accbridge.aspx',
        loginurl     :  function(icodservice) { 
        return 'http://account.zed.com/aspx/reg_lu_01.aspx?WT.svl=' + _zedapicfg.webtrends.getwtprefix(icodservice) + '_header_login' 
        } ,
        registerurl  : function(icodservice) { 
        return 'http://account.zed.com/aspx/reg_ust_01.aspx?WT.svl=' + _zedapicfg.webtrends.getwtprefix(icodservice) + '_header_signup' 
        } ,
        myAccounturl : 'http://account.zed.com/aspx/ma_st.aspx'
    },
    events : {
        homeurl : 'http://board.zed.com', 
        getmaindataurl : function(iFrom,iTo,iOffSet,iIdService,Country) {
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=1&iTipo=1&iDesde='+iFrom+'&iHasta='+iTo+'&iNewAnt='+iOffSet+'&iIdService='+iIdService+'&Country='+Country);
        },
        seeactivity : function(bactivity) {
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=1&iTipo=3&iSeeActv='+bactivity);
        }
    },
    favorites : {    
        homeurl : 'http://favorites.zed.com', 
        getzedfavorites : function(idService) {
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=2&iTipo=3&idService='+idService);
        },
        getuserfavorites : function(idFolder,iIdService) {
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=2&iTipo=2&ifolder='+idFolder+'&iIdService='+iIdService);
        }
    },
    waplink : {    
        sendwaplink : function(sPhone,sCountry,iCodServicio,iCodPlatform) {
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=4&iTipo=1&sPhone='+sPhone+'&sCountry='+sCountry+'&iCodServicio='+iCodServicio+'&iCodPlatform='+iCodPlatform);
        },
        sendpassweb : function(sPhone,sCountry,iCodServicio) {
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=4&iTipo=2&sPhone='+sPhone+'&sCountry='+sCountry+'&iCodServicio='+iCodServicio);
        },
        asociateuserwaplink : function(sPhone,sCountry,iCodServicio,iCodPlatform,sPassWeb,sNick) {
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=4&iTipo=3&sPhone='+sPhone+'&sCountry='+sCountry+'&iCodServicio='+iCodServicio+'&iCodPlatform='+iCodPlatform+'&sPassWeb='+sPassWeb+'&sNick='+sNick);
        }
    },
    
    tellafriend : {
        gethtmltellafriend : function(idPlantilla,sparamsplantilla,slayer,iIdService) {
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=3&iTipo=1&iPlantilla='+idPlantilla+'&sParamsPlantilla='+sparamsplantilla+'&sLayer='+slayer+'&iIdService='+iIdService);
        },
        getcontactaddress : function() {
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=3&iTipo=2');
        },
        getcontacts : function(sUser,sPass) {
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=3&iTipo=3&sUser='+sUser+'&sPass='+sPass);
        },
        enviaremail : function(iIdPlantilla, aParams, sContacts, sFrom, sSubject, sLanguage) {
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=3&iTipo=4&iIdPlantilla='+iIdPlantilla+'&aParams='+aParams+'&sContacts='+sContacts+'&sFrom='+sFrom+'&sSubject='+sSubject+'&sLanguage='+sLanguage);
        }    
    },    

    inbox : {         
        homeurl : 'http://inbox.zed.com/index.aspx', 
        flist : function(sType,iPage,iIdService) {
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=6&iTipo=1&sType='+sType+'&iPage='+iPage+'&iIdService='+iIdService);
        },
        fview : function(sType,idItem,idProvider,sNameProvider,iIdService) {      
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=6&iTipo=2&sType='+sType+'&idItem='+idItem+'&idProvider='+idProvider+'&sNameProvider='+sNameProvider+'&iIdService='+iIdService); 
        },
        freply : function(sType,idItem,idProvider,sNameProvider,iIdService) {        
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=6&iTipo=3&sType='+sType+'&idItem='+idItem+'&idProvider='+idProvider+'&sNameProvider='+sNameProvider+'&iIdService='+iIdService); 
        },       
        freplymsg : function(iIdMessage,sBody,iIdService) {
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=6&iTipo=14&iIdMessage='+iIdMessage+'&sBody='+sBody+'&iIdService='+iIdService);
        },
        fdelmsg : function(iIdMessage,iIdService) {
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=6&iTipo=15&iIdMessage='+iIdMessage+'&iIdService='+iIdService);
        },
        fsend : function(iServicio,sDe,sPara,sFecha,bRespondible,sAsunto,sCuerpo) {        
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=6&iTipo=4&iServicio='+iServicio+'&sDe='+sDe+'&sPara='+sPara+'&dFecha='+sFecha+'&bRespondible='+bRespondible+'&sAsunto='+sAsunto+'&sCuerpo='+sCuerpo);
        },
        falert : function(idlayer,sType,idItem,idProvider,sNameProvider,iIdService) {        
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=6&iTipo=5&sType='+sType+'&idItem='+idItem+'&idlayer='+idlayer+'&idProvider='+idProvider+'&sNameProvider='+sNameProvider+'&iIdService='+iIdService);    
        },
        fdelet : function(iMessageId) {        
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=6&iTipo=6&iMessageId='+iMessageId);  
        }, 
        finfo : function(bOk,sType,iIdService) {        
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=6&iTipo=7&bOk='+bOk+'&sType='+sType+'&iIdService='+iIdService);  
        },
        fsendmail : function(iIdMail,iIdProvider,sNameProvider,sCuerpo) {        
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=6&iTipo=8&iIdMail='+iIdMail+'&iIdProvider='+iIdProvider+'&sNameProvider='+sNameProvider+'&sCuerpo='+sCuerpo);  
        },
        fdeletemail : function(iIdMail,iProvider,sNameProvider) {        
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=6&iTipo=9&iIdMail='+iIdMail+'&iProvider='+iProvider+'&sNameProvider='+sNameProvider); 
        },
        fmain : function(iIdService,sNick,sCodLanguage) {
        return  _zedapicfg.proxyurl + encodeURIComponent('http://api.zed.com/ops/cfbridge.aspx?intOper=6&iTipo=10&iIdService='+iIdService+'&Country='+sCountry);
        }
    },

    webtrends : {
        getwtprefix : function (icodservice) {
            var result = 'undefined'
            switch (icodservice) {
              case 500: result = 'ac'; break; 
              case 501: result = 'mb'; break;
              case 506: result = 'ac'; break;
              case 502: result = 'pl'; break;
              case 503: result = 'cl'; break;
              case 508: result = 'ev'; break;
              case 510: result = 'fv'; break;
              case 507: result = 'ib'; break;
            }
            return result;
        },
        getwttoken : function (icodservice) {
            var result = 'undefined'
            switch (icodservice) {
              case 501: result = '_footer_services_zedmobile.html'; break; 
              case 502: result = '_footer_services_zedpeople.html'; break; 
              case 503: result = '_footer_services_zedclaims.html'; break; 
              case 504: result = '_footer_services_zedguides.html'; break; 
            }
            return result;
        },
        callwt : function(icodservice,token,nick) {
            if( dcsMultiTrack ) {
               dcsMultiTrack('DCS.dcsuri', this.getwtprefix(icodservice) + token,'DCS.dcsqry','wtn=' + nick ); 
            }    
        }   
    },
        
    usercontext : {
        changelanguage : function(languagecode, backurl) {
            var url = 'http://api.zed.com/ops/cfbridge.aspx?intOper=5&iTipo=1&sLanguageCode='+languagecode
            if (backurl && backurl!='') {
                url += '&sBackUrl=' + encodeURIComponent(backurl);
            }
            return url;
        },
        changecountry : function(countrycode) {
            var url = 'http://api.zed.com/ops/cfbridge.aspx?intOper=5&iTipo=2&sCountryCode='+countrycode
            return url;
        }
    }
}

///////////////////////////
// REQUIRED FILES LOADER //
///////////////////////////

//This object loads all the js and css than forms the zedapi.
function zedapiloader() {
}

zedapiloader.prototype = {

  //Adds a js include to the DOM
  _addjs: function(libraryname) {
    document.write('<script type="text/javascript" src="'+libraryname+'"></script>');
  },

  //Adds a css reference to the DOM
  _addcss: function(stylesheetname) {
    document.write('<link rel="STYLESHEET" type="text/css" media="screen" href="'+stylesheetname+'" />');
  },

  //Main function, it adds the references to the page DOM
  load: function() {
    //JS files to include. Add here new required js files.
    var includes = {items:['prototype','effects','lightwindow','zedapicm']};
    //CSS files to include. Add here new required css files.
    var csss = {items:['lightwindow']};
    var scripts = document.getElementsByTagName("script");
    var path = null;

    //Get the js folder path
    //It gets it searching in the dom the "zedapi" js include, and getting its base path
    for (var i=0;i<scripts.length;i++) {
        var script;
        script = scripts[i];
        if (script.src && script.src.match(/zedapi\.js(\?.*)?$/)) {
            path = script.src.replace(/zedapi\.js(\?.*)?$/,'');
            break;
        }
    }
    
    if (path) {
        //Relative paths resolution
        //This must be done only in development environments to support SEO and non SEO environments
        //var relpath = path.replace('/js','')
        //zedapiconfig.prototype.relpath = relpath;
        //if (zedapiconfig.prototype.account.bridgeurl.substring(0,7)!='http://') {
        //    zedapiconfig.prototype.account.bridgeurl = relpath + zedapiconfig.prototype.account.bridgeurl;
        //}
        //End relative path resolution
        //Include the js files
        for (var i=0;i<includes.items.length;i++)  {
            var include;
            include = includes.items[i];
            this._addjs(path+include+'.js');
        }
        //Include the css files
        for (var i=0;i<csss.items.length;i++)  {
            var css;
            css = csss.items[i];
            this._addcss(path+'../css/'+css+'.css');
        }
    }
    
  }
}

new zedapiloader().load();