var xmlHttp;

function onloadbody()
{
    if(typeof(onload_page) != 'undefined')
    {
        onload_page();
    }
}

function onresizebody()
{
    if(typeof(onresize_page) != 'undefined')
    {
        onresize_page();
    }
}

function trim(str) {
    if (!str || typeof str != 'string') return null;
    return str.replace(/^[\s]+/, '').replace(/[\s]+$/, '').replace(/[\s]{2,}/, ' ');
}

function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
    {
        // Firefox, Opera 8.0+, Safari
        xmlHttp= new XMLHttpRequest();
    }
        catch (e)
    {
        // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}

var livesubmit_flag= true;
function basicSearch(str,event)
{
	if(event.keyCode==40 || event.keyCode==38 || event.keyCode==13){
		livesubmit_flag= false;
		schKeyDown(event,'basicsearchinput','livesearch');
	}
	else{
		livesubmit_flag= true;	
		
	if (str.length==0)
    { 
        document.getElementById("livesearch").innerHTML="";
        document.getElementById("livesearch").style.border="0px";
        document.getElementById("livesearch").style.visibility = "hidden";
        if ($('#recentcompanies').length == 1){
        	$('#recentcompanies').show();
        }
        if ($('#p20mcountry').length == 1){
        	$('#p20mcountry').show();
        }
        return;
    }

    xmlHttp=GetXmlHttpObject();

    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request");
        return;
    } 
    
    var url="livebasicsearch.php";
    url=url+"?q="+escape(str);

    if (document.forms["f_namesearch"])
    {
        if (document.forms["f_namesearch"].elements["u"].checked)
            url=url+"&u=on";
        if (document.forms["f_namesearch"].elements["i"].checked)
            url=url+"&i=on";
        if (document.forms["f_namesearch"].elements["ui"].checked)
            url=url+"&ui=on";
        if (document.forms["f_namesearch"].elements["ii"].checked)
            url=url+"&ii=on";
        if (document.forms["f_namesearch"].elements["p"].checked)
            url=url+"&p=on";
    }
    else if (document.forms["f_compalertsnamesearch"])
    {	/*used in MMT Alert*/
    	var groupid=document.getElementById("groupid").value;
        //url=url+"&page=companyalerts&u=on&i=on&ui=on&ii=on&p=on"; // nigel's
        //url=url+"&page=companyalerts&groupid="+groupid+"&u=on&i=on&ui=on&ii=on"; //20100203 - remarked as Neel advised only Executive & Advanced search will include inactive company search
        url=url+"&page=companyalerts&groupid="+groupid+"&u=on&i=on"; //no search on Private until further advise
    }
    else {
    	/*used by ChangeCompany feature*/        
        //url=url+"&page=switch&u=on&i=on&ui=on&ii=on"; //&p=1"; for testing as DANDB not available
        //url=url+"&page=switch&u=on&i=on&ui=on&ii=on&p=on"; //20100203 - remarked as Neel advised ChangeCompany to search only ACTIVE companies
        url=url+"&page=switch&u=on&i=on"; //&p=on"; temporarily remark Private company search until further advise
    }
    
    url=url+"&sid="+Math.random();

    xmlHttp.onreadystatechange=stateChangedLiveSearch;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    
	}
} 

function stateChangedLiveSearch() 
{ 
	var isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 
        document.getElementById("livesearch"). innerHTML=xmlHttp.responseText;
        document.getElementById("livesearch"). style.border="1px solid #A5ACB2";
    	//01April2010 Margaret - the index & exchange combo boxes overlaps  
    	//live searchbox in ie6. reduce the live searchbox size 
        if (isIE6){
        	document.getElementById("livesearch"). style.width="370px";
        }
        document.getElementById("livesearch"). style.visibility = "visible";
        if ($('#recentcompanies').length == 1){
        	$('#recentcompanies').hide();
        }
        if ($('#p20mcountry').length == 1){
        	$('#p20mcountry').hide();
        }
        return;
    } 
}

function switchCompany(compNumber) {
    if (compNumber!= -1) {
        loc= new String(location.href);
    	/* Siew Fong: 11-Feb-2010 - switch to private or public view */
    	var currentsector = "public";
        if (loc.search(/dunsnumber=\d+/i) != -1) {
        	currentsector = "private";
        } else if (loc.search(/dunsnumber20m=\d+/i) != -1) {
        	currentsector = "private20m";
        }
    	var newsector= "public";
    	if (compNumber.search(/\*20m_/) != -1) {
    		newsector = "private20m";
    		compNumber= compNumber.replace(/\*20m_/, "")
    	} else if (compNumber.search(/\*/) != -1) {
    		newsector = "private";
    		compNumber= compNumber.replace(/\*/, "")
    	}
    	if (newsector == "private20m") {
    		if (currentsector == "private20m") {
    			loc= loc.replace(/dunsnumber20m=\w+/, "dunsnumber20m="+compNumber);
    		} else {
    			loc= "private20mcompanydetail.php?dunsnumber20m="+compNumber+"&pagetype=synopsis";
    		}      		
    	} else if (newsector == "private") {
    		if (currentsector == "private") {
    			loc= loc.replace(/dunsnumber=\w+/, "dunsnumber="+compNumber);
    		} else {
    			loc= "privatecompanydetail.php?dunsnumber="+compNumber+"&pagetype=synopsis";
    		}   		
    	} else {
    		if (currentsector == "private" || currentsector == "private20m") {
    			loc= "companydetail.php?compnumber="+compNumber+"&pagetype=synopsis";
    		} else {
	            if (loc.search(/companyexecutives.php/i) == -1
	            	&& loc.search(/equitypricing.php/i) == -1 
	            	&& loc.search(/pagetype=capitalstock/i) == -1){
	            	loc= loc.replace(/compnumber=\d+/, "compnumber="+compNumber);
	            } else {  
	            	var url_array=loc.split("?");      
	            	if (loc.search(/equitypricing.php/i) != -1) {
	            		if (loc.search(/pagetype=report/i) == -1) {
	            			loc= url_array[0] + "?compnumber="+compNumber;
	            		} else {
	            			loc= url_array[0] + "?pagetype=report&" + "compnumber="+compNumber;
	            		}        		
	            	} else  if (loc.search(/pagetype=capitalstock/i) != -1) {
	            		loc= url_array[0] + "?pagetype=capitalstock&" + "compnumber="+compNumber;     	
	            	} else {
	            		var pagetype=loc.match(/pagetype=[A-Za-z0-9]*&/);
	            		if(pagetype!=null)
	            			loc= url_array[0] + "?"+pagetype[0]+"compnumber="+compNumber;
	            		else
	            			loc= url_array[0] + "?compnumber="+compNumber;
	            	}
	            	
	            }
    		}
    	}

        window.location= loc;
    }
}
function validateinput()
{
    if (document.forms["login"].elements["username"].value== '' || document.forms["login"].elements["password"].value== '') {
        alert("You must enter a username and password");
        return false;
    }
    return true;
}

/* 
 * For My Mergent Tools & Company Analysis List - Start
 */
var mmtState="out";
var chkall=false;

$(document).ready(function(){
	/* for the use in 20M+ Private Company synopsis page */
//	if($("#country").val()!='USA'){
//		$("#state").hide().val('');		
//	}
	
	$("#country").change(function(){
		$.post('liveprivate20m.php', {country:$(this).val()}, function(data){
			if(data!=""){
				$("#state").replaceWith(data);
			}
		});
//		if($("#country").val()!='USA'){
//			$("#state").hide().val('');
//		}
//		else{
//			$("#state").show();		
//		}
	});
	
	$("#20MCompetitor").click(function(){
		var urlparam = getUrlVars();
		var url = window.location.protocol + '//' + window.location.host + window.location.pathname;
		url += '?dunsnumber20m='+urlparam["dunsnumber20m"];
		url += '&country='+$("#country").val();
		url += '&state='+$("#state").val();
		window.location.href = url;
	});
	/* for the use in 20M+ Private Company */
	
	$("#mergent_tools_link").live('click', function() {
		setMergentToolsInfo('');
		setMergentToolsAuto();
		return false;
	});
	
	$('#hide_detail').live('click', function(){        
		var obj = new Object();
		obj['callback'] = 'toggle_detail';

		$.ajax({
			async: false,
			type: "POST",
		   	url: "mergenttoolslive.php",
		   	data: obj,
		   	success:
			    function(t){
					window.location.reload(true)
				}
		});
    });		

	$('.mmt_list').live('click', function(){        
    	var element = $(this).attr('type');
    	if($(this).attr('src')=='/images/parent_maximise.gif'){
    		$(this).attr('src','/images/parent_minimise.gif');
    		$(element).fadeIn(250);
    	}
    	else{
    		$(this).attr('src','/images/parent_maximise.gif');
    		$(element).fadeOut(250);
    	}    	
    });

    $('.mmt_popup').live('click', function(){  	
    	url="mergenttools.php?mmttype="+$(this).attr('type');
    	openChildMaximized(url, 'Popup');
    	return false;
    });
    
    /**
     * for basic search & ownership search
     **/
    //20100727 - set addAnalysisList(company) to display options based on totalexecrecords in Executive Search Results
	//addAnalysisList($('#totalrecords').val(),'Company','analysislist');
    if(document.getElementById('p20mtotalrecords') != null){
    	addAnalysisList($('#p20mtotalrecords').val(),'P20MCompany','analysislist');
		if(document.getElementById('exanalysislist')!= null)
			document.getElementById('exanalysislist').style.visibility = "hidden";
    } 	
    else if(document.getElementById('totalexecrecords') != null){
		addAnalysisList($('#totalexecrecords').val(),'Company','analysislist');
		addAnalysisList($('#totalexecrecords').val(),'Executive','exanalysislist');
	}
	else{
		addAnalysisList($('#totalrecords').val(),'Company','analysislist');
		if(document.getElementById('exanalysislist')!= null)
			document.getElementById('exanalysislist').style.visibility = "hidden";			
	}
	
	$('#checkall').click(function() {
    	if (chkall==true){
    		chkall=false;
    	}
    	else{
    		chkall=true;
    	}
    	$("input:checkbox[name='chkopt[]']:enabled").attr('checked',chkall);
    	return false;
    });

    //Add company to Company Analysis List
    $('#analysislist, #exanalysislist').change(function(){
    	if($(this).val()=="chk"){
    		if(document.getElementById('p20mtotalrecords') != null){
    			getAnalysisList($(this).val(),0,'p20mcompanylist');
    		}
    		else if(document.getElementById('totalexecrecords') != null){
    			if(this.id=='analysislist'){
    				getAnalysisList($(this).val(),1,'companyanalysislist');
    			}
   				else{
    				getAnalysisList($(this).val(),0,'executivelist');
   				}
    		}
    		else{
				getAnalysisList($(this).val(),0,'companyanalysislist');
    		}
    		chkall=false;
    		$("input:checkbox[name='chkopt[]']").attr('checked',chkall);
    	}
    	else{
    		var sPath = window.location.pathname;
    		var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
    		var urlparam = getUrlVars();
    		urlparam["criteria"]= $("#criteria").val();
    		urlparam["sztype"]= this.id;
    		urlparam["opt"]= $(this).val();
    		if(sPage=='executivesearchresults.php'){
        		urlparam["action"]= "exec";
    		}
			$.ajax({
				async: false,
				type: 'POST',
			   	url: 'liveanalysislist.php',
			   	data: urlparam,
			   	success:
				    function(data){
		    			if(data=='not authorized')
			    			alert(data);
						else{
							updMergentTools("#mergent_tools");
						}
					}
			});    		    		
    	}
    	$('#'+this.id).val("-1");
    });	
    /**
     * for basic search & ownership search
     **/
    
    /**
     * for sorting basic search result
     */
    $('table.bodyline th.header').click(function(){
    	var sortcol = $('table.bodyline th.header').index(this)+1;
    	var sort = 'ASC';
    	if($(this).hasClass('headerSortDown'))
    		sort= 'DESC';
    	
    	var url= window.location.href;
		url = url.replace(/#excel/i,'');
    	if(url.match(/\&?sort\=[\d\w]*/i))
    		url = url.replace(/\&?sort\=[\d\w]*/i,'&sort='+sort);
    	else
    		url = url+'&sort='+sort;
    	
    	if(url.match(/\&?sortcol\=[\d\w]*/i))
    		url = url.replace(/\&?sortcol\=[\d\w]*/i,'&sortcol='+sortcol);    	
    	else
    		url = url+'&sortcol='+sortcol;
    	
    	window.location.href = url;
    });
    /**
     * for sorting basic search result
     */
    
    /**
     * Corporate Calendar
     */
    if($('#corpcalendar').length > 0){
	    $('#corpcalendar').datepicker({
			yearRange: "-30:+0",
	    	onSelect: function(dateText, inst) {
	    		var day= dateText.substr(3,2);
	    		var mth= dateText.substr(0,2);
	    		var yr= dateText.substr(6);
	    		
	    		url="companycalendar.php?ctype=day&day="+day+"&mth="+mth+"&yr="+yr;
	    		openChildMaximized(url,'corporatecalendar');
	    	}
	    });
    }
});

/**
 * for paging basic search result
 */
function onPageKeyUp(page, event){	
	if(event.keyCode==13){
		if(page.match(/[^0-9]/i)){
			alert('invalid page number');
		}
		else{
			var url= window.location.href;
			url = url.replace(/#excel/i,'');
			if(url.match(/\&?page\=[0-9]*/i))
				url = url.replace(/\&?page\=[0-9]*/i,'&page='+page);
			else
				url = url+'&page='+page;
			window.location.href = url;
		}
	}	
	
}

function setMergentToolsAuto(){
	var timer = setTimeout('setMergentToolsInfo(\'in\')', 2000);
	$('#mergent_tools_info').mouseout(function() {
		timer = setTimeout('setMergentToolsInfo(\'in\')', 2000);
	}).mouseover(function() {
		clearTimeout(timer);
	});
}

/*
 * set the fade in and fade out function for Mergent Tools
 */
function setMergentToolsInfo(state){
	if(state!="")
		mmtState=state;
	if(mmtState=="in"){
		$('#toggleImg').attr('src','/images/parent_maximise.gif');
		$("#mergent_tools_info").fadeOut(250);
		$("#mergent_tools_table_div").hide().removeClass("absolute");
		mmtState="out";
	}
	else{
		$('#toggleImg').attr('src','/images/parent_minimise.gif');
		$("#mergent_tools_table_div").show().addClass("absolute");
		$("#mergent_tools_info").fadeIn(250);
		mmtState="in";
	}
	
    $('.mmt_list').each(function(){        
    	var element = $(this).attr('type');
		$(this).attr('src','/images/parent_maximise.gif');
		$(element).fadeOut(250);
    });
}

/*
 * update session and get the latest value for Mergent Tools 
 */
function updMergentTools(element, session, value, open){
	var obj = new Object();
	if (typeof(session) != 'undefined' && typeof(value) != 'undefined') 
		obj[session] = value;
	obj['callback'] = 'getTools';	
	
	open = typeof(open) != 'undefined' ? open : true;
	
	if(open)
		$(element).load("mergenttoolslive.php", obj, function(){
//			window.scrollTo(0, scrollToDiv("linkrow"));
			setMergentToolsInfo('out');
			setMergentToolsAuto();
		});
	else
		$(element).load("mergenttoolslive.php", obj);
	
	//09Apr2010 Margaret - moved code from addToAnalysisList function, make sure
	//	box is always updated when user updates the company analysis list in 
	//	MMT page
	//30Mar2010 Margaret - user add current company into company analysis list
	//	if current page is comparison report >> 'compare company against custom group (CAL)'
	//  then reload company list box. 
	var urlparam = getUrlVars();
	if (typeof urlparam['pagetype'] != 'undefined' && typeof(urlparam["win"]) != 'undefined') {
		var win = urlparam["win"];
		if (urlparam["pagetype"] == "comparisonreport"){
			win = win.replace("#","");
			if (win == 'compvscal'){
				var target, obj = new Object();
				target = '#comparisoncompanycol1';
				obj['callback'] = 'getCAListBoxForComparison';
				
				getLoading(target);
				$(target).load('mergenttoolslive.php', obj, function() {});
			}
		}
	}
}

/*
 * Used to generate the option for Company Analysis List 
 */
function addAnalysisList(counter, type, element){
	var limit = 100;
	var mycombo = $('#'+element);

	if(type=="P20MCompany"){
		var singular= "20M+ Private Company";
		var plural= "20M+ Private Companies";
		var desc= "";
	}
	else if(type=="Company"){
		var singular= "Company";
		var plural= "Companies";
		var desc= " Analysis";
	}
	else{
		var singular= "Executive";
		var plural= "Executives";
		var desc= "";
	}
	
	mycombo.empty();
	mycombo.append($('<option></option>').val("-1").html(singular+desc+" List (500 limit)"));
	if(counter==1){
		mycombo.append($('<option></option>').val("0").html("Add "+singular));		
	}
	else if(counter>=1){
		mycombo.append($('<option></option>').val("chk").html("Add Currently Selected "+plural));
		mycombo.append($('<option></option>').val("all").html("Add All "+plural));
		if(counter > limit){
			var start=1;
			var value=0;
			do {
				var end = (start+limit-1);
				if((counter-end) < 0){
					mycombo.append($('<option></option>').val(value).html("Add "+singular+" "+start+" to "+counter));
				}
				else{
					mycombo.append($('<option></option>').val(value).html("Add "+singular+" "+start+" to "+end));
				}			
				start += limit;
				value += 1;
			} while((counter-end) > 0);
		}
	}
}

/*
 * get Company Analysis List value and update into session 
 */
function getAnalysisList(opt, index, session){
	var limit = 100;
	var list = "";
	
	if(opt!="-1"){
		if(opt=="chk"){
			var filter = new Array();			
			$('input[name="chkopt[]"]').each( function() {				
				if($(this).attr('checked')){
					if(index==0){
						list += $(this).val()+"|";				
					}
					else{
						var item=$(this).val().split(":");
						var valid=1;
						for(var i=0; i<filter.length; i++){
							if(filter[i]==item[index]){
								valid=0;
								break;
							}
						}
						if(valid){
							list += item[index]+"|";
							filter[filter.length]=item[index];
						}
					}
					var valid=1;
					for(var i=0; i<filter.length; i++){
						if(filter[i]==list){
							
							break;
						}
					}
					if(valid){
						filter[filter.length]= list;
					}
				}
			});
		}
		else{
			var cnt = 1;
			if(opt!="all"){
				var start = opt * limit + 1; 
				var end = opt * limit + limit;
			}
			$("input:checkbox[name='chkopt[]']", oTable.fnGetFilteredNodes()).each( function() {
				var add = "1";
				if(opt!="all")
					if(cnt < start || cnt > end)
						add="0";
				if(add=="1")
					list += $(this).val()+"|";
				cnt++;
			});			
		}
		if(list.length>0){
			updMergentTools("#mergent_tools", "sa_"+session, list);
		}
	}
}

function addToAnalysisList(compnumber,type){
	compnumber += "|";
	if (typeof(type) == 'undefined') {
		type = "companyanalysislist"
	}
	updMergentTools('#mergent_tools','sa_'+type, compnumber);
	
	return false;
}
/*
 * For My Mergent Tools & Company Analysis List - End
 */
 
function openChildMaximized(url,name){
 	w=800;
	h=600;
	if (window.screen) { 
		w = window.screen.availWidth; 
		h = window.screen.availHeight; 
	} 
    attributes = "scrollbars=yes,toolbar=no,directories=no,resizable=yes,location=no,top=0,left=0,width="+w+",height="+h;
  
    // retain a pointer to the window as a global, and close it before opening it again
    if (navigator.userAgent.indexOf("Chrome/") > 0) {
	    if (window.detwin) {
	        window.detwin.close();
	        window.detwin = null;
	    }
	}
	window.detwin = window.open(url,name,attributes);
	window.detwin.focus();

    return window.detwin;
}

function getLoading(element) {
	$(element).html("<div class='loading'><img src='/images/loading.gif'><br>Loading...</div>");
}

/**
 * get url variables and return them in an associative array
 * @return associative array
 */
function getUrlVars(url) {
	if (typeof url == "undefined") {
		url = window.location.href;
	}
	
	// Add on 11/26/2010 by dennis
	// to decode the %2C to , for use in add company to company list bug
	// happend when user use , in the sic search e.g. 21,31
	var binVal, thisString;
	var myregexp = /(%2C)/;
	while ((match = myregexp.exec(url)) != null && match.length > 1 && match[1] != '') {
		binVal = parseInt(match[1].substr(1),16);
		thisString = String.fromCharCode(binVal);
		url = url.replace(match[1], thisString);
	}	
	
	var map = {};
	var parts = url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
		map[key] = decodeURI(value.replace(/\+/g,  " "));
	});
	
	return map;
}
/**
 * 
 */

function schKeyDown(event,txt,div){
	var otable = $('#'+div+' table.livesearchresult');
	var orow= $("TR",otable);
	var found=0;
	var idx=0;
	var max=0;
	
	if(event.keyCode==13){
		orow.each(function(){
			if($(this).children("TD").length == 3){
				if($(this).hasClass("active")){
					window.location.href= $(this).children("TD").eq(2).children("A").attr('href');
				}
			}
		});
	}
	else{
		orow.each(function(){
			if($(this).children("TD").length == 3){
				max++;
			}
		});
		max = max-1;
		orow.each(function(){
			if($(this).children("TD").length == 3){
				if($(this).hasClass("active")){
					found=1;
					return false;
				}
				idx++;
			}
		});
		if(found==0){
			if(max>=0){
				idx=0;
				$("TR:eq("+idx+")",otable).addClass("active");
				$("TR:eq("+idx+") TD",otable).addClass("active");
			}
		}
		else{
			if(idx>max)
				idx=max;
			if((idx==0 && event.keyCode==38) || idx==max && event.keyCode==40){
				$("TR:eq("+idx+")",otable).removeClass("active").addClass("active");
				$("TR:eq("+idx+") TD",otable).removeClass("active").addClass("active");
			}
			else{
				if(event.keyCode==38){
					//orow.eq(idx).removeClass("active").pre
					$("TR:eq("+idx+") TD",otable).removeClass("active");
					$("TR:eq("+idx+")",otable).removeClass("active").prev().addClass("active").children("TD").addClass("active");
					idx--;
				}
				else{
					$("TR:eq("+idx+") TD",otable).removeClass("active");
					$("TR:eq("+idx+")",otable).removeClass("active").next().addClass("active").children("TD").addClass("active");
					idx++;
				}
			}
		}
		searchtxt=$("TR:eq("+idx+")",otable).children("TD").eq(2).children("A").eq(0).html();
		if(searchtxt!=null){
			$('#'+txt).val(searchtxt.replace(/<strong>/ig, "").replace(/<\/strong>/ig, "").replace(/&amp;/ig,"&"));
		}
	}
}

function selectCountryProfile(element, validate) {
	var countrycode = element.options[element.selectedIndex].value;
	if (countrycode != "NA")
		openCountryProfile(countrycode, 0)
	else {
		if (validate)
			alert('Please select a country');
	} 
}

function openCountryProfile(countrycode, compnumber) {
	window.location.href = "documents.php?pagetype=countryprofile&compnumber="+compnumber+"&country="+countrycode;
}

function popHelpWindow(windowpage,windowname) 
{
	windowFeatures = "top=0,left=0,resizable=yes,width="+(screen.width)+",height="+(screen.height)+",scrollbars=yes,status=no,menubar=no"; 
	newWindow=window.open(windowpage,windowname,windowFeatures)
	newWindow.focus(); 
}

function scrollToDiv(elementId){	
    var obj = document.getElementById(elementId);
    var offset = 0;
    while(obj.offsetParent) {
    	offset += obj.offsetTop;
    	obj = obj.offsetParent;
    }
    return(offset);
}

function endUserAdminLink(validated,role) 
{
	//Three cases:
	//They are not logged in. - Bring up the logon box.
	//They are logged in but not as an account administrator. - Warn the User and then jump to the loggon box.
	//They are logged in as an account administrator. - go to the page.
	if (validated) {
		if (role >= 2) {
			window.location = "useradmin.php?page=projecttracking";
		} else {
			var success = confirm("You must be logged on as an End-User Administrator to access the administration area. Do you want to re-logon?");
			if(success == true) {
				window.location = "default.php?LogIn=Logout&admin=1";
			}
		}
	} else {
		window.location = "login.php";
	}
}
