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 = 12;
	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("#");
	}
}

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 helpWindow;
function help(helpURL) {
	if (_hostName.indexOf("secfilings.")!=-1)
		helpURL = "http://www.nyse.com" + helpURL;
	var helpWindowAttributes = "width=430,height=430,scrollbars=yes,directories=no,status=no,location=no,menubar=no,personalbar=no,resizable=yes,titlebar=no,toolbar=no";
	if (helpWindow && !helpWindow.closed) {
		helpWindow.document.location.href = helpURL;
	} else {
		helpWindow = window.open(helpURL, "help", helpWindowAttributes);
	}
	helpWindow.focus();
}

var symbolWindow;
function symbol(symbolURL) {
	if (_hostName.indexOf("secfilings.")!=-1) {
		symbolURL = "http://www.nyse.com" + symbolURL;
		window.name="";
	}
	var symbolWindowAttributes = "width=430,height=430,scrollbars=1,directories=no,status=no,location=no,menubar=no,personalbar=no,resizable=no,titlebar=no,toolbar=no";
	if (symbolWindow && !symbolWindow.closed) {
		symbolWindow.document.location.href = symbolURL;
	} else {
		symbolWindow = window.open(symbolURL, "symbol", symbolWindowAttributes);
	}
	if (_hostName.indexOf("secfilings.")!=-1) {
		symbolWindow.opener = null;
	}

	symbolWindow.focus();
}

var faqWindow;
function faq(faqURL) {

	var faqWindowAttributes = "width=446, height=430, scrollbars=yes, directories=no, status=no, location=no, menubar=no, personalbar=no, resizable=yes, titlebar=no, toolbar=no";
	if (faqWindow && !faqWindow.closed) {
		faqWindow.document.location.href = faqURL;
	} else {
		faqWindow = window.open(faqURL, "faq", faqWindowAttributes);
	}
	faqWindow.focus();
}

var flashWindow;
function flash(flashURL) {

	var flashWindowAttributes = "width=430, height=220, 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();
}

var lcFactSheetWindow;
function lcFactSheet(lcFactSheetURL) {
	var lcFSWindowAttributes= "width=637,height=600,scrollbars=yes,directories=no,status=no,location=no,menubar=no,personalbar=no,resizable=yes,titlebar=no,toolbar=no";
	if (lcFactSheetWindow && !lcFactSheetWindow.closed) {
		lcFactSheetWindow.document.location.href = lcFactSheetURL;
	} else {
		lcFactSheetWindow = window.open(lcFactSheetURL, "test", lcFSWindowAttributes);
	}
	lcFactSheetWindow.focus();
}


/* duplicate function found. commented below code.
var symbolWindow;
function symbol(symbolURL) {

	var symbolWindowAttributes = "width=430,height=430,scrollbars=1,directories=no,status=yes,location=no,menubar=no,personalbar=no,resizable=no,titlebar=no,toolbar=no";
	if (symbolWindow && !symbolWindow.closed) {
		symbolWindow.document.location.href = symbolURL;
	} else {
		symbolWindow = window.open(symbolURL, "symbol", symbolWindowAttributes);
	}
	symbolWindow.focus();
}*/


window.onError = null;
var tempParentWindow = null;
function writeToParentMain(main)
{
	tempParentWindow = top.opener.top;
	if(main.indexOf("www.") != -1) {
		var outURL = parseQuery(main,"displayPage");
		open_window(outURL,"extsitename");
	}
	else {
	       if (tempParentWindow != null)
			tempParentWindow.window.location.href = main;
		else
			open_window(outURL,"NYSE");

	}
}

function open_window(url, name) {
        popup = window.open(url, name);
}

// 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);
}
