// --- Pure File Upload 3 -------------------------------------------------------
// Copyright 2006 (c) DMXzone
// Version: 3.0.8
// ------------------------------------------------------------------------------


function xmlhttpPost(strURL) {
	var refreshId = setInterval(function()
	{
		$("div#PublishStatus").load(strURL);
	}, 7500);
}


function validateForm(form, extensions, required)
{
	var allUploadsOK = true;
	document.MM_returnValue = false;
	for (var i = 0; i < form.elements.length; i++)
	{
		field = form.elements[i];
		if (!field.type || field.type.toLowerCase() != 'file') continue;
		var custom = false;
		for (var j = 3; j < arguments.length; j++)
		{
			if (field.name && field.name.toLowerCase() == arguments[j][0].toLowerCase())
			{
				validateFile(field, arguments[j][1], arguments[j][2]);
				custom = true;
			}
		}
		if (!custom) validateFile(field, extensions, required);
		if (!field.uploadOK)
		{
			allUploadsOK = false;
			break;
		}
	}
	if (allUploadsOK) document.MM_returnValue = true;
}

function validateFile(field, extensions, required)
{
	var fileName = field.value.replace(/"/gi, '');
	field.uploadOK = false;
	if (fileName == '' && required)
	{
		alert(getLang(PU3_ERR_REQUIRED));
		field.focus();
		return;
	}
	else if (extensions != '' && fileName != '')
	{
		if ( !FileNameOK(fileName) )
		{
			alert('Please use standard latin american characters in filename.\n_, a-z and 0-9 are accepted.');
			field.focus();
			field.uploadOK = false;
		}
		else 
		{
			// check extensions
			checkExtension(field, fileName, extensions);
		}		
	}
	else
	{
		field.uploadOK = true;
	}
}
/*** 16.01.2008 LSPZone and TZone Javascript Switcher for Products by Russ Biscardine ***/
function switchItems(strItem,strText,strURL)	{
	document.getElementById(strItem).innerHTML=strText;
	document.getElementById(strItem).onclick=strURL;

}
/*** END ***/

/***** ADDED ON 15.01.2008 *****/
function FileNameOK(fileName)
{				
	var re_fn = /^[A-Za-z0-9_\-\.\s]+$/;
	var indexOfPath = fileName.lastIndexOf('\\');
	var indexOfDot = fileName.lastIndexOf('\.');
	var fName = fileName.substring(indexOfPath+1,indexOfDot);
	
	return re_fn.test(fName);
}

function checkExtension(field, fileName, extensions)
{
	var re = new RegExp('\\.(' + extensions.replace(/,/gi, '|').replace(/\s/gi, '') + ')$', 'i');
	var agt = navigator.userAgent.toLowerCase();
	if (agt.indexOf("opera") != -1)
	{
		var ext = fileName.substr(fileName, lastIndexOf('.')+1);
		var extArr = extensions.split(',');
		var extCheck = false;
		for (var i = 0; i < extArr.length; i++)
		{
			if (extArr[i].toLowerCase() == ext.toLowerCase())
			{
				extCheck = true;
				break;
			}
		}
		if (!extCheck)
		{
			alert(getLang(PU3_ERR_EXTENSION,extensions));
			field.focus();
			field.uploadOK = false;
			return;
		}
	}
	else
	{
		if (!re.test(fileName))
		{
			alert(getLang(PU3_ERR_EXTENSION,extensions));
			field.focus();
			field.uploadOK = false;
			return;
		}
	}
	field.uploadOK = true;
}

function getLang(str) {
  var newStr = str;
  for (var ki=1; ki < arguments.length; ki++)
    newStr = newStr.replace("%"+ki,arguments[ki]);
  return newStr;  
}

function showProgressWindow(progressFile,popWidth,popHeight) {
  if (document.MM_returnValue) {
  	document.progressWindow = new progressPopup("UploadProgress",progressFile,popWidth,popHeight);
    window.onunload = function () {
      document.progressWindow.close();
    };
  }
}

// the Progress Popup Class
progressPopup = function(n,url,w,h){ // 1.0
	var hPopupWindowObject = this;
	var dragapproved=false;
	var drago;
	var d=dd=document;
    
    //test the browser
	var ie5=d.all&&d.getElementById;
	var ie5only = ie5 && navigator.userAgent.toLowerCase().indexOf( "msie 5" ) != -1;
	var ns6=d.getElementById&&!d.all;
	var ua=navigator.userAgent.toLowerCase();
	var op=(ua.search(/opera/i)!=-1);
	var op7=(ua.search(/opera[\/\s][7-9]/i)!=-1);
	var sf=(ua.search(/safari/i)!=-1);
	var win=(ua.indexOf('windows')!=-1);
	var mac=(ua.indexOf('mac')!=-1);

	var cw=(window.innerWidth ? window.innerWidth : (d.documentElement && typeof d.documentElement.offsetWidth != "undefined" ? d.documentElement.offsetWidth : -1));
	var ch=(window.innerHeight ? window.innerHeight : (d.documentElement && typeof d.documentElement.offsetHeight != "undefined" ? d.documentElement.offsetHeight : -1));
	var dt=parseInt((ch-h)/2), dl=parseInt((cw-w)/2);

	//fallback
	if ((!ie5&&!ns6)||(op&&!op7)||(ie5&&mac)) {
		return window.open(url,name,"width="+w+",height="+h+",scrollbars=0,top="+dt+",left="+dl);
	}


	dt += (ns6?pageYOffset:(d.documentElement?d.documentElement.scrollTop:d.body.clientTop));dl+=(ns6?pageXOffset:(d.documentElement?d.documentElement.scrollLeft:d.body.scrollLeft));	
	var nw = w + (ie5&&!op7?4:10);nh=h+(ie5&&!op7?30:36);
	
	var oldDoc = d.getElementById(n);
	if (oldDoc) {oldDoc.object.bringToFront(); return oldDoc.object;}
	
	var iframeMouseDownLeft;
	var iframeMouseDownTop;
	var pageMouseDownLeft;
	var pageMouseDownTop;
	
	this.dm0 = d.createElement("div");
	this.dm0.name = this.dm0.id = n;
	this.dm0.object = this;
	
	this.dm0.style.display = '';
	this.dm0.style.position = "absolute";	
	this.dm0.style.top = dt+"px";
	this.dm0.style.left = dl+"px";
	this.dm0.style.width=(nw+3)+"px";
	this.dm0.style.height=(nh+3)+"px";
	if (!ie5) this.dm0.style.background = "url(dmx_shadow.png) repeat bottom right";
	this.dm0.style.zIndex = ( progressPopup.nZIndexLast++ )
	
	this.bringToFront = function(){
		var db = d.body;
		if ( this.dm0.style.display=='none' ) this.dm0.style.display='';
		this.dm0.style.zIndex = ( progressPopup.nZIndexLast++ );
		this.di.style.zIndex = ( progressPopup.nZIndexLast++ );
	}	

	var dm = d.createElement("div");
	if( ie5 && win )
	{
		dm.style.background = "url(dmx_shadow.png) repeat bottom right";
		dm.style.filter = "progid:DXImageTransform.Microsoft.Blur(pixelradius=3,makeshadow=true,shadowopacity=.4)";
		dm.style.width = nw-5; 
		dm.style.height = nh-5;
	}

	//create window
	if (ie5&&!op) {
		if( ie5only )
		{
			var iframeHTML;
			iframeHTML='\<iframe id="mainiframe'+n+'" style="';
			iframeHTML+='border:0px;';
			iframeHTML+='width:0px;';
			iframeHTML+='height:0px;';
			iframeHTML+=' scrolling="no"';
			iframeHTML+=' marginwidth="0"';
			iframeHTML+=' marginheight="0"';
			iframeHTML+=' frameborder="0"';
			iframeHTML+='><\/iframe>';
			dm.innerHTML = iframeHTML;
		}
		else
		{
			this.dmf = (ie5? d.createElement('<IFRAME SRC="javascript:false">') : d.createElement("iframe"));
			this.dmf = d.createElement("iframe");
			this.dmf.src = "javascript:false";
			this.dmf.id = "mainiframe" + n;
			this.dmf.border = 0;
			this.dmf.frameborder = 0;
			this.dmf.scrolling = 'no';
			dm.appendChild(this.dmf);
		}

		this.dm0.appendChild(dm);
		d.body.appendChild(this.dm0);
		this.dmf = document.getElementById( 'mainiframe'+n );
		dd = this.dmf.contentWindow.document;

		dd.open( 'text/html', 'replace' );
		dd.write( '<html><head></head><body id="body'+Math.ceil( Math.random() * 10000 )+'" style="margin:0; padding: 0; overflow: hidden;" bottomMargin=0 leftMargin=0 topMargin=0 rightMargin=0 scroll=no>' + '</body></html>' );
		dd.close();

		this.dmf.style.display='';
	  	this.dmf.style.position = "relative";	
		this.dmf.style.top = "0px";
		this.dmf.style.left = "0px"; 
		this.dmf.style.width=(nw+6)+"px";
		this.dmf.style.height=(nh+3)+"px";
	}

	this.dw = dd.createElement("div");
	this.dw.object = this;

	this.dw.style.display="none";
	this.dw.style.border = (ie5?"4":"2")+"px outset " + (mac?"#C0C0C0":"#166AEE");
	this.dw.style.display = "block";
	this.dw.style.position = "relative";
	if (!ie5) {
		this.dw.style.margin = "-6px 6px 6px -6px"; 
		this.dw.style.MozBorderRadius="10px 10px 0px 0px";
	} 
	else {
		this.dw.style.margin = "0 0 0 0";
	}
	this.dw.style.width=(nw-(sf?10:(ns6?6:2))-(op7?-2:0)-(ie5?6:0))+"px";
	this.dw.style.height=(nh-(sf?13:(op7?9:(ns6?6:2))))+"px";

	// Generalized function to get position of an event (like mousedown, mousemove, etc)
	this.getEventPosition = function(evt) {
		var pos= { x:0, y:0 };
		var obj = drago; //this.object;
		if (!obj || !dragapproved) return;		
		if (!evt) var evt = window.event;
		if (ie5 && !evt) var evt = obj.dmf.contentWindow.event;		

		if (typeof(evt.pageX) == 'number') {
			pos.x = evt.pageX;
			pos.y = evt.pageY;
		}
		else {
			pos.x = evt.clientX;
			pos.y = evt.clientY;
			if (!top.opera) {
				if ((!window.document.compatMode) || (window.document.compatMode == 'BackCompat')) {
					pos.x += window.document.body.scrollLeft;
					pos.y += window.document.body.scrollTop;
				}
				else {
					pos.x += window.document.documentElement.scrollLeft;
					pos.y += window.document.documentElement.scrollTop;
				}
			}
		}
		return pos;
	}

	// Gets the page x, y coordinates of the iframe (or any object)
	this.getObjectXY = function(o) {
		if ( o ) 
		{
		    return { x : parseInt( o.style.left ), y : parseInt( o.style.top ) }
		}
		else
		{
		    return { x : 0, y : 0 }
		}
	}

	// Called when mouse moves in the main window
	this.mouseMove = function(evt) {
		var obj = drago; //this.object;
		if (!obj || !dragapproved) return;		
		if (!evt) var evt = window.event;
		if (ie5 && !evt) var evt = obj.dmf.contentWindow.event;
		var pos = obj.getEventPosition(evt);
		obj.drag( pos.x - pageMouseDownLeft, pos.y - pageMouseDownTop );
		pageMouseDownLeft = pos.x;
		pageMouseDownTop = pos.y;
	}

	// Called when mouse moves in the IFRAME window
	this.iframemove = function(evt) {
		var obj = drago; //this.object;
		if (!obj || !dragapproved) return;		
		if (!evt) var evt = window.event;
		if (ie5 && !evt) var evt = obj.dmf.contentWindow.event;
		var pos = obj.getEventPosition(evt);
		obj.drag( pos.x - iframeMouseDownLeft, pos.y - iframeMouseDownTop );
		pageMouseDownLeft += pos.x - iframeMouseDownLeft;
		pageMouseDownTop += pos.y - iframeMouseDownTop;
	}

	// Function which actually moves of the iframe object on the screen
	this.drag = function(x,y) {
		var o = this.getObjectXY(drago.dm0);
		var newPositionX = o.x-0+x;
		var newPositionY = o.y-0+y;
		drago.dm0.style.left = newPositionX + "px";
		drago.dm0.style.top  = newPositionY + "px";
	}

	this.dw.onmousedown = function(evt){ //initialize drag
		var obj = this.object;
		if (ie5 && !evt) var evt = obj.dmf.contentWindow.event;
		obj.bringToFront();

		dragapproved=true;
		drago=obj;

		var pos=obj.getEventPosition(evt);
		iframeMouseDownLeft = pos.x;
		iframeMouseDownTop = pos.y;
		var o = obj.getObjectXY(drago.dm0);
		if (ie5&&!op) {
			pageMouseDownLeft = o.x + pos.x - ( d.documentElement?d.documentElement.scrollLeft:d.body.scrollLeft );
			pageMouseDownTop = o.y + pos.y - ( d.documentElement?d.documentElement.scrollTop:d.body.clientTop );
		} else {
			pageMouseDownLeft = pos.x;
			pageMouseDownTop = pos.y;
		}
		obj.dw.onmousemove = obj.iframemove;
		d.onmousemove=obj.mouseMove;
		d.onmouseup=obj.dw.onmouseup;
	};

	this.dw.onmouseup = function(){ //stopdrag
		var obj = drago; //this.object;
		if ( !obj || !dragapproved ) return;
		dragapproved=false;
		drago=null;
		obj.dm0.onmousemove=null;
		d.onmousemove=null;
		d.onmouseup=null;
	}

	this.dw.onselectstart= function(){return false};

	var dt = dd.createElement("div");
	dt.align=( mac ? "left":"right" );
	if (ie5||sf) dt.style.height="19px";
	dt.style.backgroundColor = (mac?"#E3E3E3":"#0055E5");
	if (mac) dt.style.background = "url(dmx_bg_osx.png) repeat bottom right";
	dt.style.padding="2px";
	if (!ie5) {
		dt.style.paddingRight="4px";
		dt.style.MozBorderRadius="10px 10px 0px 0px";
	}
	else {
		dt.style.width = nw-(op7?10:0) + "px";
	}

	this.dtit = dd.createElement("div");
	this.dtit.style.height = "19px";
	this.dtit.style.width = ( nw-20 ) + "px";
	this.dtit.style.cursor = "default";
	this.dtit.style.textAlign = (win?"left":"center");
	this.dtit.style.fontFamily = "Tahoma";
	this.dtit.style.fontSize="12px";
	if (win) this.dtit.style.fontWeight="bold";
	this.dtit.style.color = (mac?"#000000":"#FFFFFF");
	this.dtit.style.paddingTop="3px";

	var dti = dd.createElement("img");

	dti.src = "./" + ( mac?"dmx_close_osx.png":"dmx_close.jpg" );
	dti.align=( mac?"left":"right" );

	dti.onclick = function()
	{
		hPopupWindowObject.close();
	}
	
	this.close = function()
	{
		if( hPopupWindowObject.dm0 )
		{
			hPopupWindowObject.dm0.style.display = 'none';
		}
		else if( this.dm0 )
		{
			this.dm0.style.display = 'none';
		}
	}
    
	dt.appendChild(dti);
	dt.appendChild(this.dtit);
	this.dw.appendChild(dt);
	var dc = dd.createElement("div");
	dc.style.backgroundColor="#FFFFFF";

	this.iloaded = function(evt) {
  		var ifm = (evt && evt.srcElement ? evt.srcElement : (this.object ? this.object.di : event.srcElement));
		var obj = ifm.object;
		var mfr = (ie5?document.getElementById("mainiframe"+ifm.object.dm0.id).contentWindow.document.getElementById("ciframe"):document.getElementById("ciframe"));
		if (mfr) {
			try{
				var title = (ie5?mfr.contentWindow.document.title:mfr.contentDocument.title);
				if (title && title.length > 0) {
					obj.dtit.innerHTML = title;
				}
			}
			catch( hException )
			{
				obj.dtit.innerHTML = "";
			}
		}
	}
	
	this.di = (ie5&&!op? dd.createElement('<IFRAME SRC="' + url + '">') : dd.createElement("iframe")); 
	this.di.object = this; 
	if (ie5) this.di.attachEvent('onload', this.iloaded );
	else this.di.onload=this.iloaded;
	//style it
	this.di.id="ciframe";
	this.di.marginheight="0";
	this.di.marginwidth="0";
	this.di.width=w+(op7?0:(ie5?4:0));
	this.di.height=h+(op7?0:(ie5?4:0));
	this.di.scrolling="no";
	this.di.frameborder="0";

	dc.appendChild(this.di);
	this.dw.appendChild(dc);

	if (ie5&&!op) {
		if( ie5only )
		{
			dd.body.innerHTML = '';
			dd.body.appendChild( this.dw );
		}
		else
		{
			this.dmf.appendChild(this.dw);
		}
	} else {
		dm.appendChild(this.dw);
		this.dm0.appendChild(dm);
		d.body.appendChild(this.dm0);
	}

	var hIFrame = this.di
	setTimeout( function()
				{
					hIFrame.src = url
				},200);	
				
}

progressPopup.nZIndexLast = 10000;



// --- EOF Pure File Upload 3 ---------------------------------------------------
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------



// BEGIN: Browser sniff

      isDOM = (document.getElementById) ? true : false;
       isNS = (navigator.appName.indexOf("Netscape")!=-1);
      isNS4 = (document.layers) ? true : false;
   isNS4old = (isNS4 && (parseFloat(navigator.appVersion) < 4.02));
      isNS6 = isNS&&isDOM;
       isIE = (document.all) ? true : false;
      isIE4 = isIE && !isDOM;
   isIE5or6 = isIE&&isDOM;
      isMac = (navigator.appVersion.indexOf("Mac") != -1);
     isIE4M = isIE4 && isMac;
    isOpera = (navigator.userAgent.indexOf("Opera")!=-1);
isKonqueror = (navigator.userAgent.indexOf("Konqueror")!=-1);

// END: Browser sniff

// BEGIN: Body onload utility - supports multiple onload functions
/*
Modified from: http://javascript.about.com/library/scripts/blsafeonload.htm
Call the following with your function as the argument
SafeAddOnload(yourfunctioname);
*/
var gSafeOnload = new Array();
function SafeAddOnload(f){
	if (isIE && isMac && isIE4) { // IE 4.5 blows out on testing window.onload
		window.onload = SafeOnload;
		gSafeOnload[gSafeOnload.length] = f;
	} else if (window.onload) {
		if (window.onload != SafeOnload){
			gSafeOnload[0] = window.onload;
			window.onload = SafeOnload;
		}
		gSafeOnload[gSafeOnload.length] = f;
	} else window.onload = f;
}
function SafeOnload() {
	for (var i=0;i<gSafeOnload.length;i++) gSafeOnload[i]();
}
// END: Body onload utility

// BEGIN: Scrollable Menu Links
/*
Scrollable Menu Links- By Dynamicdrive.com
For full source, TOS, and 100s DTHML scripts
Visit http://dynamicdrive.com
*/
var topNavWidth=400
var topNavScrollSpeed=6
var topNavActualWidth=''
var topNavNS, topNavLeftTimeout, topNavRightTimeout

function createTopNav(){
if (document.all){
topNavIE.innerHTML=topNavContents
topNavActualWidth=topNavIE.offsetWidth
if (topNavActualWidth > topNavWidth) document.getElementById("topNavArrows").style.visibility="visible";
}else if (document.layers){
topNavNS=document.topNavNSLayer.document.topNavNSLayer2
topNavNS.document.write(topNavContents)
topNavNS.document.close()
topNavActualWidth=topNavNS.document.width
}
}

function topNavMoveLeft(){
if (document.all&&topNavIE.style.pixelLeft>(topNavWidth-topNavActualWidth))
topNavIE.style.pixelLeft-=topNavScrollSpeed
else if (document.layers&&topNavNS.left>(topNavWidth-topNavActualWidth))
topNavNS.left-=topNavScrollSpeed
topNavLeftTimeout=setTimeout("topNavMoveLeft()",50)
}

function topNavMoveRight(){
if (document.all&&topNavIE.style.pixelLeft<0)
topNavIE.style.pixelLeft+=topNavScrollSpeed
else if (document.layers&&topNavNS.left<0)
topNavNS.left+=topNavScrollSpeed
topNavRightTimeout=setTimeout("topNavMoveRight()",50)
}
// END: Scrollable Menu Links

function isEmpty(str) {
	if (str.length == 0) return true;
	if (str.search(/\S/) == -1) return true;
	return false;
}

function isNumber(str,blnRequired) {
	if (isEmpty(str) && (blnRequired)) return false;
	else if ((str.length > 0)) {
		var strCharCode = "";	
		for (j=0;j<str.length;j++) {
			strCharCode = str.charCodeAt(j)
			if (!(strCharCode >= 44 && strCharCode <= 57)) return false;
		}
	}
	return true;
}

function isURL(str,blnRequired) {
	if (isEmpty(str) && (blnRequired)) return false;
	if (!isEmpty(str)) {
		if (str.search(" ") > -1) return false;
		if (str.search(/\./) == -1) return false;
		for(i=0;i<=str.length;i++) {
			if(str.charCodeAt(i) > 128) return false;
		}
	}
	return true;
}

function isEmail(str,blnRequired) {
	// This script and many more are available free online at
	// The JavaScript Source!! http://javascript.internet.com
	// V1.1.3: Sandeep V. Tamhankar (stamhankar@hotmail.com)
	// Modified by Tony Ruscoe (truscoe@sdlintl.com)

	/* If blnRequired = false then blank entries are allowed. */

	if (isEmpty(str) && (blnRequired)) return false;

	if (!isEmpty(str)) {

		/* The following variable tells the rest of the function whether or not
		to verify that the address ends in a two-letter country or well-known
		TLD.  1 means check it, 0 means don't. */
	
		var checkTLD=1;
	
		/* The following is the list of known TLDs that an e-mail address must end with. */
	
		var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	
		/* The following pattern is used to check if the entered e-mail address
		fits the user@domain format.  It also is used to separate the username
		from the domain. */
	
		var emailPat=/^(.+)@(.+)$/;
	
		/* The following string represents the pattern for matching all special
		characters.  We don't want to allow special characters in the address. 
		These characters include ( ) < > @ , ; : \ " . [ ] */
	
		var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	
		/* The following string represents the range of characters allowed in a 
		username or domainname.  It really states which chars aren't allowed.*/
	
		var validChars="\[^\\s" + specialChars + "\]";
	
		/* The following pattern applies if the "user" is a quoted string (in
		which case, there are no rules about which characters are allowed
		and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
		is a legal e-mail address. */
	
		var quotedUser="(\"[^\"]*\")";
	
		/* The following pattern applies for domains that are IP addresses,
		rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
		e-mail address. NOTE: The square brackets are required. */
	
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	
		/* The following string represents an atom (basically a series of non-special characters.) */
	
		var atom=validChars + '+';
	
		/* The following string represents one word in the typical username.
		For example, in john.doe@somewhere.com, john and doe are words.
		Basically, a word is either an atom or quoted string. */
	
		var word="(" + atom + "|" + quotedUser + ")";
	
		// The following pattern describes the structure of the user
	
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	
		/* The following pattern describes the structure of a normal symbolic
		domain, as opposed to ipDomainPat, shown above. */
	
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	
		/* Finally, let's start trying to figure out if the supplied address is valid. */
	
		/* Begin with the coarse pattern to simply break up user@domain into
		different pieces that are easy to analyze. */
	
		var matchArray=str.match(emailPat);
	
		if (matchArray==null) {
	
		/* Too many/few @'s or something; basically, this address doesn't
		even fit the general mould of a valid e-mail address. */
	
			//alert("Email address seems incorrect (check @ and .'s)");
			return false;
		}
		var user=matchArray[1];
		var domain=matchArray[2];
	
		// Start by checking that only basic ASCII characters are in the strings (0-127).
	
		for (i=0; i<user.length; i++) {
			if (user.charCodeAt(i)>127) {
				//alert("The username contains invalid characters.");
				return false;
	   		}
		}
		for (i=0; i<domain.length; i++) {
			if (domain.charCodeAt(i)>127) {
				//alert("The domain name contains invalid characters.");
				return false;
			}
		}
	
		// See if "user" is valid 
	
		if (user.match(userPat)==null) {
	
		// user is not valid
	
			//alert("The username doesn't seem to be valid.");
			return false;
		}
	
		/* if the e-mail address is at an IP address (as opposed to a symbolic
		host name) make sure the IP address is valid. */
	
		var IPArray=domain.match(ipDomainPat);
		if (IPArray!=null) {
	
		// this is an IP address
	
			for (var i=1;i<=4;i++) {
				if (IPArray[i]>255) {
					//alert("Destination IP address is invalid!");
					return false;
				}
			}
			return true;
		}
	
		// Domain is symbolic name.  Check if it's valid.
	 
		var atomPat=new RegExp("^" + atom + "$");
		var domArr=domain.split(".");
		var len=domArr.length;
		for (i=0;i<len;i++) {
			if (domArr[i].search(atomPat)==-1) {
				//alert("The domain name does not seem to be valid.");
				return false;
			}
		}
	
		/* domain name seems valid, but now make sure that it ends in a
		known top-level domain (like com, edu, gov) or a two-letter word,
		representing country (uk, nl), and that there's a hostname preceding 
		the domain or country. */
	
		if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) {
			//alert("The address must end in a well-known domain or two letter " + "country.");
			return false;
		}
	
		// Make sure there's a host name preceding the domain.
	
		if (len<2) {
			//alert("This address is missing a hostname!");
			return false;
		}
	}
	// If we've gotten this far, everything's valid!
	return true;
}

function isDate(str,blnRequired,UKUS,bln4DigitYear) {
	if (isEmpty(str) && (blnRequired)) return false;
	else if ((str.length > 0) && (blnRequired)) {
		var strCheck = str;
		//string too long to be a valid date
		if (strCheck.length > 10) return false;
		var aDate;
		var strDate;
		var strMonth;
		var strYear;
		aDate = strCheck.split("/");
		if (aDate.length != 3) return false;
		if (UKUS == "UK") {
			strDate = aDate[0];
			strMonth = aDate[1] - 1;
		}
		else if (UKUS == "US") {
			strDate = aDate[1];
			strMonth = aDate[0] - 1;
		}
		strYear = aDate[2];
		if (strYear.length != 2 && strYear.length != 4) return false;
		if (strYear.length == 2) {
			if (bln4DigitYear) return false;
			if (strYear >= "70") strYear = "19" + strYear;
			else strYear = "20" + strYear;
		}
		var oDate = new Date(strYear,strMonth,strDate);
		if (isNaN(oDate)) return false; //a valid date could not be constructed
		if (strDate != oDate.getDate()) return false; //the date returned was different to the original date
		if (strMonth != oDate.getMonth()) return false; //the month returned was different to the original date
		if (strYear < 2000 && strYear > 1899) strYear = strYear.substr(2);
		if (strYear != oDate.getYear()) return false; //the month returned was different to the original date
		return true;
	}
}

function isTime(str,strFormat,blnRequired) {
	if (isEmpty(str) && (blnRequired)) return false;
	else if ((str.length > 0) && (blnRequired)) {
		var strCheck = str;
		if (strCheck.length > 12) return false; //string too long to be a valid time
		var aCheck = strCheck.split(":");
		if (aCheck.length != 3) return false;
		strHour = aCheck[0];
		strMinute = aCheck[1];
		strSecond = aCheck[2];
		if (strFormat == "24Hr") {
			var aCheck = strCheck.split(":");
			strHour = aCheck[0];
			strMinute = aCheck[1];
			strSecond = aCheck[2];
			if (strHour > 23 || isNaN(strHour)) return false;
			if (strMinute > 59 || isNaN(strMinute)) return false;
			if (strSecond > 59 || isNaN(strSecond)) return false;
		}
		if (strFormat == "12Hr") {
			var aCheck2 = strSecond.split(" ");
			if (aCheck2.length != 2) return false;
			strSecond = aCheck2[0];
			strAMPM = aCheck2[1];		
			if (strHour > 12 || isNaN(strHour)) return false;
			if (strMinute > 59 || isNaN(strMinute)) return false;
			if (strSecond > 59 || isNaN(strSecond)) return false;
			if (strAMPM != "AM" && strAMPM != "PM") return false;
		}
	}
	return true;
}

function isDateTime(str,UKUS,strFormat,blnRequired,bln4DigitYear) {
	if (isEmpty(str) && (blnRequired)) return false;
	else if ((str.length > 0) && (blnRequired)) {
		aCheck = str.split(" ");
		if ((strFormat == "12Hr") && (aCheck.length != 3)) return false;
		if ((strFormat == "24Hr") && (aCheck.length != 2)) return false;
		if (!isDate(aCheck[0],blnRequired,UKUS,bln4DigitYear)) return false;
		var strTime;
		if(strFormat == "12Hr") strTime = aCheck[1] + " " + aCheck[2];
		else if (strFormat == "24Hr") strTime = aCheck[1];
		if (!isTime(strTime,strFormat,blnRequired)) return false;
	}
	return true;
}

function isLengthOK(str,min,max,blnRequired) {
	if (isEmpty(str) && (blnRequired)) return false;
	if(str.length < min || str.length > max && blnRequired) return false;
	else return true;
}

function isValueOK(str,min,max,blnRequired) {
	if (isEmpty(str) && (blnRequired)) return false;
	if (isNaN(str) && blnRequired) return false;
	if(str < min || str > max && blnRequired) return false;
	else return true;
}

function isUsernamePassword(str,blnRequired) {
	if (isEmpty(str) && (blnRequired)) return false;
	else if (!isLengthOK(str, 6, 16, true)) return false;
	else if (str.search(/[\W_]+/) > -1) return false;
	return true;
}

function isCreditCard(strNumber) {

	// Original from: http://www.sislands.com/jscript/week6/ccvalidation.htm
	// Modified by Tony Ruscoe (truscoe@sdlintl.com)

	// REMOVE ANY NON-NUMERIC CHARACTERS
	strNumber = strNumber.replace(/[^0-9]/gi, "");

	// REJECT CC NUMBER IF EMPTY, SHORTER THAN 4 OR LONGER THAN 19
	if (isEmpty(strNumber) || strNumber.length < 4 || strNumber.length > 19) {
		return false;
	}
	
	// THE LUHN FORUMLA / MODULUS 10 CHECK
	var sum = 0;
	var mul = 1;
	var lenNumber = strNumber.length;
	for (var i = 0; i < lenNumber; i++) {
		var digit = strNumber.substring(lenNumber - i - 1, lenNumber - i);
		var tproduct = parseInt(digit, 10) * mul;
		if (tproduct >= 10) sum += (tproduct % 10) + 1
		else sum += tproduct;
		if (mul == 1) mul++;
		else mul--;
	}
	if ((sum % 10) == 0) return true;
	else return false;
}

function isExpiryDate(d) {
	// REGULAR EXPRESSION TO REMEMBER THE MONTH (EITHER 1 OR 2 DIGIT)
	// AND YEAR (EITHER 2 OR 4 DIGIT) INPUT AND KEEP THEM SEPARATE
	var re = /(\d{1,2})[ \-\/](\d{2,4})/;
	var arr = re.exec(d);
	var enteredMonth = parseInt(eval(RegExp.$1));
	var enteredYear = parseInt(eval(RegExp.$2));
	if (enteredYear < 100) { // IF A 2 DIGIT YEAR IS ENTERED
		if (enteredYear < 70) enteredYear += 2000; // IF LESS THAN 70 ASSUME 20xx
		else enteredYear += 1900; // ELSE ASSUME 19xx
	}
	var now = new Date();
	var nowMonth = now.getMonth() + 1;
	var nowYear = now.getFullYear();
	// IF ENTERED YEAR IS LARGER THAN TODAY'S YEAR, IT'S VALID
	if (enteredYear > nowYear) return true;
	// IF TODAY'S MONTH IS GREATER OR EQUAL TO ENTERED MONTH, IT'S VALID
	if (enteredYear == nowYear) {
		if (enteredMonth >= nowMonth) return true;
	}
	return false;
}

function openWindow(strURL){
	var xPos = (screen.width - 400) / 2;
	var yPos = (screen.height - 300) / 2 - 20;
	window.open(strURL,"_blank","width=400,height=300,left="+xPos+",top="+yPos+";");
}

function redrawWindow(intWidth, intHeight){
	if (isEmpty(intWidth)) intWidth = 300;
	if (isEmpty(intHeight)) intHeight = 300;
	intWidth = (intWidth > screen.width) ? screen.width : intWidth;
	intHeight = (intHeight > screen.height-25) ? screen.height-25 : intHeight;
	var xPos = (screen.width - intWidth) / 2;
	var yPos = (screen.height - intHeight) / 2 - 25;
	xPos = (xPos < 0) ? 0 : xPos;
	yPos = (yPos < 0) ? 0 : yPos;
	self.moveTo(xPos, yPos);
	self.resizeTo(intWidth, intHeight);
	self.focus();
}

function viewLicenseHistory(licenseID){
	var xPos = (screen.width - 400) / 2;
	var yPos = (screen.height - 300) / 2 - 20;
	window.open("/https://secure.sdlintl.com/products-home/products/products-and-services/licenses/license-history.htm?LicenseID="+licenseID+"&width=640&height=400","licenseHistory","width=400,height=300,left="+xPos+",top="+yPos+",scrollbars,resizable;");
}

/********
 * Takes a Select option value and loads reloads the URL in the current window
********/

function goto_URL_2(object) {
   location.replace(object.options[object.selectedIndex].value);
}


/********
 * needed for homepage and changing of Flash-leftMenu-Navigation-swapping
********/

function swapReason(id)
{
	if(document.all)
	{
		for (i=0;i<arrReasons.length;i++) {
			document.all["reason"+i].style.color = "#ad9c5a";
		}
		document.all["reason"+id].style.color = "#880000";
		document.all["reasontext"].innerHTML = arrReasons[id];
	}
	else if(document.getElementById)
	{
		for (i=0;i<arrReasons.length;i++) {
			document.getElementById("reason"+i).style.color = "#ad9c5a";
		}
		document.getElementById("reason"+id).style.color = "#880000";
		document.getElementById("reasontext").innerHTML = arrReasons[id]
	}
	else
	{
		alert("Your browsers is not compatible with this feature.\n\nYou require Internet Explorer 5.0 or above or Netscape 6 or above");
	}
}

/********
 * needed for flash-handling
********/


function CreateControl(DivID,WIDTH, HEIGHT, URL)
{
  var d = document.getElementById(DivID);
  d.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width='+ WIDTH +' height=' + HEIGHT +'>\
  <param name="movie" value=' + URL + '>\
  <param name="base" value="">\
  <param name="quality" value="high">\
  <param name="menu" value="false">\
  <param name="wmode" value="transparent" >\
  <embed src=' + URL + ' base="" quality="high" menu="false" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent" width=' + WIDTH +' height=' + HEIGHT +'>\
  </embed>\
  </object>';
}

/********
 * Takes a Select option value and loads it into a higher level frame
********/

function goto_URL(object) {
   parent.frames[0].location.replace(object.options[object.selectedIndex].value);
}

/********
 * Takes a Select option value and loads reloads the URL in the current window
********/

function goto_URL_2(object) {
   location.replace(object.options[object.selectedIndex].value);
}

/********
 * JavaScript fix for the 2nd level menu dropdowns in IE6 because it doesn't support li:hover
********/
EnableMenu = function() {
	if (document.all && document.getElementById) {
		oRoot = document.getElementById("Menu");
		for (i=0; i<oRoot.childNodes.length; i++) {
			oNode = oRoot.childNodes[i];
			if (oNode.nodeName == "LI") {
				oNode.onmouseover = function() { this.className += " over"; }
				oNode.onmouseout = function() { this.className = this.className.replace(" over", ""); }
			}
		}
	}
}
function MM_openBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}


//window.onload=EnableMenu;
SafeAddOnload(EnableMenu);

/**
 * @author Brooks Andrus 
 * October 30, 2006
 *
 * Real Player JavaScript detection and embed script
 * Inspired by Geoff Stern's SWFObject http://blog.deconcept.com/swfobject/
 *
 * Tested and found to work on:
 *    - Windows XP, IE 6, Firefox 1.5
 *    - Mac OS X, Firefox 1.5, Firefox 2.0, Safari 2.0.4
 *
 * Known Issues
 *    - Opera & Real Media fail on all platforms
 */
 
 
 
/**
 * Here's our JavaScript constructor function.
 * 
 * @param src - the file name / path
 * @param id  - the object id for the embedded wmp
 * @param w   - the width of the object / embed area
 * @param h   - the height of the object / embed area
 */
RealEmbed = function( src, id, w , h )
{
	this.params     = new Object();
	this.attributes = new Array();
	
	if ( id  )  { this.setAttribute('id'    , id  ); }
	if ( src )  { this.setAttribute( 'src'  , src ); }
	if ( w   )  { this.setAttribute('width' , w   ); }
	if ( h   )  { this.setAttribute('height', h   ); }
}

/**
 * Stuffs attributes array with name value pairs.
 *
 */
RealEmbed.prototype.setAttribute = function( name, value )
{
	this.attributes[name] = value;
}

/**
 * Returns value for a given attribute array key.
 *
 */
RealEmbed.prototype.getAttribute = function( name )
{
	return this.attributes[name];
}

/**
 * Allows name / value parameter tags to be chained onto the
 * RealEmbed object - keeps the constructor from being enormous
 *
 */
RealEmbed.prototype.addParam = function( name, value )
{
	this.params[name] = value;
}

/**
 * Returns a keyed array of name / value parameters
 *
 */
RealEmbed.prototype.getParams = function()
{
	return this.params;
} 

/**
 * Returns a string of html param tags with name / value pairs set.
 *
 */
RealEmbed.prototype.getParamTags = function( ie )
{
	var params = "";
	if ( ie )
	{
		var paramObj = this.getParams();
		
		for ( var i in paramObj )
		{
			params += '<param name="' + i + '" value="' + paramObj[i] + '" />'
		}
	}
	else
	{
		var paramObj = this.getParams();
		for ( var i in this.getParams() )
		{
			params += ' ' + i + '="' +  paramObj[i] + '"';
		}
	}
	return params;
}

RealEmbed.prototype.getFormattedName = function()
{
	var videofile =  this.getAttribute( 'src' );
	// this will be the final video link (absolute path)
	var videolink = location.href;
			
	// remove the file:// because windows media doesn't understand that
	var file = videolink.indexOf( "file://");

	if ( file > -1 )
	{
		// this is a local path
		videolink = videolink.substring( file + 8 );
		// remove the %20 because media player doesn't understand those
		while( videolink.lastIndexOf( "%20" ) != -1 )
		{
			videolink = videolink.replace( "%20", " " );
		}
		//remove the html file name now
		var lastslash = videolink.lastIndexOf( "/");
		if ( lastslash > -1 )
		{
			videolink = videolink.substring( 0, lastslash );
		}
		//add the video file name
		videolink = videolink + "/" + videofile;
	}
	if ( navigator && navigator.userAgent.substr( 0, navigator.userAgent.indexOf( "/" ) ) == "Opera" )
	{
		videolink = videofile;
	}
	else
	{
		videolink = videofile;
	}
	return videolink;
}

/**
 * Creates the object and embed tags needed to display Real Player
 * in a web page. 
 *
 */
RealEmbed.prototype.getHTML = function()
{	
	var node;
	if ( navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length )
	{
		node  = '<embed name="' + this.getAttribute( 'id' ) + '"'	
				+ ' id="' + this.getAttribute( 'id' ) + '"'
				+ ' width="' + this.getAttribute( 'width' ) + '"'
				+ ' height="' + this.getAttribute( 'height' ) + '"'
				+ ' src="' + this.getFormattedName() + '"'
				+ ' type="audio/x-pn-realaudio-plugin"'
				+ this.getParamTags( false )
		node += ' />';
	}
	else
	{
		node  = '<object id="' + this.getAttribute( 'id' ) + '"'
				+ ' classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"'
				+ ' width="' + this.getAttribute( 'width' ) + '"'
				+ ' height="' + this.getAttribute( 'height' ) 
				+ ' type="audio/x-pn-realaudio-plugin"'
				+ '">'
				+ '<param name="src" value="' + this.getAttribute( 'src' ) + '" />'
				+ this.getParamTags( true )
				+ '</object>';
	}
	return node
}

/**
 * Responsible for writing out the innerHTML for the element identified
 *
 */
RealEmbed.prototype.write = function( elementId )
{
	var n = ( typeof elementId == 'string' ) ? document.getElementById( elementId ) : elementId;
	n.innerHTML = this.getHTML();
	return true;
}

/**
 * Returns boolean value indicating whether Real Player 
 * plugin is installed for the browser in use. A touch of vb 
 * script is actually used when IE is the browser.
 */
function isRealInstalled() 
{
	var installed = false;
	realObj = false;
	if ( navigator.mimeTypes && navigator.mimeTypes.length )
	{	
		for ( var i = 0; i < navigator.mimeTypes.length; i++ )
		{
			var mt = navigator.mimeTypes[i];
			if ( mt.type == "audio/x-pn-realaudio-plugin" )
			{
				installed = true;
			}
		}
	}
	else 
	{
		execScript( 'on error resume next: realObj = IsObject( CreateObject( "rmocx.RealPlayer G2 Control.1" ) )','VBScript' );
		installed = realObj;
	}
	return installed;
}
