function download(num) {

    if (num == "" || num == null)
    {
        num = 0;
    }
    
    var tracking = ReadCookie("AffiliateWizAffiliateID");
    var rid = 2875; // Direct DE
    var sub = "";    
    
    if (tracking != null && tracking != "")
    {
        var splitTracking = tracking.split('&');
        
        if (splitTracking.length > 0)
        {
            rid = splitTracking[0].split('=')[1];
            sub = splitTracking[1].split('=')[1];
        }
    } 
    
    if (sub == "")
    {
        sub = ReadCookie("referrer");
    }
	 			 
    if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent))
    {
         mywindow = window.open('http://www.etoro.com/setup.aspx?rid=' + rid + '&sub=' + sub + '&dl='+num+'','downWindow','left=0,top=0,width=100,height=100,z-lock=yes,dependent=yes');	
    }
	 
   location.href= "/download.aspx?rid=" + rid + "&sub=" + sub + "&dl=" + num;
}		

function ReadCookie(cookieName) {
    var theCookie=""+document.cookie;
    var ind=theCookie.indexOf(cookieName);
    if (ind==-1 || cookieName=="") return ""; 
    var ind1=theCookie.indexOf(';',ind);
    if (ind1==-1) ind1=theCookie.length; 
    return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

