var IE4 = (document.all) ? true : false;
var NS4 = (document.layers) ? true : false;
var ver4 = (IE4 || NS4) ? true : false;

function find_object(sID)
{
	if (document.getElementById)
	{
		return document.getElementById(sID);
	}
	else if (document.all)
	{
		return document.all[sID];
	}
	else if (document.layers)
	{
		return document.layers[sID];
	}
	else
	{
		return null;
	}
}

function show_hide(objname, vis, type)
{
    var obj = find_object(objname);
    if(!obj) return;
    if('visibility' == type)
        //alert(obj.style.visibility);
        obj.style.visibility = vis?'visible':'hidden';
    else
        obj.style.display = vis?'block':'none';
    
}

function openCalendar(frm, elm) {
	openWindow(base + '_server/blocks/calendar.asp?frm=' + frm + '&elm=' + elm, '_blank', 200, 170, 'status=no,toolbar=no,menubar=no,resizable=no,scrollbars=no');
}

function openScheduleCalendar(frm, elm, AssignedToID) {
	openWindow(basesub + 'support/schedcalendar.asp?frm=' + frm + '&elm=' + elm+ '&AssignedToID=' + AssignedToID, 'dlgScheduleCalendar' + AssignedToID, 200, 170, 'status=no,toolbar=no,menubar=no,resizable=no,scrollbars=no');
}


function browseLink(sURL) 
{
	var re;
	re = /~/g;
	
	sURL = sURL.replace('http|', 'http://');
	sURL = sURL.replace(re, '.');
	
	window.open(sURL, '_blank');
}

function ForgotPassword() 
{
	openDlg(basesub + 'getpass.asp', 'dlgForgot', 1, 390, 150); 
}

function Subscribe() 
{
	openDlg(basesub + 'subscribe1.asp', 'dlgSubscribe', 1, 390, 170); 
}
function TellAFriend() 
{
	var sURL;
	if (window.encodeURIComponent) 
     sURL = encodeURIComponent(document.location.href) 
    else if (window.escape) 
     sURL = escape(document.location.href);
	openDlg(basesub + 'tellafriend.asp?URL=' + sURL, 'dlgTellAFriend', 1, 410, 250); 
}

function openDlg(url, name, id, width, height) 
{
	if(isNaN(numID = parseInt(id, 10)))
		numID = id.substring(1, (id.length > 5)?5:id.length);
	openWindow(url, name + numID, width, height, "status=no,toolbar=no,resizable=yes,scrollbars=no,menubar=no");
}

function openWindow(url, name, width, height, features) {
	var win;
	var top = 0;
	var left = 0;
	
	if (screen.width > width) left = (screen.width - width) / 2;
	if (screen.height > height) top = (screen.height - height) / 2;
	
	if (typeof(features) == "undefined") win = window.open(url, name, 'left='+left+',top='+top+',screenX='+left+',screenY='+top+',width='+width+',height='+ height);
	else win = window.open(url, name, 'left='+left+',top='+top+',screenX='+left+',screenY='+top+',width='+width+',height='+ height +', ' + features);
		
	if (navigator.appName != 'Microsoft Internet Explorer')  { if ( window.focus )  win.focus()};
}

function closeWindow(reload, frmName) {
	if (reload == 'reload') 
		if (!top.opener.closed) {
				eval('frm = top.opener.document.' + frmName);
				if (frm) frm.submit();
			}
	
	top.close();
}

function checkSelection(objSelection){
	if (typeof(objSelection) != "undefined") {
		if(objSelection.length) {
			for(var i=0; i < objSelection.length; i++){
				if(objSelection[i].checked) {
					return true;
				}
			}
		}
		else {
			return (objSelection.checked);
		}
	}
	return false;
}

function validateEmail(strValue) {
	var objRegExp  =  /(^\w([\w\.\-\_]*)\@[\w\-\_]+\.([\w\-\_]+\.)*\w+$)/; 
	return objRegExp.test(strValue);
}

function getRandom() {
	return Math.random();
}

function getRandomDlgID() {
	return Math.round(getRandom() * 10000);
}

function QuickTourPRJ(){
	openDlg('http://www.aceflex.com/QuickTourPRJ/overview.htm', 'dlgQuickTourPRJ', '', 960, 560);
}

function QuickTourB2C(){
	openDlg('http://www.aceflex.com/QuickTourB2C/overview.htm', 'dlgQuickTourB2C', '', 960, 610);
}
