// JavaScript Document


//Removes Default Text from form fields when clicked
function clickremove(obj, defaulttext)
{
	if (obj.value == defaulttext)
		obj.value = "";
}

//Adds Default Text on form field if blur and emtpy
function bluradd(obj, defaulttext)
{
	if (obj.value == "")
		obj.value = defaulttext;
}


// Allows flash to run
function flash(file, width, height, header, mylink)
{
	header = header.replace(/%/g,'%25').replace(/&/g,'and').replace(/\+/g,'%2B');
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'+width+'" height="'+height+'">\n');
	document.write('<param name="movie" value="'+file+'" />\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<param name="wmode" value="transparent" />\n');
	document.write('<param name="FlashVars" VALUE="header='+header+'&amp;link='+mylink+'" />\n');
	document.write('<embed src="'+file+'" FlashVars="header='+header+'&amp;link='+mylink+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" />\n');
	document.write('</object>');
}

// Fraction from Decimal
function fractApprox(x,maxDenominator) {
	// Created 1997 by Brian Risk.  http://brianrisk.com
	maxDenominator = parseInt(maxDenominator);
	var approx = 0;
	var error = 0;
	var best = 0;
	var besterror = 0;
	for (var i=1; i <= maxDenominator; i++) {
		approx = Math.round(x/(1/i));
		error = (x - (approx/i))
		if (i==1) {best = i; besterror = error;}
		if (Math.abs(error) < Math.abs(besterror)) 
			{best = i; besterror = error;}
	}
	return (Math.round(x/(1/best)) + ":" + best);
}

// Screen Resolution
function getres()
{
	var width = screen.width;
	var height = screen.height;
	var decimalval = width/height;
	document.write(width + ' x ' + height + ' (' + fractApprox(decimalval.toFixed(4), 10) + ')');
}

//Compares screen resolution to current
function compareres(mywidth, myheight)
{
	
	if (mywidth == screen.width && myheight == screen.height)
		document.write('<div class="recommended">&nbsp;</div>');
	else if (fractApprox((mywidth/myheight).toFixed(4), 100) == fractApprox((screen.width/screen.height).toFixed(4), 100))
		document.write('<div class="recommended">&nbsp;</div>');
}
