var g_sAffQueryString = getAffQueryString();

var dlgRoot = "http://www.screensavers.com/Dlg/";

var agt=navigator.userAgent.toLowerCase();
var theOS = new Object;
theOS.major = parseInt(navigator.appVersion);
theOS.win95 =((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));  
theOS.ie = ( agt.indexOf("aol")==-1 && agt.indexOf("c-aol")==-1 )|| (agt.indexOf("msie")!=-1); 
theOS.ie3 =(theOS.ie && (theOS.major == 2)); 
theOS.ie4 = (theOS.ie && (agt.indexOf('4')!=-1) && (agt.indexOf('5.')==-1) && (agt.indexOf('6.0')==-1));
theOS.ie5 = (theOS.ie && (agt.indexOf('5.0')!=-1 && agt.indexOf('5.01')==-1 && agt.indexOf('5.5')==-1));
theOS.ie501 = (theOS.ie && (agt.indexOf('5.01')!=-1 && agt.indexOf('5.5')==-1));
theOS.ie55 = (theOS.ie && (agt.indexOf('5.5')!=-1));    
theOS.ie6 = (theOS.ie && (agt.indexOf('6.0')!=-1));  
theOS.win98 =((agt.indexOf("win98")!=-1)||(agt.indexOf("windows 98")!=-1)); 
theOS.winnt =((agt.indexOf("winnt")!=-1)||(agt.indexOf("windows nt")!=-1)); 
theOS.win32 = theOS.win95 || theOS.winnt || theOS.win98 ||((theOS.major >= 4) && (navigator.platform == "Win32")) || (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1);
theOS.compatible = ( theOS.win32 && (theOS.ie501 || theOS.ie55 || theOS.ie6));
theOS.PLcompatible = (theOS.compatible && !theOS.win95 && !theOS.ie501);
var bValidOS = theOS.compatible;

var OS_WARN = "You must be using Internet Explorer 5.01 or higher on a Windows computer to install ScreenSavers.";



function getSS(ssID, ssName, ssPath, ssSwchPath, log_url, ssPublisherURL, ssPublisherName, ssType, ssCat, ssSubCat, ssFile)
{
    var ss_date = new Date();
    var ss_logger=new Image();
    ss_logger.src=log_url + "&cacheBuster=" + ss_date.getMilliseconds();
    
    if(!bValidOS)
    {
        alert(OS_WARN);
    }
    else
    {
		var qStr = "?ssName=";
		qStr += escape(ssName);
		qStr += "&ssID=";
		qStr += escape(ssID);
		qStr += "&ssImg=";
		qStr += escape(ssSwchPath);
		qStr += "&ssExe=";
		qStr += escape(ssPath);
		qStr += "&ssPublisherURL=";
		qStr += escape(ssPublisherURL);
		qStr += "&ssPublisherName=";
		qStr += escape(ssPublisherName);
		qStr += "&ssType=";
		qStr += escape(ssType);
		qStr += "&ssCat=";
		qStr += escape(ssCat);
		if(null != ssSubCat)
		{
			qStr += "&ssSubCat=";
			qStr += escape(ssSubCat);
		}
		if(null != ssFile)
		{
			qStr += "&ssFile=";
			qStr += escape(ssFile);
		}
		qStr += "&" + g_sAffQueryString;

		qStr += "&log_url=" + escape(log_url);
                qStr += "&ssPLAble=" + (theOS.PLcompatible ? "true" : "false");
		
		var dlgHtmlPage = "ssterms.html";

		var new_date = new Date();
      var new_logger = new Image();
      
      new_logger.src="http://www.screensavers.com/img/pix.bmp?display=DownloadButtonClick&cacheBuster=" + new_date.getMilliseconds() + "&u_id="+g_sGenID+ "&aff_id="+g_sAffID+ "&dest_id=" + ssID + "&SS_ID=" + g_sSSID + "&sess_id=" + g_sSessID;
         		
		var dlgHeight = 360;
		var dlgWidth = 440;
		var dlgLeft = (window.screen.width/2) - (dlgWidth/2);
		var dlgTop = (window.screen.height/2) - (dlgHeight/2);
		var curDlg = window.open(dlgRoot+dlgHtmlPage+qStr, ssID, "left="+dlgLeft+",top="+dlgTop+",height="+dlgHeight+",width="+dlgWidth+",status=no,toolbar=no,menubar=no,location=no,resizable=no");
		curDlg.focus();
    }
}
