/*
$Revision: 2 $
$Archive: /Screensavers.com/Screensaver Wallpaper Manager/js/landing_main.js $
$Date: 5/07/04 2:31p $
$Author: Seanc $
*/

// 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 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);
//Browser Compatibility Check
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 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
		qStr += "&aff_id=" + g_iAffID;
		qStr += "&log_url=" + escape(log_url);
		qStr += "&ssPLAble=" + (theOS.PLcompatible ? "true" : "false");
		
		var dlgHtmlPage = "ssterms.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');
}
