var curX=-10;

var  newnd;
function OpenSS(winName,theURL,wid,hei)
{
  newnd = window.open(theURL,winName,'status=0,scrollbars=1,resizable=1,width='+wid+',height='+hei);
  newnd.focus();
  newnd.focus();
}

function RGB(r,g,b)
{
    hex=new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
    rgb="#";
    rgb+=hex[r>>4];
    rgb+=hex[r & 15];
    rgb+=hex[g>>4];
    rgb+=hex[g & 15];
    rgb+=hex[b>>4];
    rgb+=hex[b & 15];
    return rgb;
}

var text="";

function DoEffect1(str)
{
    text=str;
    html="";
    if (curX>0)
    {
        html="<font color=white>"+str.substr(0,curX)+"</font>";
    }
    dr=(0xFF-0x20)/10;
    dg=(0xFF-0x5a)/10;
    db=(0xFF-0x87)/10;
    r=0xFF;
    g=0xFF;
    b=0xFF;
    for (i=curX;i<curX+10 && i<str.length;i++)
    {
        if (i>=0) html+="<font color="+RGB(r,g,b)+">"+str.charAt(i,1)+"</font>";
        r-=dr;
        g-=dg;
        b-=db;
    }
    if (i<str.length)
    {
        html+="<font color=#205a87>"+str.substr(i,str.length-i)+"</font>";
    }
    if (document.all['title'])
    {
        document.all['title'].innerHTML=html;
        curX++;
    }
    if (curX<str.length+11) setTimeout("DoEffect1(text)",5);
  
}

var cur = new Date();
var exp = new Date(cur.getTime() + 2000000000);
var date = GetDate();
var ref = GetRef();
var page = GetPage();
document.cookie ="date="+(date)+"; path=/; expires="+exp.toGMTString(); 
document.cookie ="ref="+(ref)+"; path=/; expires="+exp.toGMTString(); 
document.cookie ="page="+(page)+"; path=/; expires="+exp.toGMTString(); 

function GetDate()
{
    var date = GetCookie('date');
    if(date == null)
    {
        var day = cur.getDate()+"/";
        var month = cur.getMonth()+1+"/";
        var year = cur.getYear();
        date = day+month+year;
    }
    return date;
}

function GetRef()
{
    var ref = GetCookie('ref');
    if(ref == null)
    {
        ref = document.referrer;
    }
    return ref;
}

function GetPage()
{
    var page = GetCookie('page');
    if(page == null)
    {
        page = document.location;
    }
    return page;
}

function GetCookieVal(offset)
{
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
    endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name)
{  
    var arg = name + "=";  
    var alen = arg.length;  
    var clen = document.cookie.length;  
    var i = 0;  
    while (i < clen)
    {
        var j = i + alen;    
        if (document.cookie.substring(i, j) == arg)      
            return GetCookieVal (j);    
        i = document.cookie.indexOf(" ", i) + 1;    
        if (i == 0)
            break;   
    }  
    return null;
}

function GetRegnowURL(pid)
{
    pid = pid + "";

    var url="";
    var ref = GetCookie('ref');
    var date = GetCookie('date');
    var page = GetCookie('page');

    if(date == null)
    {
        url = "https://www.regnow.com/softsell/nph-softsell.cgi?item=" + pid + "&linkid=noCookie";
    }
    else
    {
        if (ref == null)
        {
            ref="directRequest";
        }
        var ref2 = escape (ref);
        url = "https://www.regnow.com/softsell/nph-softsell.cgi?item=" + pid + "&linkid=" + (date) +  "&linkid=" + (ref2) + "&linkid=" + (page);
    }

    return url;
}

function GetRegnowCouponURL(pid,coup)
{
    pid = pid + "";

    var url="";
    var ref = GetCookie('ref');
    var date = GetCookie('date');
    var page = GetCookie('page');

    if(date == null)
    {
        url = "https://www.regnow.com/softsell/nph-softsell.cgi?item=" + pid + "&linkid=noCookie&ss_coupon="+coup;
    }
    else
    {
        if (ref == null)
        {
            ref="directRequest";
        }
        var ref2 = escape (ref);
        url = "https://www.regnow.com/softsell/nph-softsell.cgi?item=" + pid + "&linkid=" + (date) +  "&linkid=" + (ref2) + "&linkid=" + (page)+"&ss_coupon="+coup;
    }

    return url;
}

function GetRegnowBundleURL(pid)
{
    pid = pid + "";

    var url="";
    var ref = GetCookie('ref');
    var date = GetCookie('date');
    var page = GetCookie('page');

    if(date == null)
    {
        url = "https://www.regnow.com/softsell/nph-softsell.cgi?bundle=" + pid + "&linkid=noCookie";
    }
    else
    {
        if (ref == null)
        {
            ref="directRequest";
        }
        var ref2 = escape (ref);
        url = "https://www.regnow.com/softsell/nph-softsell.cgi?bundle=" + pid + "&linkid=" + (date) +  "&linkid=" + (ref2) + "&linkid=" + (page);
    }

    return url;
}

function GetShareitURL(pid)
{
    pid = pid + "";

    var url="";
    var ref = GetCookie('ref');
    var date = GetCookie('date');
    var page = GetCookie('page');

    if(date == null)
    {
        url = "https://secure.shareit.com/shareit/cart.html?PRODUCT["+pid+"]=1&HADDITIONAL2["+pid+"]=noCookie";
    }
    else
    {
        if (ref == null)
        {
            ref="directRequest";
        }
        var ref2 = escape (ref);
        url = "https://secure.shareit.com/shareit/cart.html?PRODUCT["+pid+"]=1&HADDITIONAL2["+pid+"]=("+(date)+")_"+(ref2)+"_"+(page);
    }

    return url;
}

