//copyright 2000; Gravity Media Group.
//this code may be used only for the purposes for which
//it was purchased. Unauthorized duplication or usage is
//prohibited.
//contact scott@gravitymedia.com with any questions.

if (is == null || is == "undefined") {
	alert("to know what is is, you need to first include 'browsercheck.js'");
} else {
var sInt;
if (is.linux) {
	sInt = 1.33;
} else if (is.mac && is.dom==1) {
	sInt = 1.33;
} else if (is.mac && is.dom==2) {
	sInt = 1.33;
} else if (is.ie) {
	sInt = 1.0;
} else {
	sInt = 1.06;
}
}

function styleObj (name, type, tag) {
	this.name = name;
	this.params = new Array();
	this.comment = "";
	this.type = (type)?type:"normalClass";
	this.tag = (tag)?tag:null;
}

function addP (pname, pattr) {
	this.params[this.params.length] = new styleParam(pname, pattr);
}
styleObj.prototype.addP = addP;


function styleParam (pname, pattr) {
	this.name = pname;
	this.attr = pattr;
}

function addComment (comm) {
	this.comment = comm;
}
styleObj.prototype.addComment = addComment;

function writeStyles(retStr) {
	sStr = "";
	sStr += "<STYLE TYPE=\"text/css\"><!-- \n";
	for (i=0; i<arStyles.length; i++) {
		if (arStyles[i] == null ) {continue;}
		if (arStyles[i].type == "normalClass") {
			sStr += "." + arStyles[i].name + " {";
		} else if (arStyles[i].type == "tagClass") {
			if (arStyles[i].name == "") {
				sStr += arStyles[i].tag + " {";
			}
			else {
				sStr += arStyles[i].tag + "." + arStyles[i].name + " {";
			}
		} else if (arStyles[i].type == "pseudoElement") {
			sStr += arStyles[i].tag + ":" + arStyles[i].name + " {";
		} else if (arStyles[i].type == "specificClass") {
			sStr += "." + arStyles[i].name + " " + arStyles[i].tag + " {";
		} else {
			sStr += "." + arStyles[i].name + " {";
		}
		for (j=0; j<arStyles[i].params.length; j++) {
			pname = arStyles[i].params[j].name;
			pattr = arStyles[i].params[j].attr
			
			if (pname == "font-size" || pname == "line-height") {
				if (is.linux) {
					pattr = (Math.floor(sInt * pattr));	
				} else {
					pattr = (sInt * pattr);	
				}
				pattr += "pt";
			}
			if (pname == "margin") {
				arPt = pattr.split(",");
				pattr = "";
				for (x=0; x<arPt.length;x++) {
					pattr += arPt[x] + "px ";
				}
			}
			if (pattr != "0px 0px 0px 0px "){
				sStr += pname + ":" + pattr + "; ";
			}
		}	
		sStr += "}\n";
	 }
		sStr += "--></STYLE>";
		if (retStr) {
			return sStr;
		}
		document.write(sStr);
}
