/*############################################################*/
function openWindow(URL,width,height)
{
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height+",left = 50,top = 50');");
    return false;
}
/*############################################################*/
function checkMailForm(someName, someMail) {
	var name = document.getElementById(someName).value;
	var mail = document.getElementById(someMail).value;

	var str = "";
	if (name.length < 1) str = str + "Please enter your name!\n";
	if (mail.length > 0){
		var countMe = 0
		var theCharacter = ""
		for (var x = 0; x < mail.length; x++)	{
			theCharacter = mail.charAt(x)
			if (theCharacter == "@")	{
				countMe++
			}
		}
		if (countMe != 1) str = str + "Your e-mail is not valid! Please enter a valid email address!\n";
	}
	else {
		str = str + "Please enter your e-mail!\n";
	}
	if (str.length == 0){
		return true;
	}
	else {
		alert(str);
		return false;
	}
}

function IsNumeric(sText, accept) {
	var ValidChars = accept;
	var IsNumber=true;
	var Char;

	for (i = 0; i < sText.length && IsNumber == true; i++) {
		Char = sText.charAt(i);
		if (ValidChars.indexOf(Char) == -1) {
			IsNumber = false;
		}
	}
	return IsNumber;
}

function validateQty(frm, qty) {
	var myFrm = document.getElementById(frm);
	var myQty = document.getElementById(qty).value;
	if (!IsNumeric(myQty, '0123456789') || myQty.length == 0) {
		alert('Please enter a valid quantity!')
	}
	else {
		myFrm.submit();
	}
}
/*############################################################*/
var isMozilla;
var objDiv = null;
var originalDivHTML = "";
var DivID = "";
var over = false;

function buildDimmerDiv()
{
    document.write('<div id="dimmer" class="dimmer" style="width:'+ window.screen.width/1.1+ 'px;height:' + window.screen.height/1.5 +'px;"></div>');
}

function displayFloatingDiv(divId, title, width, height, left, top)
{
	DivID = divId;

	document.getElementById('dimmer').style.visibility = "visible";

    document.getElementById(divId).style.width = width + 'px';
    document.getElementById(divId).style.height = height + 'px';
    document.getElementById(divId).style.left = left + 'px';
    document.getElementById(divId).style.top = top + 'px';

	var addHeader;

	if (originalDivHTML == "")
	    originalDivHTML = document.getElementById(divId).innerHTML;

	addHeader = '<table style="width:' + width + 'px" class="floatingHeader">' +
	            '<tr><td ondblclick="void(0);" onmouseover="over=true;" onmouseout="over=false;" style="cursor:move;height:18px">' + title + '</td>' +
	            '<td style="width:18px" align="right"><a href="javascript:hiddenFloatingDiv(\'' + divId + '\');" style="color: #ffffff;">' +
	            'Close</a></td></tr></table>';

	document.getElementById(divId).innerHTML = addHeader + originalDivHTML;


	document.getElementById(divId).className = 'dimming';
	document.getElementById(divId).style.visibility = "visible";


}

function hiddenFloatingDiv(divId)
{
	document.getElementById(divId).innerHTML = originalDivHTML;
	document.getElementById(divId).style.visibility='hidden';
	document.getElementById('dimmer').style.visibility = 'hidden';

	DivID = "";
}

function MouseDown(e)
{
    if (over)
    {
        if (isMozilla) {
            objDiv = document.getElementById(DivID);
            X = e.layerX;
            Y = e.layerY;
            return false;
        }
        else {
            objDiv = document.getElementById(DivID);
            objDiv = objDiv.style;
            X = event.offsetX;
            Y = event.offsetY;
        }
    }
}

function MouseMove(e)
{
    if (objDiv) {
        if (isMozilla) {
            objDiv.style.top = (e.pageY-Y) + 'px';
            objDiv.style.left = (e.pageX-X) + 'px';
            return false;
        }
        else
        {
            objDiv.pixelLeft = event.clientX-X + document.body.scrollLeft;
            objDiv.pixelTop = event.clientY-Y + document.body.scrollTop;
            return false;
        }
    }
}

function MouseUp()
{
    objDiv = null;
}

function init()
{
    isMozilla = (document.all) ? 0 : 1;


    if (isMozilla)
    {
        document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
    }

    document.onmousedown = MouseDown;
    document.onmousemove = MouseMove;
    document.onmouseup = MouseUp;

	buildDimmerDiv();

}

init();

function displayWindow()
{
	var w, h, l, t;
	w = 300;
	h = 200;
	l = screen.width/2.5;
	t = screen.height/4;
	displayFloatingDiv('windowcontent', '&nbsp;', w, h, l, t);
	document.getElementById("nameM").focus();
	return false;
}

function checkTellForm() {
	var frm = document.getElementById('tellFrm');
	var name = document.getElementById('nameY').value;
	var mail = document.getElementById('addressY').value;
	var fname = document.getElementById('nameF').value;
	var fmail = document.getElementById('addressF').value;

	var str = "";
	if (name.length < 1) str = str + "Please enter your name!\n";
	if (mail.length > 0){
		var countMe = 0
		var theCharacter = ""
		for (var x = 0; x < mail.length; x++)	{
			theCharacter = mail.charAt(x)
			if (theCharacter == "@")	{
				countMe++
			}
		}
		if (countMe != 1) str = str + "Your e-mail is not valid! Please enter a valid email address!\n";
	}
	else {
		str = str + "Please enter your e-mail!\n";
	}
	if (fname.length < 1) str = str + "Please enter your friend's name!\n";
	if (fmail.length > 0){
		var countMe = 0
		var theCharacter = ""
		for (var x = 0; x < fmail.length; x++)	{
			theCharacter = fmail.charAt(x)
			if (theCharacter == "@")	{
				countMe++
			}
		}
		if (countMe != 1) str = str + "Your friend's e-mail is not valid! Please enter a valid email address!\n";
	}
	else {
		str = str + "Please enter your friend's e-mail!\n";
	}
	if (str.length == 0){
		return true;
	}
	else {
		alert(str);
		return false;
	}
}
/*############################################################*/