//	global stettings / objects / vars
var BRWSR, DOM, SCRRES
//########################################################################
//safe the data
function jWDIsDateOK(intDay,intMonth,intYear)
	{
	if(intMonth==2){
		if(0 == intYear % 4){
			if(29<intDay)
				return false;
		}
		else{
			if(28<intDay)
				return false;
		}
	}
	if(intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11){
		if(30<intDay){
			return false;
		}
		else if(31<intDay){
			return false;
		}
	}
	if(1>intDay)
		return false;
	if(1>intMonth)
		return false;
	if(1>intYear)
		return false;
	if(4>len(intYear))
		return false;
	if(12<intMonth)
		return false;
	return true;
}

//########################################################################
//safe the data
function jWDIsTimeOK(intHour,intMin)
	{
	if(intHour>23){
		return false;
	}
	if(intHour<0){
		return false;
	}
	if(intMin>59){
		return false;
	}
	if(intMin<0){
		return false;
	}
	return true;
}
//########################################################################
//save the data
function jWDIsDatePatternOK(strDate)
{
	var pattern,vals
	
	vals=new Array();

	//if (InterfaceDateDelimiter == '.')
	//{
		pattern=/^([0-9]{1,2})[ .]+([0-9]{1,2})[ .]+([0-9]{1,4})$/;	
	//}
	//else if (InterfaceDateDelimiter == '/')
	//{
	//	pattern=/^([0-9]{1,2})[ /]+([0-9]{1,2})[ /]+([0-9]{1,4})$/;	
	//}	
		  
	if(pattern.test(strDate))
	{
		pattern.exec(strDate);
		vals[0]=RegExp.$1;
		vals[1]=RegExp.$2;
		vals[2]=RegExp.$3;
		return vals;
	}
	return vals;
}

//########################################################################
//save the data
function jWDIsTimePatternOK(strTime)
	{
	var pattern,vals
	vals=new Array();
	pattern=/^([0-9]{1,2})[ :]+([0-9]{1,2})$/;
  
  if(pattern.test(strTime))
  	{
  	pattern.exec(strTime);
		vals[0]=RegExp.$1;
		vals[1]=RegExp.$2;
  	return vals;
  	}
  return vals;
	}


//########################################################################
//remove unwanted characters
//  function jWDReplaceChunk(str)
  function jWDInputField2JS(str)
    {
    var buf
    buf=str
    buf=buf.replace(/\n/g,"<br>")
    buf=buf.replace(/\r/g,"")
    buf=buf.replace(/\"/g,"\\\"")
    buf=buf.replace(/\'/g,"\\\'")
    return buf;
    }

//########################################################################
//remove unwanted characters
  function jWDJS2InputField(str)
    {
    var buf
    buf=str
    buf=buf.replace(/<br>/g,"\r\n")
    buf=buf.replace(/\\"/g,"\"")
    buf=buf.replace(/\\'/g,"\'")
    return buf;
    }

//########################################################################
//remove unwanted characters
  function jWDJS2DB(str)
    {
    var buf
    buf=str
    buf=buf.replace(/\\"/g,"\"")
    buf=buf.replace(/\\'/g,"\'")
    return buf;
    }

//########################################################################
//remove unwanted characters
  function jWDInputField2DB(str)
    {
    var buf
    buf=str
    buf=buf.replace(/\n/g,"<br>")
    return buf;
    }

//*****************************************************************************
// browser sniffing
function jWDBrowserSniffer()
	{
  this.ie4= document.all ? 1 : 0;
  this.ns4= document.layers ? 1 : 0;
  }

//*****************************************************************************
//	document object model sniffer

function jWDDomSniffer()
	{
  if( document.all)
  	{
    this.doc= 'document.all';
    this.sty= '.style';
    this.htm= '';
    }
  else  if( document.layers)
  	{
    this.doc= 'document';
    this.sty= '';
    this.htm= '.document';
    }
  return this;
  }

//*****************************************************************************
//	Screen / Window Reslolution
function jWDResSniffer()
	{
  if( document.all)
  	{
    this.winWidth= document.body.clientWidth;
    this.winHeight= document.body.clientHeight;
    }
  else if( document.layers)
  	{
    this.winWidth= innerWidth;
    this.winHeight= innerHeight;
    }
  this.scrWidth= screen.width;
  this.scrHeight= screen.height;
  }

//*****************************************************************************
// image preloader
function jWDPreloadImages()
	{ 
  if (document.images)
		{
    var jWDImgFiles = jWDPreloadImages.arguments;
    if (document.jWDPreloadArray==null)
			{
			document.jWDPreloadArray = new Array();
			}
    var i = document.jWDPreloadArray.length;
 	  with (document)
		for (var j=0; j < jWDImgFiles.length; j++)
			{
 	    jWDPreloadArray[i] = new Image;
   	  jWDPreloadArray[i++].src = jWDImgFiles[j];
  		} 
		}
	}

//*****************************************************************************
// Swaps all necessary Images
// call: jSwapImg('layername','objectname','imagesrc', .....)
// where layername is the ID or the NAME
function jWDSwapImg()
	{
  var i,j=0,objStr,obj
	var swapArray=new Array
	var oldArray=document.jWDSwapImgData;
  for (i=0; i < (jWDSwapImg.arguments.length-2); i+=3)
		{
		if( document.layers)
			{
			objStr= 'document.layers[\'' + jWDSwapImg.arguments[i] + '\'].document.' + jWDSwapImg.arguments[i+1];
			}
		else
			{
			objStr= 'document.' + jWDSwapImg.arguments[i+1];
			}
    obj = eval(objStr);
    if (obj != null)
			{
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = jWDSwapImg.arguments[i+2];
			}
    }
  document.jWDSwapImgData = swapArray; //used for restore
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// restores all Images (onMouseOut)
// call: jSwapImgRestore
// parameters= none
function jWDSwapImgRestore()
	{
  if (document.jWDSwapImgData != null)
		{
    for (var i=0; i< (document.jWDSwapImgData.length-1); i+=2)
			{
      document.jWDSwapImgData[i].src = document.jWDSwapImgData[i+1];
			}
		}
	}

//*****************************************************************************
// body on load functions
function jWDBodyPreInit()
	{
  SCRRES= new jWDResSniffer();
  }

//*****************************************************************************
// body on load functions
function jWDBodyPostInit()
	{
  }

//*****************************************************************************
//	standard Object
function jWDObject(ID)
	{
	//	properties
  this.ie4= document.all ? 1 : 0;
  this.elemid= ID;
  this.element= this.ie4 ? document.all[ID].style : document[ID];
  this.form= null;
  this.xpos= jObjLeft;
  this.ypos= jObjTop;
  this.width= jObjWidth;
  this.height= jObjHeight;
  this.timer= null;
  this.path= null;
  this.active= 0;
  this.num= 0;
  this.growing= 0;
  this.growtimenr= null;
  this.growpath= null;
  this.grownum= 0;  
  this.cleft= 0;
  this.cright= 0;
  this.ctop= 0;
  this.cbottom= 0;
	this.statement= new Array();
	this.name= ID + "Var";
	eval( this.name + " = this");

  //	methods
  this.setform= jFormAdd;
  this.addstatement= jStmntPush;
  this.popstatement= jStmntPop;
  this.zIndex=jObjZIndex;
  this.hide= jObjHide;
  this.show= jObjShow;
  this.moveto= jObjMoveTo;
  this.moveby= jObjMoveBy;
  this.slideto= jObjSlideTo;
  this.slideby= jObjSlideBy;
  this.growto= jLayerGrowTo;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//	internal use only
  this.grower= jLayerGrower;
  this.grow= jGrowStep;
  this.animate= jObjAnimator;
  this.step= jObjStep;
  }

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jObjLeft()
	{
	return (this.ie4) ? this.element.pixelLeft : this.element.left;
  }

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jObjTop()
	{
	return (this.ie4) ? this.element.pixelTop : this.element.top;
  }

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jObjWidth()
  {
	return (this.ie4) ? this.element.pixelWidth : this.element.clip.width;
  }

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jObjHeight()
  {
  return (this.ie4) ? this.element.pixelHeight : this.element.clip.height;
  }

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jFormAdd( name)
	{
  this.form= this.ie4 ? eval('document.'+name) : eval('document.'+this.elemid+'.document.'+name);
  }

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jStmntPush( stmnt)
	{
  var pos= this.statement.length;
  this.statement[pos]= stmnt;
  }

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jStmntPop()
	{
  var buf, len, val;
  len = this.statement.length;
  if( 0 != len)
  	{
    val= this.statement[len-1];
    buf= this.statement.slice(0, len-1);
    this.statement= buf;
    return val;
    }
  else
  	return "";
  }


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jObjZIndex(pos)
	{
  this.element.zIndex= pos;
  }

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jObjHide()
	{
  this.element.visibility= 'hidden';
  }

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jObjShow()
	{
  this.element.visibility= 'visible';
  }
  
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jObjMoveTo( xPos, yPos)
	{
  if( this.ie4)
  	{
	  this.element.pixelLeft= xPos;
  	this.element.pixelTop= yPos;
    }
  else
  	{
	  this.element.left= xPos;
  	this.element.top= yPos;
    }
  }

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jObjMoveBy( xDelta, yDelta)
	{
  if( this.ie4)
  	{
	  this.element.pixelLeft= this.xpos() + xDelta;
  	this.element.pixelTop= this.ypos() + yDelta;
    }
  else
  	{
	  this.element.left= this.xpos() + xDelta;
  	this.element.top= this.ypos() + yDelta;
    }
  }

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jObjSlideTo( xPos, yPos, steps, interval)
	{
	var sX= this.xpos();
	var sY= this.ypos();
	var dX= xPos - sX;
	var dY= yPos - sY;
	var stepX= dX / steps;
	var stepY= dY / steps;
	var stepArr= new Array();
  for( var i =0; i < steps-2; i++)
		{
		sX += stepX;
		sY += stepY;
		stepArr[i]= new jObjPos( sX, sY);
		}
  // slow down by half
	for( var i =steps-2; i < steps+2; i++)
		{
		sX += stepX/2;
		sY += stepY/2;
		stepArr[i]= new jObjPos( sX, sY);
		}
	this.path= stepArr;
	this.animate( interval);
	}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jObjSlideBy( xDelta, yDelta, steps, interval)
	{
	this.slideto( xDelta + this.xpos(), yDelta + this.ypos(), steps, interval);  
  }


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jLayerGrowTo( top, right, bottom, left, steps, interval)
	{
  if( this.ie4)
  	{
    var buf= this.element.clip.substring( 5, 100);
    vals= buf.split(' ');
    ctop= parseInt(vals[0]);
    cright= parseInt(vals[1]);
    cbottom= parseInt(vals[2]);
    cleft= parseInt(vals[3]);
    }
  else
  	{
    cleft= this.element.clip.left;
    cright= this.element.clip.right;
    ctop= this.element.clip.top;
    cbottom= this.element.clip.bottom;
    }

  var sX1= cleft;
  var sX2= cright;
  var sY1= ctop;
  var sY2= cbottom;
	var dX1= cleft - left;
  var dX2= right - cright;
	var dY1= ctop - top;
  var dY2= bottom - cbottom
	var stepX1= dX1 / steps;
	var stepX2= dX2 / steps;
	var stepY1= dY1 / steps;
	var stepY2= dY2 / steps;
	var stepArr= new Array();
  for( var i =0; i < steps-2; i++)
		{
		sX1 -= stepX1;
		sX2 += stepX2;
		sY1 -= stepY1;
		sY2 += stepY2;

		stepArr[i]= new jLaySize( sX1, sX2, sY1, sY2);
		}
  // slow down by half
	for( var i =steps-2; i < steps+2; i++)
		{
		sX1 -= stepX1/2;
		sX2 += stepX2/2;
		sY1 -= stepY1/2;
		sY2 += stepY2/2;
		stepArr[i]= new jLaySize( sX1, sX2, sY1, sY2);
		}
	this.growpath= stepArr;
	this.grower( interval);
  }

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jLayerGrower( interval)
	{
  if( this.growing)
  	{
    return;
    }
  this.growing= 1;
  this.grownum= 0;
  this.growtimer= setInterval( this.name + '.grow()', interval);
  }

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jGrowStep()
	{
  var pos;
  var stmnt;
  if( this.ie4)
    {
    this.element.clip= 'rect(' + this.growpath[this.grownum].y1 + ' ' + this.growpath[this.grownum].x2 + ' ' + this.growpath[this.grownum].y2 + ' ' + this.growpath[this.grownum].x1 + ')';
    }
  else
    {
    this.element.clip.top= this.growpath[this.grownum].y1;
    this.element.clip.right= this.growpath[this.grownum].x2;
    this.element.clip.bottom= this.growpath[this.grownum].y2;
    this.element.clip.left= this.growpath[this.grownum].x1;
    }
	if( this.grownum >= this.growpath.length -1)
		{
		clearInterval( this.growtimer);
		this.growing=0;
    eval( this.popstatement())
		}
	else
		{
		this.grownum++;
		}
  }

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jLaySize( dX1, dX2, dY1, dY2)
	{
  this.x1= Math.round( dX1);
  this.x2= Math.round( dX2);
  this.y1= Math.round( dY1);
  this.y2= Math.round( dY2);
  }

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jObjAnimator( interval)
	{
	if( this.active)
		{
		return;
		}
	this.num= 0;
	this.active= 1;
	this.timer= setInterval( this.name + '.step()', interval);
  }

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jObjStep()
	{
	this.moveto( this.path[this.num].x, this.path[this.num].y);
	if( this.num >= this.path.length -1)
		{
		clearInterval( this.timer);
		this.active=0;
		eval( this.popstatement());
		}
	else
		{
		this.num++;
		}
	}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jObjPos( x, y)
	{
	this.x= Math.round( x);
	this.y= Math.round( y);
	}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function jWDDateCompare(fromDateDD,fromDateMM,fromDateYY,fromTimeHH,fromTimeMM,toDateDD,toDateMM,toDateYY,toTimeHH,toTimeMM)
{
if (parseInt(toDateYY,10) > parseInt(fromDateYY,10)) {
	return true; 	}
else {
	if (parseInt(toDateYY,10) < parseInt(fromDateYY,10)) {
		return false; 	}
	else {
		if (parseInt(toDateMM,10) > parseInt(fromDateMM,10)) {
			return true; }
		else {
			if (parseInt(toDateMM,10) < parseInt(fromDateMM,10)) {
				return false; }
			else {
				if (parseInt(toDateDD,10) > parseInt(fromDateDD,10)) {
					return true; }
				else {
					if (parseInt(toDateDD,10) < parseInt(fromDateDD,10)) {
						return false; }
					else {
						if (parseInt(toTimeHH,10) > parseInt(fromTimeHH,10)) {
							return true; }
						else {
							if (parseInt(toTimeHH,10) < parseInt(fromTimeHH,10)) {
								return false; }
							else {
								if (parseInt(toTimeMM,10) > parseInt(fromTimeMM,10)) {
									return true; }
								else {
									return false;	}
								}
							}
						}
					}
				}
			}
      		}
	}
return true;
}
//#########################################################################################################
function jWDCheckDateRange(fromDateYY,toDateYY)
{
	if (parseInt(toDateYY,10) > parseInt(9999,10)) {
		return false; 	}		
	if (parseInt(fromDateYY,10) < parseInt(1753,10)) {
			return false; 	}
	return true;	
}
//#########################################################################################################

//
// Create xmlhttp object
//
function jWDCreateXmlHttp() {
	var xmlhttp=false;

	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} 
	catch (e) {
		try {
	  	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  }
	  catch (E) {
	  	xmlhttp = false;
	  }
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		}
		catch (e) {
			xmlhttp=false;
		}
	}
	
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		}
		catch (e) {
			xmlhttp=false;
		}
	}
	
	return xmlhttp;
} // jWDCreateXmlHttp

//
// Fetch data and update fields
//
function jWDaddMovieStatistic(cid,intType) {
	
	var request = jWDCreateXmlHttp();	

	if(typeof request != 'object') {
		//alert("Unable to retrieve data\nBrowser does not support XMLHTTP");
		return;
	}
	
	// Send the request
	request.open("GET", "/inc/updateMovieStatistics.asp?CID=" + cid + "&Type=" + intType);
	
	request.send(null);
} // jWDaddMovieStatistic

function jWDZoomImage(parent) {
	
	var source = parent.firstChild.src;
	var options = 'location=no,menubar=no,resizable=yes,status=no,toolbar=no';
	
	// Get original image path
	source = source.replace(/\d{1,3}\-\d{1,3}/, "O");
	
	window.open(source, "_blank", options);
}


//when thumbnail button is clicked, swap photo
function swapPhoto(ID1,ID2,imgpath,imgtext) {
		window.document.images[ID1].src = imgpath;
		var parentID = null;
		if (document.layers) {
			var oLayer = (parentID)? eval('document.' + parentID + '.document.' + ID2 + '.document') : document.layers[ID2].document;
			oLayer.open();
			oLayer.write(imgtext);
			oLayer.close();
		}
		else if (document.all) document.all[ID2].innerHTML = imgtext
		else if (parseInt(navigator.appVersion)>=5&&navigator.appName=="Netscape") {
			document.getElementById(ID2).innerHTML = imgtext;
		}		
}


