//Global vars
var intImageWidth = 200;
var intImageHeight = 150;

//Function to trim a string   
function trim(string){

while(string.substr(0,1)==" ")

string = string.substring(1,string.length) ;

while(string.substr(string.length-1,1)==" ")

string = string.substring(0,string.length-2) ;

return string;

}


//Check emailsyntax for page
function checkEmailSyntax(email,errormessage,okmessage,naamgame)
{
	var str=trim(email);
	naamgame = trim(naamgame);
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	
	var blnTest = filter.test(str);
	
	if (blnTest)
	{
		if (naamgame == '')
		{
			blnTest = false;
		}
	}
	
	if (blnTest)
	{
		alert(okmessage);
		return true;
	}
	else
	{
		alert(errormessage);
		return false;
	}
}

//Onmouseover function
function fnOver(strText, strLocalImage ,strImageUrl, strTitle, objTd)
{
	var strImage = "";
	if (strLocalImage == '')
	{	
		strImage = "<img src=\"http://www.artviper.net/screenshots/screener.php?url=" + strImageUrl + "&q=20&h=" + intImageHeight + "&w=" + intImageWidth + "&sdx=640&sdy=480\" alt=\"artViper designstudio website thumbnail \"/>";
	}
	else
	{
		strImage = "<img src='" + strLocalImage + "' width='" + intImageWidth + "' height='" + intImageHeight + "' alt='' border='' />";
	}
	
	var strhtml = "<table class='popdisplay' border='0' cellspacing='4' cellpadding='4'>";
	strhtml += "<tr><td align='center'><b>" + strTitle + "</b></td></tr>";
	strhtml += "<tr><td align='center' height='160'>" + strImage + "</td></tr>";
	strhtml += "<tr><td height='20' class='normaltext' align='center' valign='top' style='padding-left:6px;'>" + strText + "&nbsp;</td></tr>";
	strhtml += "<tr><td height='20' >&nbsp;</td></tr>";
	strhtml += "</table>";
	
	
	ddrivetip(strhtml, 340);
	
	if (objTd)
	{
		objTd.style.background = '#e8d8b9';
		objTd.style.borderTop = '1px solid #bd7900';
		objTd.style.borderBottom = '1px solid #bd7900';
	}
}

//onmouseout function
function fnOut(objTd)
{
	hideddrivetip();
	
	if (objTd)
	{
		objTd.style.background = '#ffffff';
		objTd.style.borderTop = '1px solid #ffffff';
		objTd.style.borderBottom = '1px solid #ffffff';
	}
}

//Create a nocache string, or  a name for new windows
function noCache()
{
	var nc = new Date();
	nc = nc.toString();
	nc = nc.replace(/ /g,'');
	nc = nc.replace(/\+/g,'');
	nc = nc.replace(/:/g,'');
	
	return nc;
	
}

//onclick function
function fnClick(strUrl)
{
	var width = 800;
	var height = 600;
	var toolbar = 'yes';
	var resizable = 'yes';
	var personalbar = 'no';
	var locationbar = 'yes';
	var status = 'yes';
	var scrollbars='yes';
	var menubar = 'yes';
	
	var winleft = (screen.width - 800) / 2;
	var winUp = (screen.height - 600) / 2;
	winUp = winUp -40;	
	
	window.open(strUrl + '#gamecoll', noCache(), 'width='+width+',height='+height+',left='+winleft+',top='+winUp+',scrollbars='+scrollbars+',resizable='+resizable+',menubar='+menubar+',toolbar='+toolbar+',personalbar='+personalbar+',location='+locationbar+',status='+status+'');
}


/***********************************************
* Cool DHTML tooltip script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetfromcursorX=40 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="/images/merchantpage/arrow2.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="hidden"
else

//increase left margin when div is at the right of the screen
if (tipobj.style.left)
{
	var modleft = tipobj.style.left.replace('px','');
	tipobj.style.left = (modleft - 30) + 'px';
}


pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip


