/**
 * Helper-functions to find out some client-informations
 * 
 * Stores infos in cookie
 */

var cookieString;

// ------------------------------------------------------------------------------------------------
// Set cookie
// ------------------------------------------------------------------------------------------------
function setCookie( name, value, expires, path, domain, secure )
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if (expires){
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

// ------------------------------------------------------------------------------------------------
// JavaScript is enabled! ;o)
// ------------------------------------------------------------------------------------------------
cookieString = 'sc_javascript=1';

// ------------------------------------------------------------------------------------------------
// Detect Flash
// ------------------------------------------------------------------------------------------------
cookieString += '&sc_flashversion='+GetSwfVer();

// ------------------------------------------------------------------------------------------------
// Detect Acrobat Reader
// ------------------------------------------------------------------------------------------------
var i_acrobatreader;
var v_acrobatreader;
var a_acrobatreader;
if (navigator.plugins) {
	for (var i=0; i < navigator.plugins.length; i++) {
		if (navigator.plugins[i].name.toLowerCase().indexOf("adobe acrobat") >= 0) {
			i_acrobatreader = true;
			v_acrobatreader = navigator.plugins[i].description.substring(navigator.plugins[i].description.toLowerCase().lastIndexOf("version ") + 8, navigator.plugins[i].description.toLowerCase().lastIndexOf(" for"));
			break;
		}
	}
}

var pdfCheck;
var stringsToCheck = new Array('Adobe', 'Acrobat', 'pdf', 'PDFViewer');
for (var i in stringsToCheck) {
	if (navigator.plugins[stringsToCheck[i]] != null) {
		pdfCheck = '1';
	}
}

if (i_acrobatreader) {
	if (v_acrobatreader) {
		pdfCheck = 'Adobe Acrobat Version: '+v_acrobatreader;
	} else {
		pdfCheck = '1';
	}
} else {
	pdfCheck = '0';
}
cookieString += '&sc_pdfplugin='+pdfCheck;


// ------------------------------------------------------------------------------------------------
// Detect screen resolution
// ------------------------------------------------------------------------------------------------
cookieString += '&sc_screenresolution='+screen.width+'x'+screen.height;

// ------------------------------------------------------------------------------------------------
// Detect screen color depth
// ------------------------------------------------------------------------------------------------
cookieString += '&sc_screencolordepth='+screen.colorDepth;

// ------------------------------------------------------------------------------------------------
// Browser version
// ------------------------------------------------------------------------------------------------
cookieString += '&sc_browserversion='+navigator.appCodeName+' '+navigator.appName+' '+ navigator.appVersion;

// ------------------------------------------------------------------------------------------------
// Create cookie with check-strings
// ------------------------------------------------------------------------------------------------
// add special separator for cookie-end
cookieString += '+sysEnd+';
// set cookie
setCookie('sys', cookieString, '', '/');