function isEmailAddr(elem)
{
	var str = elem.value;
	var re = /[\w\-]+\@[\w\-]+\.\w{2,3}/;
	if (!str.match(re))
	{
		return false;
	}
	else
	{
		return true;
	}
}

function checkForm(formObj)
{
	var flag = 1;

	var nameRef = document.getElementById("name_text");
	var emailRef = document.getElementById("email_text");
	var companyRef = document.getElementById("company_text");
	
	
	if(!(formObj['name'].value.length))
	{
		nameRef.style.fontWeight = "bold";
		nameRef.style.color = "red";
		flag = 0;
	}
	if((!(formObj['email'].value.length))||(!isEmailAddr(formObj['email'])))
	{
		emailRef.style.fontWeight = "bold";
		emailRef.style.color = "red";
		flag = 0;
	}
	if(!(formObj['message'].value.length))
	{
		companyRef.style.fontWeight = "bold";
		companyRef.style.color = "red";
		flag = 0;
	}

	if(!flag)
	{
		alert('Please fill in the marked fields!');
		return false;
	}
	return true;
}

function new_window(pageUrl)
{
	LeftPosition = (screen.width) ? (screen.width-700)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-700)/2 : 0;
	var win = window.open(pageUrl,'Product','scrollbars,width=700,height=700,top='+TopPosition+',left='+LeftPosition);
	if(win) 
	{
		win.focus();
		if(document.all)
			document.all['popwarning'].style.display = "none";
		else
			document.getElementById("popwarning").style.display = "none";
	}
	else
	{
		if(document.all)
			document.all['popwarning'].style.display = "block";
		else
			document.getElementById("popwarning").style.display = "table-row";
	}
}


function promoPopup(pageUrl)
{
	LeftPosition = (screen.width) ? (screen.width-850)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-700)/2 : 0;
	var win = window.open(pageUrl,'Featuring','width=850,height=700,scrollbars=1,top='+TopPosition+',left='+LeftPosition);
	if(win) 
	{
		win.focus();
		if(document.all)
			document.all['popwarning'].style.display = "none";
		else
			document.getElementById("popwarning").style.display = "none";
	}
	else
	{
		if(document.all)
			document.all['popwarning'].style.display = "block";
		else
			document.getElementById("popwarning").style.display = "table-row";
	}
}

function popupParam(pageUrl,width,height)
{
	LeftPosition = (screen.width) ? ((screen.width >= width)?(screen.width-width)/2 : screen.width) : 0;
	TopPosition = (screen.height) ? ((screen.height >= height)?(screen.height-height)/2 : screen.width) : 0;
	var winWidth = ((screen.width >= width)? width : screen.width);
	var winHeight = ((screen.height >= height)? height : screen.height);
	var win = window.open(pageUrl,'Featuring','width='+winWidth+',height='+winHeight+',scrollbars=1,top='+TopPosition+',left='+LeftPosition);
	if(win) 
	{
		win.focus();
	}
}

function checkEULA() {
	if(EULABox = document.getElementById('licence')) {
		if(EULABox.checked) {
			return true;
		} else {
			alert('You must agree to the terms of the EULA in order to download the demo version.');
			return false;
		}
	} else {
		return false;
	}
}

//======================================================================================================


//======================================================================================================

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function getInnerWidth() {
	var x;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
	}
	return x;
}

function getInnerHeight() {
	var y;
	if (self.innerHeight) // all except Explorer
	{
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		y = document.body.clientHeight;
	}
	return y;
}

function initScroll () {
	//browser detection
	var tabRef = document.getElementById('productListTab');
	var ie5 = (document.getElementById && document.all); 
	var ns6 = (document.getElementById && !document.all); 
	var ua = navigator.userAgent.toLowerCase();
	var isapple = (ua.indexOf('applewebkit') != -1 ? 1 : 0);
	
	var iebody=(document.compatMode && document.compatMode != 'BackCompat') ? document.documentElement : document.body;
	
	//determining the scrolled amount
	var pagex = (isapple == 1 ? 0:(ie5)?iebody.scrollLeft:window.pageXOffset);
	var pagey = (isapple == 1 ? 0:(ie5)?iebody.scrollTop:window.pageYOffset);
	
	var y = findPosY(tabRef)-5;
	
	//getting inner frame dimensions
	
	var innerX = getInnerWidth();
	var innerY = getInnerHeight();
	
	//getting document dimensions
	
	var docX = (document.width)?document.width:document.body.offsetWidth;
	var docY = (document.height)?document.height:document.body.offsetHeight;
	docX -= 10;
	docY -= 10;
	
	
	//alert('docX:'+docX+';docY:'+docY);
	while((y > pagey)&&((pagey + innerY) < docY)) {
		window.scrollBy(0,2);
		pagey = (isapple == 1 ? 0:(ie5)?iebody.scrollTop:window.pageYOffset);
	}
}


function toggleProductList() {
	var listRef = document.getElementById('productListWrapper');
	var tabRef = document.getElementById('prodListTabImg');
	if(!Element.visible(listRef)) {
		tabRef.src = '../img/product_list_open.gif';
		Effect.BlindDown('productListWrapper');
		window.setTimeout('initScroll()',1500);
	} else {
		tabRef.src = '../img/product_list_closed.gif';
		Effect.BlindUp('productListWrapper');
	}
}

function toggleBlock(signID,blockID) {
	var signRef = document.getElementById(signID);
	var blockRef = document.getElementById(blockID);
	if(!Element.visible(blockRef)) {
		signRef.src = './img/butt_minus.gif';
		Effect.BlindDown(blockID);
	} else {
		signRef.src = './img/butt_plus.gif';
		Effect.BlindUp(blockID);
	}
}