var debug=false;
var vbrunsok=false;
var versionCode = parseFloat(navigator.appVersion);
var activeX = (navigator.appName == "Microsoft Internet Explorer" && versionCode >= 4.0) ? true : false;


var theAgent		= navigator.userAgent.toLowerCase();
var cookiesOk		= navigator.cookieEnabled;
var	isAOL 			= (theAgent.indexOf("aol") != -1) || (theAgent.indexOf("iweng") != -1);
var	isKhtml 		= (theAgent.indexOf("khtml") != -1);
var	isOpera 		= (theAgent.indexOf("opera") != -1);
var	isGecko 		= !isKhtml && !isOpera && (theAgent.indexOf("gecko/") != -1);
var	isSafari 		= (theAgent.indexOf("safari") != -1);
var	isKonqueror = (theAgent.indexOf("konqueror") != -1);
var	isNetscape 	= !isOpera && ((theAgent.indexOf('mozilla')!=-1) && ((theAgent.indexOf('spoofer')==-1)	&& (theAgent.indexOf('compatible') == -1)));
var	isWebtv 		= (theAgent.indexOf("webtv") != -1);
var	isIE 				= !isWebtv && !isOpera && (theAgent.indexOf("msie") != -1);

// Get platform type
var	osMac = (theAgent.indexOf("mac")!=-1);
var	osWin = (navigator.platform == "Win32") || (theAgent.indexOf("windows")!=-1) || (theAgent.indexOf("winnt")!=-1) || (theAgent.indexOf("winme")!=-1) || (theAgent.indexOf("win9")!=-1) || (theAgent.indexOf("win16")!=-1) ;


browserTest();

function preStartUpCheck(){
     if (!document) return false;
     //if (!document.body) return false;
     if (!document.getElementById) return false;
     if (!document.getElementById('store')) return false;
     if (!document.getElementById('store').style) return false;
     if (!document.getElementById('store').innerHTML) return false;
     return true;
   }

function client_interrogator(){
	//getLocalTime();
	//getBrowserProperties();
	//getMachineProperties();
	//getVisualProperties();
}

function network_interrogator(){
}

function detectIE(ClassID,name) { result = false; document.write('<SCR'+'IPT LANGUAGE=VBScript>\n on error resume next\n vbrunsok=1\n result = IsObject(CreateObject("' + ClassID + '"))</SCR'+'IPT>\n'); if (result) return name+','; else return ''; }
function detectNS(ClassID,name) { n = ""; if (nse.indexOf(ClassID) != -1) if (navigator.mimeTypes[ClassID].enabledPlugin != null) n = name+","; return n; }

function browserTest(){
	if (isIE && osWin){
 		pluginlist = detectIE("Adobe.SVGCtl","SVG Viewer") + detectIE("SWCtl.SWCtl.1","Shockwave Director") + detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash") + detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer") + detectIE("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime") + detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player") + detectIE("PDF.PdfCtrl.5","Acrobat Reader");
 		if(vbrunsok){
 			say('Visual basic found.')
		}else{
			say("Sorry, Internet Explorer requires VBScript to provide your browser with information about your browser plugins!\nThere has been no visual basic found, please install or enable VBSript if you wish to launch this application.");
		}
	}
	
	if (isNetscape || !osWin){
		nse = "";
		for (var i=0;i<navigator.mimeTypes.length;i++) nse += navigator.mimeTypes[i].type.toLowerCase();
		pluginlist = detectNS("image/svg-xml","SVG Viewer") + detectNS("application/x-director","Shockwave Director") + detectNS("application/x-shockwave-flash","Shockwave Flash") + detectNS("audio/x-pn-realaudio-plugin","RealPlayer") + detectNS("video/quicktime","QuickTime") + detectNS("application/x-mplayer2","Windows Media Player") + detectNS("application/pdf","Acrobat Reader");
		//alert('NS mimetypes'+nse);
	}
	
	if (isOpera && osWin){
		nse = "";
		for (var i=0;i<navigator.mimeTypes.length;i++) nse += navigator.mimeTypes[i].type.toLowerCase();
		pluginlist = detectNS("image/svg-xml","SVG Viewer") + detectNS("application/x-director","Shockwave Director") + detectNS("application/x-shockwave-flash","Shockwave Flash") + detectNS("audio/x-pn-realaudio-plugin","RealPlayer") + detectNS("video/quicktime","QuickTime") + detectNS("application/x-mplayer2","Windows Media Player") + detectNS("application/pdf","Acrobat Reader");
		//alert('Opera mimetypes'+nse);
	}

	// Add java test result to pluginlist
	pluginlist += navigator.javaEnabled() ? "Java," : "";
	if (pluginlist.length > 0) pluginlist = pluginlist.substring(0,pluginlist.length-1);
	cookieMessage=(cookiesOk)?'Yes':'No';
	say(pluginlist+"\n"+'in '+theAgent+"\n"+'0n '+navigator.platform+"\n"+'Cookies '+cookieMessage);
	isWinMedia =(pluginlist.indexOf("Windows Media Player")!=-1)?true:false;
	isRealMedia		 =(pluginlist.indexOf("RealPlayer")!=-1)?true:false;
}


function getArgs(){ //Gather arguments from calling page
	fromparent=location.search.substr(1);
	if (fromparent){
    fromparent=unescape(fromparent);
    pairs=fromparent.split("&");
    for(i=0; i<pairs.length; i++){
      pair=pairs[i].split("=");
      eval(pair[0]+"=pair[1]");
    }
  }
}

function say(message){
	if(debug){
		if(document.getElementById('txtarea')){
			txt('INFO:',message);
		}else{
			alert(message);
		}
	}
}

function button_ctrl( id,state ){
	if(document.getElementById(id)){
			src_temp=document.getElementById(id).src.split('/');
			cc=src_temp[src_temp.length-1].split('.');
			cdw=cc[0].split('_');


			srcend=cdw[cdw.length-1];
			
			if(srcend=='button'){
				 cdw[cdw.length]=state;
			}else{
				 cdw[cdw.length-1]=state;
			}
			if(state==''){
				flnm=cdw.slice(0,cdw.length-1).join('_');
			}else{
				flnm=cdw.join('_');
			}
			flnmtemp=flnm+'.'+cc[cc.length-1]
			flnmtempa=src_temp.slice(0,src_temp.length-1).join('/');
			ftb=flnmtempa+'/'+flnmtemp;
			
			//alert(ftb);
			document.getElementById(id).src=ftb;

 	}
 }  // button_ctrl
