function download(num) {

    var rid = 2971 ; // Direct
    var seoRID = 2972 ; // SEO
    var sub = '';
    var referrer = ReadCookie("referrer");
    
    if (referrer != null || referrer != "")
    {
        if (referrer.match("google.") != null || 
            referrer.match("yahoo.") != null || 
            referrer.match("live.") != null || 
            referrer.match("msn.") != null || 
            referrer.match("rambler.") != null || 
            referrer.match("yandex.") != null && 
            referrer.match("mail.") == null)
            {
                rid = seoRID;
                sub = referrer;
            }
    } 
	 			 
    if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent))
    {
         if (num == "" || num == null)
         {
            mywindow = window.open('http://www.etoro.com/setup.aspx?rid=' + rid + '&sub=' + sub + '','downWindow','left=0,top=0,width=100,height=100,z-lock=yes,dependent=yes');	
            num=0;
         }
         else
         {
            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));
}

