function BrowserInfo() {
	var agent = window.navigator.userAgent;
	if (agent.indexOf("MSIE") != -1) {
			var start = agent.indexOf("MSIE");
			this.name = "MSIE";
			this.version = parseFloat(agent.substring(start + 5, agent.indexOf(";", start)));
	} else if (agent.indexOf("Firefox") != -1) {
			var start = agent.indexOf("Firefox");
			this.name = "Firefox";
			this.version = agent.substring(start + 8, agent.length);
			var firstDec = this.version.indexOf(".") + 1;
			while (this.version.indexOf(".", firstDec) != -1)
				this.version = this.version.substring(0, firstDec) + this.version.substring(firstDec).replace(".", "");
			this.version = parseFloat(this.version);
	} else {
			this.name = "Unknown";
			this.version = 0;
	}
}

var info = new BrowserInfo();
var userAgent = window.navigator.userAgent
var isIE = (window.navigator.userAgent.indexOf("MSIE") != -1);
var isIE6 = (info.name == "MSIE" && info.version < 7);
/*var isSafari = (window.navigator.userAgent.indexOf("Safari") != -1);
var isMac = navigator.appVersion.indexOf("Mac")!=-1;*/
var isFireFox = (window.navigator.userAgent.indexOf("Firefox") != -1);
/*var isMacFireFox = isMac && isFireFox;
var is_iPod = navigator.appVersion.indexOf("iPod")!=-1;
var is_iPhone = navigator.appVersion.indexOf("iPhone")!=-1;*/

if (info.name == "MSIE" && info.version < 7)
	document.writeln('<link href="stylesIE6.css" rel="stylesheet" type="text/css" />');
else
	document.writeln('<link href="stylesDynamic.css" rel="stylesheet" type="text/css" />');
/*if (isMac || isSafari)
	document.writeln('<link href="stylesMac.css" rel="stylesheet" type="text/css" />');

if (isMacFireFox)
	document.writeln('<link href="stylesMacFireFox.css" rel="stylesheet" type="text/css" />');

if (is_iPod || is_iPhone)
	document.writeln('<link href="styles_iPod.css" rel="stylesheet" type="text/css" />');*/


function writePngImage(url, width, height, alt) {
	if (!isIE6)
		document.write("<img alt=\"" + alt + "\" src=\"" + url + "\" style=\"width: " + width + "px; height: " + height + "px;\">");
	else
		document.write("<img src=\"spacer.png\" style=\"width: " + width + "px; height: " + height + 
			"px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "', sizingMethod=scale);\">");
}

function writePngClass(url, width, height, alt, className) {
	if (!isIE6)
		document.write("<img alt=\"" + alt + "\" class=\"" + className + "\" src=\"" + url + "\" style=\"width: " + width + "px; height: " + height + "px;\">");
	else
		document.write("<img alt=\"" + alt + "\" class=\"" + className + "\"  src=\"spacer.png\" style=\"width: " + width + "px; height: " + height + 
			"px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "', sizingMethod=scale);\">");
}

function writePngImageMap(url, width, height, alt, map) {
	if (!isIE6)
		document.write("<img usemap=\"" + map + "\" alt=\"" + alt + "\" src=\"" + url + "\" style=\"width: " + width + "px; height: " + height + "px;\">");
	else
		document.write("<img usemap=\"" + map + "\" src=\"spacer.png\" style=\"width: " + width + "px; height: " + height + 
			"px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "', sizingMethod=scale);\">");
}

function renderFlash(src, width, height, features) {
	document.writeln('<embed src="' + src + '" quality="high" bgcolor="#ffffff" width="' + width + 
					 '" height="' + height + '" align="middle" allowscriptaccess="sameDomain" ' +
					 'type="application/x-shockwave-flash" ' + features + 
					 'pluginspage="http://www.macromedia.com/go/getflashplayer" />');
}

function submitForm(id) 
{
	document.getElementById(id).submit();
	return false;
}

String.prototype.trim = function () {
	return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

reset_form_value = function(str1, str2, val) {
	if(str1 == val.value.trim())
		val.value = str2;
}

function launchWindow(url, width, height, title) {
	if (url != "")
		window.open(url, "preview_image", "width=" + (width + 50) + ", height=" + (height + 50) + ", location=0, menubar=0, resizable=0, scrollbars, status=0, titlebar=1, toolbar=0");
}



function getCookie( name ) {
  var start = document.cookie.indexOf( name + "=" );
  var len = start + name.length + 1;
  if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
    return null;
  }
  if ( start == -1 ) return null;
  var end = document.cookie.indexOf( ";", len );
  if ( end == -1 ) end = document.cookie.length;
  return unescape( document.cookie.substring( len, end ) );
}

function setCookie( name, value, expires, path, domain, secure ) {
  var today = new Date();
  today.setTime( today.getTime() );
  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" : "");
}

function deleteCookie( name, path, domain ) {
  if ( getCookie( name ) ) document.cookie = name + "=" +
    ( ( path ) ? ";path=" + path : "") +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

if (getCookie("FontSize") == null)
	setCookie("FontSize", "font_normal");

function loadFont() {
	var size = getCookie("FontSize");
	document.getElementsByTagName("body")[0].className = size;
}

function smallerFont() {
	var bodyTag = document.getElementsByTagName("body")[0];
		
	if (getCookie("FontSize") == "font_normal") {
		setCookie("FontSize", "font_small");
		bodyTag.className = "font_small";
	} else if (getCookie("FontSize") == "font_large") {
		setCookie("FontSize", "font_normal");
		bodyTag.className = "font_normal";
	}
	return false;
}

function largerFont() {
	var bodyTag = document.getElementsByTagName("body")[0];
		
	if (getCookie("FontSize") == "font_small") {
		setCookie("FontSize", "font_normal");
		bodyTag.className = "font_normal";
	} else if (getCookie("FontSize") == "font_normal") {
		setCookie("FontSize", "font_large");
		bodyTag.className = "font_large";
	}
	return false;
}

function showVideo(video) {
	var video01 = document.getElementById("video01");
	var video02 = document.getElementById("video02");
	var video03 = document.getElementById("video03");

	switch (video) {
		case "video01":
			/*video01.style.display = "";
			video02.style.display = "none";
			video03.style.display = "none";*/
			window.location="Media.aspx?video=1";
			break;

		case "video02":
			/*
			video01.style.display = "none";
			video02.style.display = "";
			video03.style.display = "none";
*/
			window.location="Media.aspx?video=2";
			break;

		case "video03":
			/*
			video01.style.display = "none";
			video02.style.display = "none";
			video03.style.display = "";*/
			window.location="Media.aspx?video=3";
			break;

		case "video04":
			/*
			video01.style.display = "none";
			video02.style.display = "none";
			video03.style.display = "";*/
			window.location="Media.aspx?video=4";
			break;
	}
}