var DragDrop = true;
var img = null;
var X = null;
var Y = null;
var MU_Pos_X = null;
var tempX = null;
var MU_Pos_Y = null;
var tempY = null;

N = (document.all) ? 0 : 1;

function GetMosaic(page)
{
	var windowOptions = 'location=no';
	windowOptions    += ',toolbar=no';
	windowOptions    += ',menubar=no';
	windowOptions    += ',status=no';
	windowOptions    += ',personalbar=no';
	windowOptions    += ',scrollbars=no';
	windowOptions    += ',resizable=no';
	windowOptions    += ',copyhistory=no';
	windowOptions    += ',top=0';
	windowOptions    += ',left=0';
	windowOptions    += ',width=' + 1000;
	windowOptions    += ',height=' + 670;
	var hWin = window.open(page, '', windowOptions);
	
	if (!hWin)
	{
		alert('You have popup blocking enabled which prevents our site from working properly. ' +
			  'Please place our site in your popup blocking whitelist.');
	}
}

function GetMosaicPage(page)
{
	var windowOptions = 'location=no';
	windowOptions    += ',toolbar=no';
	windowOptions    += ',menubar=no';
	windowOptions    += ',status=no';
	windowOptions    += ',personalbar=no';
	windowOptions    += ',scrollbars=no';
	windowOptions    += ',resizable=no';
	windowOptions    += ',copyhistory=no';
	windowOptions    += ',top=0';
	windowOptions    += ',left=0';
	windowOptions    += ',width=' + 960;
	windowOptions    += ',height=' + 670;
	var hWin = window.open(page, '', windowOptions);
	
	if (!hWin)
	{
		alert('You have popup blocking enabled which prevents our site from working properly. ' +
			  'Please place our site in your popup blocking whitelist.');
	}
}


if (N) 
{	
	var offsetx = 0;
	var offsety =  20;
}
else
{
	var offsetx = -2;
	var offsety =  18;
}
function NewDiv(newid)
{ 
    if(document.createElement)
    { 
        var el = document.createElement('div'); 
        el.id = newid;     
        with(el.style)
        { 
            display = 'none';
            position = 'absolute';
        } 
        el.innerHTML = '&nbsp;'; 
        document.body.appendChild(el); 
    } 
} 

var display_desc = null;
function GetMousePosition(e)
{
    mousex = (!N) ? event.x : (N) ? clientX = e.clientX : false;
    mousey = (!N) ? event.y : (N) ? clientY = e.clientY : false;
    display_desc = document.getElementById('tooltip');
    display_desc.style.left = (mousex + offsetx) + 'px';
    display_desc.style.top = (mousey + offsety) + 'px';
}

function ShowDesc(tip)
{
    if(!document.getElementById('tooltip')) NewDiv('tooltip');
    display_desc = document.getElementById('tooltip');
    display_desc.innerHTML = tip;
    display_desc.style.display = 'block';
    document.onmousemove = GetMousePosition;
}

function HideDesc(m_move)
{
    display_desc.style.display = 'none';
    if(!m_move) document.onmousemove = MM;
}


function LoadPage(action)
{
	if (action == 'New') 
	{
		timer = -1;
		StartTimer();
		document.getElementById('cmdPause').disabled = false;
		document.getElementById('cmdPause').className = 'button_light';
		document.getElementById('cmdContinue').disabled = true;
		document.getElementById('cmdContinue').className = 'button_light_disabled';
	}
	else
	{
		document.getElementById('divTimer').innerHTML = '00:00:00';
		document.getElementById('cmdPause').disabled = true;
		document.getElementById('cmdPause').className = 'button_light_disabled';
		document.getElementById('cmdContinue').disabled = true;
		document.getElementById('cmdContinue').className = 'button_light_disabled';	
	}	
		
	//document.getElementById('Banners').checked = true;
	//document.getElementById('Banners').value = 'ON';
	document.oncontextmenu = function(){return false;};	
}

function ResizeWindow()
{
	window.resizeTo(1022, 735);	
}


function BannersOff(chk)
{
	for (i = 0; i < document.all.imgB.length; i ++)
	{
		var tempSrc = document.all.imgB[i].src
		document.all.imgB[i].src = document.all.imgB[i].lowsrc;
		document.all.imgB[i].lowsrc = tempSrc;
		if (chk.checked)
			document.all.imgB[i].alt = '';
		else
			document.all.imgB[i].alt = document.all.imgB[i].id;
	}	
	
	if (chk.checked)
	{
		document.getElementById('divBannersOff').innerHTML = 'Banners ON';
		if (document.all.img_468_60) document.all.img_468_60.style.visibility = 'visible';
		if (document.all.img_120_600) document.all.img_120_600.style.visibility = 'visible';
	}
	else
	{
		document.getElementById('divBannersOff').innerHTML = 'Banners OFF';
		if (document.all.img_468_60) document.all.img_468_60.style.visibility = 'hidden';
		if (document.all.img_120_600) document.all.img_120_600.style.visibility = 'hidden';
	}
}


var timer = null;
var TimerID = null;
function StartTimer() 
{	
	DragDrop = true;
	TimerID = setTimeout('StartTimer(timer)', 1000);
	timer += 1;	
	ConvertTime(timer);
}


function StopTimer()
{
	DragDrop = false;
	clearTimeout(TimerID);
	ConvertTime(timer);	
}

function ConvertTime(t)
{
	timer = t;
	var s = t % 60;			
	var h = Math.floor(t / 60 / 60);	
	var m = (t - s - h * 60 * 60) / 60;

	if (String(s).length == 1) s = '0' + s;
	if (String(m).length == 1) m = '0' + m;
	if (String(h).length == 1) h = '0' + h;
	document.getElementById('divTimer').innerHTML = h + ':' + m + ':' + s;   
}


function DisableButtons(btn)
{
	if (btn.id == 'cmdPause')
	{
		document.getElementById('cmdPause').style.color = '#969696';	
		document.getElementById('cmdPause').disabled = true;
		document.getElementById('cmdPause').className = 'button_light_disabled';
		document.getElementById('cmdContinue').style.color = '#4B4B4B';
		document.getElementById('cmdContinue').disabled = false;
		document.getElementById('cmdContinue').className = 'button_light';
	}
	else if (btn.id == 'cmdContinue')
	{
		document.getElementById('cmdPause').style.color = '#4B4B4B';
		document.getElementById('cmdPause').disabled = false;
		document.getElementById('cmdPause').className = 'button_light';
		document.getElementById('cmdContinue').style.color = '#969696';			
		document.getElementById('cmdContinue').disabled = true;
		document.getElementById('cmdContinue').className = 'button_light_disabled';
	}
}

/*
function ButtonOver(btn) 
{
	btn.style.color = '#000000';
}
function ButtonOut(btn) 
{
	btn.style.color = '#4B4B4B';
}
*/

function LTrim(str)
{
	return str.replace(/^\s*/, "")
}

function RTrim(str)
{
	return str.replace(/\s*$/, "");
}

function Trim(str)
{
	return RTrim(LTrim(str));
}

function ValidEMail(eMail)
{
	var objRegExp = /^[A-Z0-9]+([-._]?[A-Z0-9]+)*\@[A-Z0-9]+([.-]?[A-Z0-9]+)*\.[A-Z]{2,5}$/i;
	return objRegExp.test(eMail);
}
