/*
   (c) 2004-2005, Sharewire B.V.
   www.sharewire.net

   For questions and support mail us at
   support@sharewire.net
*/

function launch(newURL, newName, newFeatures, orgName) {
        var remote = open(newURL, newName, newFeatures);

        if (remote.opener == null)
            remote.opener = window;
        remote.opener.name = orgName;

        return remote;
}

/*
   Parameters:
     _nProdID             Sharewire ID of product
     _nAffiliateID        Affiliate ID. Set to 0 if none.
     _sCustParam          Custom parameter, will be posted to your notification URL. Set to '' if none.
     _sCountry            Country (string). If not '', the country selection screen will be omitted.
                          Possible values:
                          'aus'          Austria
                          'bel'          Belgium
                          'dk'           Denmark
                          'fi'           Finland
                          'ger'          Germany
                          'ire'          Ireland
                          'it'           Italy
                          'nl'           Netherlands
                          'nor'          Norway
                          'por'          Portugal
                          'sp'           Spain
                          'swe'          Sweden
                          'uk'           United Kingdom
                          'us'           United States
                          ''             Start with payment screen
     _bDoPopup            1 or 0. If 1, payment screens will be displayed in a separate popup screen.
                          If 0, payment screens will be displayed in current page.
     _bDoPhoneSelection   1 or 0. If 1, a separate screen will be included which displays all
                          available product versions.
                          If 0, _nProdID will be used.
     _nScreenWidth        Popup screen width. Ignored if _bDoPopup == 0.
     _nScreenHeight       Popup screen height. Ignored if _bDoPopup == 0.

*/
function doSharewire(_nProdID, _nAffiliateID, _sCustParam, _sCountry, _bDoPopup, _bDoPhoneSelection, _nScreenWidth, _nScreenHeight) {
        if(_bDoPopup == 0) {
            document.location.href="http://www.sharewire.net/buy/?prodID="+_nProdID+"&phoneSelection="+_bDoPhoneSelection+"&country="+_sCountry+"&custParam="+_sCustParam;
            return;
        }

        if(screen) {
            leftPos = (screen.width/2)-_nScreenWidth
            topPos  = (screen.height/2)-_nScreenHeight;
        }

        myRemote = launch("http://www.sharewire.net/buy/?prodID="+_nProdID+"&phoneSelection="+_bDoPhoneSelection+"&country="+_sCountry+"&custParam="+_sCustParam,
                "myRemote", 'toolbar=0,location=0,directories=0,status=0,'+
                'menubar=0,scrollbars=0,resizable=1,width='+ _nScreenWidth +',height='+ _nScreenHeight +','+
                'left='+leftPos+',top='+topPos,'myWindow');

        myRemote.focus();
}

function launchSharewire(prodID) {
    doSharewire(prodID, 0, '', '', 1, 0, 292, 480);
    /*
    if (screen) {
            leftPos = (screen.width/2)-146
        topPos  = (screen.height/2)-220;
    }
    //+document.location.href
    myRemote = launch("http://www.sharewire.net/buy/?prodID="+prodID+"&referrer=",
        "myRemote", 'toolbar=0,location=0,directories=0,status=0,'+
        'menubar=0,scrollbars=0,resizable=1,width=280,height=498,'+
        'left='+leftPos+',top='+topPos,'myWindow');

    myRemote.focus();
    */
}

function launchSharewireMP(prodID, param) {
    doSharewire(prodID, 0, param, '', 1, 0, 292, 480);

    /*
        if (screen) {
            leftPos = (screen.width/2)-146
        topPos  = (screen.height/2)-220;
    }

    myRemote = launch("http://www.sharewire.net/buy/?prodID="+prodID+"&custParam="+param,
        "myRemote", 'toolbar=0,location=0,directories=0,status=0,'+
        'menubar=0,scrollbars=0,resizable=1,width=280,height=498,'+
        'left='+leftPos+',top='+topPos,'myWindow');

    myRemote.focus();
    */
}

function launchSharewireAF(prodID, custID) {
    doSharewire(prodID, custID, '', '', 1, 0, 292, 480);

    /*
        if (screen) {
            leftPos = (screen.width/2)-146
        topPos  = (screen.height/2)-220;
    }

    myRemote = launch("http://www.sharewire.net/buy/?prodID="+prodID+"&affiliate="+custID+"&referrer=",
        "myRemote", 'toolbar=0,location=0,directories=0,status=0,'+
        'menubar=0,scrollbars=0,resizable=1,width=280,height=498,'+
        'left='+leftPos+',top='+topPos,'myWindow');

    myRemote.focus();
    */
}

function swResell(prodID, affID) {
        if (screen) {
            leftPos = (screen.width/2)-146
        topPos  = (screen.height/2)-220;
    }

    myRemote = launch("http://www.sharewire.net/buy/?prodID="+prodID+"&swAff="+affID,
        "myRemote", 'toolbar=0,location=0,directories=0,status=0,'+
        'menubar=0,scrollbars=0,resizable=1,width=280,height=498,'+
        'left='+leftPos+',top='+topPos,'myWindow');

    myRemote.focus();
}

function viewSale(saleID) {
        //var leftDiff = 20;
           //var winWidth = 292;
           //var winHeight = 440;
    if (screen) {
            leftPos = (screen.width/2)-146
                topPos  = (screen.height/2)-220;
    }

        myRemote = launch("viewsale.php3?saleID="+saleID,"myRemote",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=300,height=400,left='+leftPos+',top='+topPos,'myWindow');
        myRemote.focus()
}

function showContent() {
    document.forms.product_form.contentchanged.value = 1
    document.forms.product_form.submitted.value = 0
    document.forms.product_form.submit()
}
