var _hostName = top.location.hostname;

function BrowserCheck() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.version = navigator.appVersion
	this.v = parseInt(this.version)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=5)
	this.ie4 = (this.version.indexOf('MSIE 4')>0)
	this.ie5 = (this.version.indexOf('MSIE 5')>0)
	this.min = (this.ns||this.ie)
}

var flashVersion = 0;
var flashVersion_DONTKNOW = -1;
var dontKnow = false;
var flashcookie = false;

function getFlashVersion() {
	var latestFlashVersion = 8;
	var agent = navigator.userAgent.toLowerCase(); 

	if (agent.indexOf("mozilla/3") != -1 && agent.indexOf("msie") == -1) {
		flashVersion = 0;
	}

	if (navigator.plugins != null && navigator.plugins.length > 0) {
		var flashPlugin = navigator.plugins['Shockwave Flash'];
		if (typeof flashPlugin == 'object') { 
			for (var coun = latestFlashVersion; coun >= 3; coun--) {
            if (flashPlugin.description.indexOf(coun + '.') != -1) {
               flashVersion = coun;
               break;
            }
         }
		}
	}

	else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
	   var doc = '<scr' + 'ipt language="VBScript"\> \n';
      doc += 'On Error Resume Next \n';
      doc += 'Dim obFlash \n';
      doc += 'For coun = ' + latestFlashVersion + ' To 3 Step -1 \n';
      doc += '   Set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash." & coun) \n';
      doc += '   If IsObject(obFlash) Then \n';
      doc += '      flashVersion = coun \n';
      doc += '      Exit For \n';
      doc += '   End If \n';
      doc += 'Next \n';
      doc += '</scr' + 'ipt\> \n';
      document.write(doc);
   }
		
	else if (agent.indexOf("webtv/2.5") != -1) {
			flashVersion = 3;
	}

	else if (agent.indexOf("webtv") != -1) flashVersion = 2;

	else {
		flashVersion = flashVersion_DONTKNOW;
	}

	return flashVersion;
}

function createcookie() {
	var cookieStart = document.cookie.indexOf('isflash');

	if (cookieStart != -1) {
		var cookieEnd = document.cookie.indexOf(';', cookieStart);
		if (cookieEnd == -1) cookieEnd = document.cookie.length; {
			flashVersion = document.cookie.substring(cookieStart + 8, cookieEnd);
			flashcookie = true;
		}
	}
	else {
		flashVersion = getFlashVersion();
		document.cookie = 'isflash=' + flashVersion;
	}
}

createcookie();

if (flashVersion == flashVersion_DONTKNOW) {
	flashVersion = 0;
	dontKnow = true;
}

function checkflash() {
	if(flashVersion<6 && flashcookie==false) {
		flash("get_flash.html");
	}
}

checkflash();

function clearcookie() {
	name = document.cookie;
	var expire = new Date();
	expire.setTime(expire.getTime() - 1000);
	document.cookie = name + "=" + "" + "; expires=" + expire.toUTCString();
}

function verifyflash() {
	clearcookie();
	location.reload();
}

var flashWindow;
function flash(flashURL) {
	var flashWindowAttributes = "width=430, height=300, scrollbars=no, directories=no, status=no, location=no, menubar=no, personalbar=no, resizable=no, titlebar=no, toolbar=no" + " top= " + ((screen.height/2)-110) + " left= " + ((screen.width/2)-215);
	if (flashWindow && !flashWindow.closed) {
		flashWindow.document.location.href = flashURL;
	} else {
		flashWindow = window.open(flashURL, "flash", flashWindowAttributes);
	}
	flashWindow.focus();
}


// Parses a query string 'queryString' for the variable 'queryName'
// and returns the value associated with that name.
function parseQuery (queryString, queryName) {
	startIndex = queryString.indexOf(queryName);
	if (startIndex == -1) {
		return false;
	}
	startIndex = queryString.indexOf("=", startIndex) + 1;
	endIndex = queryString.length;
	theVal = queryString.substring(startIndex, endIndex);
	theVal = unescape(theVal);
	return (theVal);	
}

