/*
$Revision: 2 $
$Archive: /J2EE_DEV_ENVIROMENT/src/webdocs/website/install_test/js/landing_main.js $
$Date: 6/06/05 6:12p $
$Author: Michellek $
*/

// This allows direct links to screensavers content downloading.

//	VARIABLES *********************

var dlgRoot = "http://www.screensavers.com/Dlg/";

// do OS/Browser sniff
var agt= "" + navigator.userAgent.toLowerCase();
var appVer = "" + navigator.appVersion.toLowerCase();
var is_minor = 0;
var is_major = 0;
var is_opera = (agt.indexOf("opera") != -1);
var iePos  = appVer.indexOf('msie');
var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
var is_konq = (agt.indexOf('konqueror') !=-1);
var is_khtml  = (is_safari || is_konq);
if (iePos !=-1)
{
    if(is_win)
    {
        is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)));
        is_major = parseInt(is_minor);
    }
}
var is_ie   = ((iePos!=-1) && (!is_opera) && (!is_khtml));
var is_ie5up = (is_ie && is_minor > 5);
var bValidOS = is_win && is_ie5up;
var theOS = new Object;
theOS.compatible = bValidOS;
var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));
var is_ie5_5up =(is_ie && is_minor >= 5.5);
theOS.PLcompatible = (bValidOS && !is_win95 && is_ie5_5up);
var OS_WARN = "You must be using Internet Explorer 5.01 or higher on a Windows computer to install ScreenSavers.";

if (!window.g_iAffID) {
  if (window.g_sAffID) {
    g_iAffID = g_sAffID;
  }
}
function getSSLanding(ssID, ssName, ssPath, ssSwchPath, log_url, ssPublisherURL, ssPublisherName, ssType, ssCat, ssSubCat, ssFile)
{
    //create a image hit that will log the fact that we're requesting a new
    //image download...
    //
    //this is included to maintain compatability with the previous version
    //of SS.com... if/when we find another way to log this... we need to remove this
    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);
		}
		//add aff_id and u_id to querystring
		if (window.g_iAffID) qStr += "&aff_id=" + g_iAffID;
		qStr += "&log_url=" + escape(log_url);
		qStr += "&ssPLAble=" + (theOS.PLcompatible ? "true" : "false");
		
		var dlgHtmlPage = "directdownload.html";					
		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();
    }
}


function daughterWin(daughter)
{
   window.open(daughter,'daughter','width=500,height=600,location=0,resizable=0,copyhistory=0,status=0,scrollbars=1');
}
