/*
	$Id:$
*/

function cssDivergence() {
	win = "";
	mac = "";
	w3c = "";

	this.setLinkElement = setLinkElement;
	this.setCssLocation = setCssLocation;

	function setCssLocation(url,ppi) {
		if ( typeof(url) != "undefined") {
			if (ppi == "90") w3c = url;
			else if (ppi == "72") mac = url;
			else win = url;
		}
	}

	function getCssLocation() {
		var rez = win;
		if (mac != "" && getPPI() == 72) rez = mac;
		else if (w3c != "" && getPPI() == 90) rez = w3c;
		return rez;
	}

	function getPPI() {
		var result = 90; //W3C recommended ppi
		if (navigator.userAgent) {
			if (navigator.userAgent.indexOf("Mac",0) != -1 && !document.getElementById) {
				result = 72;
			} else if (navigator.userAgent.indexOf("Win",0) != -1 && document.layers) {
				result = 90; 
			} else {
				result = 96;
			}
		}
		return result;
	}

	function setLinkElement() {
		if (getCssLocation() != "") document.write('<link rel="stylesheet" type="text/css" href="' + getCssLocation() +'" />');
	}
}
