//TO DO: iPhone touch commands
//javascript:output="";function (obj){for(i in obj){output+=i+" = "+obj[i].toString().replace("<","[")+"\n";}}Iterate(document.forms);alert(output);
// MISSING
// Party Poker
// WPT All In Holdem
// Monster Trailer
// I Am Sam
// Blues Story (To lose white frame)
// Potomac Disaster
// 
// 
// WHITE FRAME @ HEADS
// Blues Story
// Smash Cuts
// SAT (x3)
// Blame Game
// HeatVision (x2)
// Latinos '08


function GenDiv(DivID,DivPosition){
	var fn=arguments.callee.name;
	dv=document.createElement("div");
	dv.setAttribute("id",DivID);
	dv.setAttribute("class","dbe");
	//dv.setAttribute("name",DivID);  Doesn't work -- see below
	dv.style.position=(DivPosition==undefined?"absolute":DivPosition);
	dv.Alpha=0;
	dv.style.visibility="hidden";
	zIndexCount++;
	dv.style.zIndex=zIndexCount;
	dv.zOrigin=zIndexCount;
	document.body.appendChild(dv);
 	window[DivID]=document.getElementById(DivID);
 	eval(DivID).name=DivID; //not sure about this
 	//ENG.innerHTML+=document.getElementsByName[DivID];
}

function LoadDiv(obj,source,xtra){
	obj.innerHTML="<IMG ID='img' SRC='"+source+"?"+UniqueID+"' " + (xtra != undefined ? xtra : "") +" />";
	//ENG.innerHTML+=obj.innerHTML+"<br>";
}

function GetLoadStats(){
	this.parentNode.natH=this.naturalHeight;
	this.parentNode.natW=this.naturalWidth;
	//ENG.innerHTML+=this.parentNode.id+": "+this.natH+", "+this.natW+"<br>";
}

function LoadDivEmbed(obj,source,xtra){
	obj.innerHTML="<embed ID='img' SRC='"+source+"' " + (xtra != undefined ? xtra : "") + " />";
}

function LoadDivVideo(obj,source,xtra){
	ReportAction("Play: "+ActiveClip.Clip);
	obj.innerHTML="<embed ID='img' SRC='"+source+"' "+(xtra!=undefined?xtra:"")+" />";
    //options are video / embed
}

function ClearDiv(obj){
	SetAlpha(obj,0);
	obj.innerHTML="";
}

function ENGit(txt){
	ENG.innerHTML+=txt+"<br>";
}

function Iterate(obj){
	var txt;
	for(i in obj){
		txt=obj[i].toString();
		txt=txt.replace(/</g,"[");
		txt=txt.replace(/>/g,"]");
		txt=txt.replace(/\[br]/g,"<br>");
		ENGit(i+": "+txt);
		//ENG.innerHTML+=i+" - "+obj[i].id+" - "+obj[i].style.zIndex+"<br>";		
	}
}

function GetPos(obj){
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do{
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}

function SetPos(obj, _x, _y, _width, _height, SizeType){
    //self.status=obj.id;//buh?
    obj.style.position="absolute";
    obj.style.overflow="hidden";
    if(_x!=undefined){
    	obj_x=parseInt(_x);
    	obj.style.left=parseInt(_x)+"px";
	}
    if(_y!=undefined){
    	obj._y=parseInt(_y);
    	obj.style.top=parseInt(_y)+"px";
	}
    if(_width!=undefined){
    	obj._width=parseInt(_width);
    	obj.style.width=parseInt(_width)+"px"; //Crops image
    	if(SizeType!="Crop" && obj.childNodes[0]!=undefined){
    		obj.childNodes[0].width=_width;
    	}
	}
    if(_height!=undefined){
    	obj._height=parseInt(_height);
    	obj.style.height=parseInt(_height)+"px"; //Crops image
    	if(SizeType!="Crop" && obj.childNodes[0]!=undefined){
    		obj.childNodes[0].height=_height;
    	}
	}
}

function GoGeo(GeoObj,Dur,Pos,Size,OnComplete){
	if(Pos!=undefined){
		$(GeoObj).animate(Pos,Dur,OnComplete);
	}
	if(Size!=undefined){
		$(GeoObj.childNodes[0]).animate(Size,Dur,OnComplete);
	}
}


function SetAlpha(obj, Alpha) {
	var fn=arguments.callee.name;
	Alpha = (Alpha == 100)?99.999:Alpha;
	if(browser.id=="IE"){// IE/Win
		obj.style.filter = "alpha(opacity:"+Alpha+")";
	}
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = Alpha/100;
	// Older Mozilla and Firefox
	obj.style.MozOpacity = Alpha/100;  
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = Alpha/100;
	//
	obj.Alpha=Alpha;
	obj.style.visibility=(obj.Alpha==0 ? "hidden" : "visible");
}

function FaderMaster(obj, ITVrate, FadeSteps, AlphaStart, AlphaEnd) {
	var fn=arguments.callee.name;
	obj.ITVrate = ITVrate;
	obj.FadeSteps = FadeSteps;
	obj.AlphaStart = (AlphaStart == undefined ? obj.Alpha : AlphaStart);
	obj.AlphaEnd = AlphaEnd;
	obj.AlphaRate = (Math.abs(obj.AlphaEnd-obj.AlphaStart)/obj.FadeSteps)*(obj.AlphaEnd<obj.AlphaStart ? (-1) : 1);
	//ENG.innerHTML+=obj.id+":"+obj.AlphaRate+"<br>";	
	obj.tStart = new Date().getTime();
	obj.Fading = true;
	obj.Alpha = obj.AlphaStart;
	clearInterval(obj.ITVfm);
	obj.ITVfm = setInterval(Fader, obj.ITVrate);
	function Fader() {
		obj.Alpha = obj.Alpha+obj.AlphaRate;		
		if ((obj.AlphaRate>0 && obj.Alpha>=obj.AlphaEnd) || (obj.AlphaRate<0 && obj.Alpha<=obj.AlphaEnd)) {
			obj.Alpha = obj.AlphaEnd;
			obj.Fading = false;
			obj.tEnd = new Date().getTime();
			SetAlpha(obj,obj.Alpha);
			//ENG.innerHTML+="FadeEnd:"+obj.id+"-"+obj.Alpha+"<br>";
			clearInterval(obj.ITVfm);			
		} else {
			SetAlpha(obj,obj.Alpha);
		}
		//ENG.innerHTML+=obj.id+" - "+obj.Alpha+" <br> ";
	}
}

function FaderBatchMaster(BatchObj, BatchITVrate, ITVrate, FadeSteps, AlphaStart, AlphaEnd){
	BatchObj.DivCount=BatchObj.DivArr.length;
	BatchObj.Creeper=0;
	BatchObj.FaderBatchIntvl=setInterval(FaderBatch, BatchITVrate);
	function FaderBatch(){
		FaderMaster(BatchObj.DivArr[BatchObj.Creeper],ITVrate, FadeSteps, AlphaStart, AlphaEnd);
		BatchObj.Creeper++;
		if(BatchObj.Creeper>=BatchObj.DivCount){
			clearInterval(BatchObj.FaderBatchIntvl);
		}
	}	
}

function tpRotate(obj,deg){
	obj.style.webkitTransform="rotate("+deg+"deg)";
	obj.style.MozTransform="rotate("+deg+"deg)";
}

function StrSrchLeft(Needle,Haystack){
	//ENG.innerHTML+=Needle+" / "+Haystack+"<br>";
	if(Haystack.substr(0,Needle.length)==Needle){
		return true;
	} else {
		return false;
	}
}

function ValidateEntry(txt,type){
	var fn=arguments.callee.name;
	var pattern
	if(type=="email"){
		pattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; //ref http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/
	} else if(type=="text"){
		pattern = /^[a-zA-Z0-9_-]/;
	}
	return pattern.test(txt);  
}


function ShakeMaster(obj,hshake,hdur,vshake,vdur){
	if(hshake==undefined){
		hshake=0;
		hdur=0;
	}
	$(obj).animate({
		left: "+="+hshake
	},hdur,function(){
		$(this).animate({
			left: "-="+hshake*2
		},hdur,function(){
			$(this).animate({
				left: "+="+hshake
			},hdur,function(){
				//on complete
			});
		});
	});
	if(vshake==undefined){
		vshake=0;
		vdur=0;
	}
	$(obj).animate({
		top: "+="+vshake
	},vdur,function(){
		$(this).animate({
			top: "-="+vshake*2
		},vdur,function(){
			$(this).animate({
				top: "+="+vshake
			},vdur,function(){
				//on complete
			});
		});
	});	
}

function MouseOverStandard(obj){
	if(DeviceType!="Mobile"){
		if(obj=="[object HTMLDivElement]"){
			DivObj=obj;
		} else{
			DivObj=this;
		}
		document.body.style.cursor="pointer";
		FaderMaster(DivObj,10,20,undefined,DivObj.Alpha*60/100);
		ShakeMaster(DivObj,2,20,0,2);
	}
}

function MouseOutStandard(obj){
	if(DeviceType!="Mobile"){
		if(obj=="[object HTMLDivElement]"){
			DivObj=obj;
		} else{
			DivObj=this;
		}
		document.body.style.cursor="standard";
		FaderMaster(DivObj,10,20,undefined,100);
	}
}

function DivSetPropsToggler(DivSetNames,mode){
	for(i=1;i<DivSetNames.length;i++){
		DivSetName=DivSetNames[i];
		DivObj=eval(DivSetName);
		SetPos(DivObj,DivObj._x,DivObj._y);
		if(mode=="on"){
			LoadDiv(DivObj,DivObj.FilePath);
			DivObj.getElementsByTagName("img")[0].onload=function(){
				FaderMaster(this.parentNode,10,20,undefined,100);
			}
			if(DivObj.urlink!="" && DivObj.urlink!=null){
				DivObj.onclick=function(){
					parent.Redirect(this.urlink);
				}
				if(DeviceType!="Mobile"){//
					DivObj.onmouseover=function(){
						FaderMaster(this,10,20,undefined,50);
						ShakeMaster(this,1,20,0,0);
					}
					DivObj.onmouseout=function(){
						FaderMaster(this,10,20,undefined,100);
					}
				}
			}
		} else if(mode=="off"){
			FaderMaster(DivObj,10,5,undefined,0);
		} else if(mode=="admin"){
			LoadDiv(DivObj,DivObj.FilePath);
			DivObj.getElementsByTagName("img")[0].onload=function(){
				FaderMaster(this.parentNode,10,20,undefined,100);
			}			
			Drag.init(DivObj);
		}
	}
	if(mode=="admin"){
		ENG.innerHTML="Click here for code...<br>";
		ENG.onclick=function(){
			ENG.innerHTML="";
			for(i=1;i<DivSetNames.length;i++){
				DivName=DivSetNames[i];
				DivObj=eval(DivName);
				ENG.innerHTML+="DivSetPushProps(\""+DivName+"\", "+parseInt(DivObj.style.left)+", "+parseInt(DivObj.style.top)+", \""+DivObj.urlink+"\");"+"<br>";
			}
		}
	}
}

function DivSetPushProps(DivName,_x,_y,urlink){
	//DivNameFull=DivSetMasterName+"_"+DivName; //DivSetMasterName+"_"+DivName; (vecchio)
 	DivCount++;
 	DivSetNames[DivCount]=DivName;
	GenDiv(DivName);
	DivObj=eval(DivName);
	DivObj._offsetX=DivSetOffsetX;
	DivObj._offsetY=DivSetOffsetY;	
	DivObj._x=_x+DivObj._offsetX;
	DivObj._y=_y+DivObj._offsetY;
	DivObj.urlink=urlink;
	DivObj.FilePath=AssetsPath+DivName+".png";
	//SetAlpha(DivObj,100);
}

function InitTable(TableName){
	window[TableName]=document.createElement("table");
	window[TableName].setAttribute("id",TableName);
	window[TableName].setAttribute("name",TableName);
	window[TableName].style.color="#999999";
	window[TableName].style.fontSize=11;
	window[TableName].style.fontFamily="Arial";
	GenDiv(TableName+"Div");
	eval(TableName+"Div").appendChild(window[TableName]);
	//window[TableName].insertRow(0);
	//Drag.init(ShoppingCartDiv);
}

function Genppup(ppupID,x,y,ySpacer,_alpha){
	for(i=1;i<=eval(ppupID).length;i++){
		GenDiv(ppupID+i);
		eval(ppupID+i).style.visibility="hidden";
		FaderMaster(eval(ppupID+i),10,15,0,_alpha);
		eval(ppupID+i).innerHTML=eval(ppupID)[i-1];
		SetPos(eval(ppupID+i),x,y+(ySpacer*(i-1)));
		eval(ppupID+i).onmouseover=function(){
			FaderMaster(this,10,15,this.Alpha,50);
		}
		eval(ppupID+i).onmouseout=function(){
			FaderMaster(this,10,50,this.Alpha,100);
		}
		eval(ppupID+i).onmouseup=function(){
			eval(ppupID+"_onClick")(this.id);
		}
	}
}

function DeviceInfo(){
	if(http_user_agent.toLowerCase().search("iphone")>=0){
		DeviceName="iPhone";
	} else if(http_user_agent.toLowerCase().search("ipad")>=0){
		DeviceName="iPad";
	} else if(http_user_agent.toLowerCase().search("android")>=0){
		DeviceName="Android";
	} else {
		DeviceName="TBD";
	}
	if(DeviceName=="iPhone" || DeviceName=="iPad" || DeviceName=="Android"){
		DeviceType="Mobile";
	} else {
		DeviceType="Computer";
	}

}

function WaitForInits(){
	if(FlashInit==true){
		clearInterval(WaitForInitsIntvl);
		InitClipset();
	} else if(browser.id=="IE"){
		FlashInit=true;
	} else{
		CookieFL=swf.childNodes[0].GetVariable("CookieFL");
		SystemCapabilities=swf.childNodes[0].GetVariable("SystemCapabilities");
		//ENG.innerHTML+=CookieFL+" / "+SystemCapabilities+"<br>";
		if(CookieFL!="" && CookieFL!=null && SystemCapabilities!="" && SystemCapabilities!=null){
			FlashInit=true;
		}
	}
	FlashInitCount++;
	FlashInit=(FlashInitCount>FlashInitMax ? true : FlashInit);
}


function InitFlash(){
	var fn=arguments.callee.name;
	GenDiv("swf");
	LoadDivEmbed(swf,"dbe10.swf","FlashVars='remote_addr="+remote_addr+"'");
	CookieFL="";
	SystemCapabilities="";
	FlashInit=false;
	FlashInitCount=0;
	FlashInitMax=25;
	if(DeviceType=="Mobile" || http_host=="Local" /*|| DeviceType=="Computer"*/){
		FlashInit=true;
	}
	WaitForInitsIntvl=setInterval("WaitForInits();",100);
}


function GetDivStats(StatsType,Div1,Div2){
	if(StatsType.toLowerCase()=="left"){
		return parseInt(Div1.style.left);
	} else if(StatsType.toLowerCase()=="right"){
		return parseInt(Div1.style.left)+Div1.clientWidth;
	} else if(StatsType.toLowerCase()=="xmid"){
		return (parseInt(Div1.style.left)+Div1.clientWidth/2) - (Div2!=undefined ? Div2.clientWidth/2 : 0);
	} else if(StatsType.toLowerCase()=="top"){
		return parseInt(Div1.style.top);
	} else if(StatsType.toLowerCase()=="bottom"){
		return parseInt(Div1.style.top)+Div1.clientHeight;
	} else if(StatsType.toLowerCase()=="ymid"){
		return (parseInt(Div1.style.top)+Div1.clientHeight/2) - (Div2!=undefined ? Div2.clientHeight/2 : 0);
	}
}

function get_cookie ( cookie_name ){
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

function StrToArr(Str) {
	var fn=arguments.callee.name;
	//ENG.innerHTML=Str+" typeof: "+typeof(Str)+"<br>";
	//Iterate(Str);
    Arr1 = Str.substr(1).split("&");
    var Arr2=new Object();
    for(i in Arr1){
    	pair=Arr1[i].split("=");
        Arr2[pair[0]]=pair[1];
    }
    return Arr2;
}

function ArrToStr(arr){
	var fn=arguments.callee.name;
	dstring="";
	for(i in arr){
		dstring+=(dstring!="" ? "&" : "")+i+"="+encodeURI(arr[i]);
	}
	return dstring;
}

function GenForm() {
	if(document.getElementById(FormName+"BG")==null){
		GenDiv(FormName+"BG");
	}
    if(document.getElementById(FormName)==null){
		GenDiv(FormName);
	}
    for(i=1 ; i<=FormInputNames.length ; i++){
        if(FormInputTypes[i-1]=="textarea"){
        	nd = document.createElement("textarea");
        } else{
			window[FormName].innerHTML+=FormInputLabels[i-1];
			nd = document.createElement("input");
			nd.setAttribute("type",FormInputTypes[i-1]);
        }
        nd.setAttribute("id",FormInputNames[i-1]);
        nd.setAttribute("name",FormInputNames[i-1]);
        nd.setAttribute("value",FormInputValues[i-1]);
        nd.onkeyup=function(evt){FormFncCommon(evt);}
        window[FormName].appendChild(nd);
        if(i<FormInputNames.length){window[FormName].innerHTML+="<br>";}
    }
    window[FormName]["FormInputNames"]=FormInputNames;
    window[FormName]["FormFncCustom"]=FormFncCustom;
}

function FormFncCommon(obj,Action){
	objDebug=obj;
	ActionDebug=Action;
	var fn=arguments.callee.name;
	if(obj.which==13 && document.activeElement.type=="textarea"){
		return
	}
	var DivName, DivObj, DivBGName, DivBGObj, FormInputNames, FormFncCustom, InputName;
	if(obj.type=="keyup"){//comes from a key click
		DivName=obj.target.parentNode.id;
		DivObj=eval(DivName);
		//FormName=obj.target.parentNode.id;
		//FormObj=eval(FormName);
		FormInputNames=DivObj.FormInputNames;
		FormFncCustom=DivObj.FormFncCustom;
		DivObj.vType="keyup";
		DivObj.vKey=obj.which;
	} else {//comes from a mouse click
		DivObj=obj;
		DivName=DivObj.id;
		//FormName=DivName.replace("Div","");
		//FormObj=eval(FormName);
		FormInputNames=DivObj.FormInputNames;
		FormFncCustom=DivObj.FormFncCustom;
		DivObj.vType="mouseclick";
		DivObj.vKey="";
	}
	DivBGName=DivName+"BG";
	DivBGObj=eval(DivBGName);
	if(obj.which==13 || Action=="Submit"){//return
		document.activeElement.blur();
		DivObj.vAction="Submit";
		FaderMaster(DivObj,10,20,undefined,0);
		FaderMaster(DivBGObj,10,20,undefined,0);
	} else if(obj.which==27 || Action=="Cancel"){//esc
		document.activeElement.blur();
		//FormObj.blur();
		DivObj.vAction="Cancel";
		FaderMaster(DivObj,10,20,undefined,0);
		FaderMaster(DivBGObj,10,20,undefined,0);
	}
	if(FormFncCustom!=""){eval(FormFncCustom)(DivObj);}
}

function ToolTipUpdate(_txt, TXTcolor, BGcolor) {
	ToolTip.txt = _txt;
	ToolTip.innerHTML=_txt;
	ToolTip.style.fontFamily="arial";
	ToolTip.style.fontSize="11";
	ToolTip.style.align="left";
	ToolTip.style.backgroundColor=BGcolor;
	ToolTip.style.color=TXTcolor;
	ToolTip.style.border="1px solid "+BGcolor;
}

function Browser() {
	//use this function: browser=new Browser();
	var ua, s, i;
	this.id		="tbd";
	this.isIE	= false;
	this.isNS	= false;
	this.isFF	= false;
	this.isChr	= false;
	this.isSaf	= false;
	this.version = null;
	ua = navigator.userAgent;
	s = "MSIE";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isIE = true;
		this.id = "IE";
		this.version = parseFloat(ua.substr(i + s.length));
		return;
	}
	s = "Netscape6/";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		this.id = "Netscape";
		this.version = parseFloat(ua.substr(i + s.length));
		return;
	}
	s = "Firefox/";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isFF = true;
		this.id= "Firefox";
		this.version = parseFloat(ua.substr(i + s.length));
		return;
	}
	s = "Chrome/";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isChr = true;
		this.id= "Chrome";
		var kywrd="Version/";
		var startPos=ua.indexOf(kywrd)+kywrd.length;
		var endPos=ua.indexOf(" ",startPos);
		var strch=endPos-startPos;
		this.version = parseFloat(ua.substr(startPos,strch));
		return;
	}
	s = "Safari/";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isSaf = true;
		this.id= "Safari";
		var kywrd="Version/";
		var startPos=ua.indexOf(kywrd)+kywrd.length;
		var endPos=ua.indexOf(" ",startPos);
		var strch=endPos-startPos;
		this.version = parseFloat(ua.substr(startPos,strch));
		return;
	}
	s = "Gecko"; 	// Treat any other "Gecko" browser as NS 6.1.
	if ((i = ua.indexOf(s)) >= 0) {
		this.id = "Gecko";
		this.isNS = true;
		this.version = 6.1;
		return;
	}
}

function GetMouseInit(){
	//IE = document.all?true:false;
	if(browser.id!="IE"){//if used to be... !browser.isIE
		document.captureEvents(Event.MOUSEMOVE);
	}
	document.onmousemove = GetMouseXY;
	MouseX = 0;
	MouseY = 0;
}

function GetMouseXY(evt) {
	if (browser.id=="IE") {//command used to be browser.isIE
		MouseX = event.clientX + document.body.scrollLeft;
		MouseY = event.clientY + document.body.scrollTop;
	} else {  // grab the x-y pos.s if browser is NS
		MouseX = evt.pageX;
		MouseY = evt.pageY;
	}
	MouseX=(MouseX<0?0:MouseX);
	MouseY=(MouseY<0?0:MouseY);
	//ENG.innerHTML=MouseX+","+MouseY+"<br>";
}

function GetKeyPressInit(){
	var fn=arguments.callee.name;
	if(parseInt(browser.version)>3){
		document.onkeyup=function(evt){
			GetKeyPress(evt);
		}
	}
}

function GetKeyPress(evt){
	//needs more work -- Modifiers for both browser situations.
	if(browser.id=="Netscape" && parseInt(browser.version)==4){ // used to be: if(browser.isNS==true && parseInt(browser.version)==4)
		KeyMod=evt.modifiers;
	} else {
		KeyMod=evt.shiftKey+"-"+evt.altKey+"-"+evt.ctrlKey;
	}
	KeyCode=evt.which;
	KeyChar=String.fromCharCode(evt.which);
	KeyChar=(evt.shiftKey==true?KeyChar.toUpperCase():KeyChar.toLowerCase());
	//ENG.innerHTML="Keypress: "+KeyChar+"-"+KeyCode+"-"+KeyMod+"<br>";
	if(KeyCode==27){
		QTFullScreen();
	}
}

function Draggables(DragStatus){//http://www.youngpup.net/projects/dom-drag/dom-drag.js
	if(DragStatus=="off"){
		Drag=undefined;
	} else {
		Drag = {
			obj : null,
			cancel : function(o){
				o.onmousedown=undefined;
			},
			init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
			{
				o.onmousedown	= Drag.start;
				o.hmode			= bSwapHorzRef ? false : true ;
				o.vmode			= bSwapVertRef ? false : true ;
				o.root = oRoot && oRoot != null ? oRoot : o ;
		
				if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
				if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
				if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
				if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";
		
				o.minX	= typeof minX != 'undefined' ? minX : null;
				o.minY	= typeof minY != 'undefined' ? minY : null;
				o.maxX	= typeof maxX != 'undefined' ? maxX : null;
				o.maxY	= typeof maxY != 'undefined' ? maxY : null;
		
				o.xMapper = fXMapper ? fXMapper : null;
				o.yMapper = fYMapper ? fYMapper : null;
		
				o.root.onDragStart	= new Function();
				o.root.onDragEnd	= new Function();
				o.root.onDrag		= new Function();
			},
			start : function(e)
			{
				var o = Drag.obj = this;
				e = Drag.fixE(e);
				var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
				var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
				o.root.onDragStart(x, y);
				o.lastMouseX	= e.clientX;
				o.lastMouseY	= e.clientY;
				if (o.hmode) {
					if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
					if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
				} else {
					if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
					if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
				}
		
				if (o.vmode) {
					if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
					if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
				} else {
					if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
					if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
				}
				document.onmousemove	= Drag.drag;
				document.onmouseup		= Drag.end;
				return false;
			},
			drag : function(e)
			{
				e = Drag.fixE(e);
				var o = Drag.obj;
				var ey	= e.clientY;
				var ex	= e.clientX;
				var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
				var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
				var nx, ny;
				if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
				if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
				if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
				if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);
				nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
				ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));
				if (o.xMapper)		nx = o.xMapper(y)
				else if (o.yMapper)	ny = o.yMapper(x)
				Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
				Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
				Drag.obj.lastMouseX	= ex;
				Drag.obj.lastMouseY	= ey;
				Drag.obj.root.onDrag(nx, ny);
				return false;
			},
			end : function()
			{
				document.onmousemove = null;
				document.onmouseup   = null;
				Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
											parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
				//ENG.innerHTML+=Drag.obj.id+" - "+Drag.obj.style.top+","+Drag.obj.style.left+"<br>";										
				Drag.obj = null;
			},
			fixE : function(e)
			{
				if (typeof e == 'undefined') e = window.event;
				if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
				if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
				return e;
			}
		};
	}
}

function RatiosInit(){
	GenDiv("Ratios");
    Ratios.style.color="#ffffff";
    Ratios.style.fontFamily="arial";
    Ratios.style.fontSize=30;
	Ratios.innerHTML='x1 <input type="text" id="x1" name="x1" value style="color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 30px; ">';
	Ratios.innerHTML+='<br>y1 <input type="text" id="y1" name="y1" value style="color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 30px; ">';
	Ratios.innerHTML+='<br>x2 <input type="text" id="x2" name="x2" value style="color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 30px; ">';
	Ratios.innerHTML+='<br>y2 <input type="text" id="y2" name="y2" value style="color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 30px; ">';
	FaderMaster(Ratios,10,20,undefined,100);
	Ratios.childNodes["x1"].onkeyup=function(evt){RatiosCalc(evt);};
	Ratios.childNodes["y1"].onkeyup=function(evt){RatiosCalc(evt);};
	Ratios.childNodes["x2"].onkeyup=function(evt){RatiosCalc(evt);};
	Ratios.childNodes["y2"].onkeyup=function(evt){RatiosCalc(evt);};
}

function RatiosCalc(evt){
	if(evt.which>=37 && evt.which<=40){return}
	//ENG.innerHTML+=evt.which+"<br>";
	var x1=Ratios.childNodes["x1"].value;
	var y1=Ratios.childNodes["y1"].value;
	var x2=Ratios.childNodes["x2"].value;
	var y2=Ratios.childNodes["y2"].value;
	if(document.activeElement.name=="x1" || document.activeElement.name=="y1"){
		Ratios.childNodes["x1"].style.cssText="color: #000000; background-color: #eeeeee; font-size: 30";
		Ratios.childNodes["y1"].style.cssText="color: #000000; background-color: #eeeeee; font-size: 30";
		Ratios.childNodes["x2"].style.cssText="color: #ccaaaa; background-color: #eeeeee; font-size: 30";
		Ratios.childNodes["y2"].style.cssText="color: #ccaaaa; background-color: #eeeeee; font-size: 30";		
	} else if(document.activeElement.name=="x2"){
		Ratios.childNodes["x1"].style.cssText="color: #000000; background-color: #eeeeee; font-size: 30";
		Ratios.childNodes["y1"].style.cssText="color: #000000; background-color: #eeeeee; font-size: 30";
		Ratios.childNodes["x2"].style.cssText="color: #000000; background-color: #eeeeee; font-size: 30";
		Ratios.childNodes["y2"].style.cssText="color: #00aa00; background-color: #eeeeee; font-size: 30";
		if(x1!="" && y1!="" && x2!=""){
			y2=x2/(x1/y1);
		}
	} else if(document.activeElement.name=="y2"){
		Ratios.childNodes["x1"].style.cssText="color: #000000; background-color: #eeeeee; font-size: 30";
		Ratios.childNodes["y1"].style.cssText="color: #000000; background-color: #eeeeee; font-size: 30";
		Ratios.childNodes["x2"].style.cssText="color: #00aa00; background-color: #eeeeee; font-size: 30";
		Ratios.childNodes["y2"].style.cssText="color: #000000; background-color: #eeeeee; font-size: 30";
		if(x1!="" && y1!="" && y2!=""){
			x2=y2*(x1/y1);
		}
	}
	Ratios.childNodes["x1"].value=x1;
	Ratios.childNodes["y1"].value=y1;
	Ratios.childNodes["x2"].value=x2;
	Ratios.childNodes["y2"].value=y2;
	if(obj.vKey==9 || obj.vKey==16){
		document.activeElement.select();
	}
}

function GetNow(){
	var fn=arguments.callee.name;
	server_client_offset=server_time_secs-client_time_secs; //This really needs to be set only once
	var Now=new Date();
	var NowYear=Now.getFullYear();
	var NowMonth=Now.getMonth()+1;
	var NowDay=Now.getDate();
	var NowHours=Now.getHours();
	var NowMinutes=Now.getMinutes();
	var NowSeconds=Now.getSeconds();
	var NowDate=NowYear+(NowMonth<10?"0":"")+NowMonth+(NowDay<10?"0":"")+NowDay;
	var NowTime=(NowHours<10?"0":"")+NowHours+(NowMinutes<10?"0":"")+NowMinutes+(NowSeconds<10?"0":"")+NowSeconds;
	return NowDate+"|"+NowTime;
}

function ConvertTime(TimeVal,OutputType,InputType){
	var hh_, hh, mm_, mm, ss_, ss, ff_, ff, hhmmss, hhmmssff;
	if(OutputType=="hhmmss" || OutputType=="hhmmssff" || OutputType=="hh" || OutputType=="mm" || OutputType=="ss" || OutputType=="ff"){
		hh_ = TimeVal/60/60;
		hh = Math.floor(hh_);
		mm_ = (hh_-hh)*60;
		mm = Math.floor(mm_);
		ss_ = (mm_-mm)*60;
		ss = Math.floor(ss_);
		ff_ = (ss_-ss)*qt_TimeScale/1000;
		ff = Math.floor(ff_);
		hhmmss=(hh<10?"0":"")+hh+":"+(mm<10?"0":"")+mm+":"+(ss<10?"0":"")+ss;
		hhmmssff=hhmmss+":"+(ff<10?"0":"")+ff;
		if(OutputType=="hhmmss"){
			return hhmmss;
		} else if(OutputType=="hhmmssff"){
			return hhmmssff;
		} else if(OutputType=="hh"){
			return hh;
		} else if(OutputType=="mm"){
			return mm;
		} else if(OutputType=="ss"){
			return s;
		} else if(OutputType=="ff"){
			return ff;
		}
	}
}

function QTFullScreen(){
	//ENG.innerHTML="";
	if(Player.PlayMode!="FullScreen"){
		Player.PlayMode="FullScreen";
		Player.OriginX=parseInt(Player.style.left);
		Player.OriginY=parseInt(Player.style.top);
		Player.OriginW=Player.clientWidth;
		Player.OriginH=Player.clientHeight;
		window.resizeTo(screen.width,screen.height);
		SetPos(Player,0,0,screen.width,(screen.width)*ActiveClip.Height/ActiveClip.Width);
		if(Player.clientHeight>screen.height-Player.FullScreenMarginY){
			SetPos(Player,0,0,(screen.height-Player.FullScreenMarginY)*ActiveClip.Width/ActiveClip.Height,screen.height-Player.FullScreenMarginY)
		}
		//ENG.innerHTML+="Screen: ("+screen.width+","+screen.height+")<br>";
		//ENG.innerHTML+="Player: ("+Player.clientWidth+","+Player.clientHeight+")<br>";
		SetPos(ENG,Player.clientWidth+5,undefined);
	} else{
		Player.PlayMode="Normal";
		SetPos(Player,Player.OriginX,Player.OriginY,ActiveClip.Width,ActiveClip.Height);
	}
	ReportAction("PlayMode: "+Player.PlayMode);
	//ENG.innerHTML+=Player.PlayMode+"<br>";
	// pw/ph = h1/w1
	// h1=w1*pw/ph
	//WindowPriorWidth=window
	//self.resizeTo(screen.width,window.screen.height);
}

function QTStats(obj){ // obj is the DIV, chldnode=id of embedded player eg. "img"
	qt_TimeScale=obj.childNodes[0].GetTimeScale();
	qt_Position=obj.childNodes[0].GetTime();
	qt_Rate=obj.childNodes[0].GetRate();
	qt_Duration=obj.childNodes[0].GetDuration();
	obj.rate_secs=qt_Rate/qt_TimeScale
	obj.pos_secs=qt_Position/qt_TimeScale;
	obj.pos_hhmmss=ConvertTime(obj.pos_secs,"hhmmss");
	obj.pos_hhmmssff=ConvertTime(obj.pos_secs,"hhmmssff");
	obj.dur_secs=qt_Duration/qt_TimeScale;
	obj.dur_hhmmss=ConvertTime(obj.dur_secs,"hhmmss");
	//ENG.innerHTML=obj.pos_hhmmss+" of "+obj.dur_hhmmss+"<br>";
}

function QTWatch(){ // Runs continuously after first clip runs
	var range, elapse, i;
	QTStats(Player);
	range=.3;
	if(Player.childNodes[0].src!=Player.src_prior){
		//ENG.innerHTML+="New start (clip change)<br>";
	} else if(Player.rate_secs!=Player.rate_secs_prior){ //On Start Playing
		//ENG.innerHTML+="New Start (rate change)<br>";
	} else if(Player.rate_secs==Player.rate_secs_prior && Player.rate_secs!=0) {//While Playing
		elapse=Player.pos_secs-Player.pos_secs_prior;
		if(elapse>=1-range && elapse<=1+range){
			//ENG.innerHTML+="Cont'd: "+(Player.pos_secs-Player.pos_secs_prior)+"<br>";
		} else{
			//ENG.innerHTML+="New start (beyond elapse)<br>";
		}
	}
	for(i in PlayerFuncs){
		eval(PlayerFuncs[i]);
	}
	if(Player.pos_secs>=Player.dur_secs && Player.dur_secs>0){//End of clip
		if(ActiveClip.ClipName=="ex1015_act01"){
			//ActiveThumb=this;
			ActiveClip=eval("ex1015_act02");
	        SecurityCheck(); 
		} else if(ActiveClip.ClipName=="ex1015_act02"){
			ActiveClip=eval("ex1015_act03");
	        SecurityCheck(); 
		} else if(ActiveClip.ClipName=="ex1015_act03"){
			ActiveClip=eval("ex1015_act04");
	        SecurityCheck(); 
		}
	}
	Player.pos_secs_prior=Player.pos_secs;
	Player.rate_secs_prior=Player.rate_secs;
	Player.src_prior=Player.childNodes[0].src;
}

function InitThumbs(){
	ThumbCount=0;
	ThumbCountMAX=50;
	for(i=1;i<=ThumbCountMAX;i++){
		GenDiv("Thumb"+i);
		//SetAlpha(eval("Thumb"+i),0);
	}
}


function InitHeader1(_txt, FullAlpha, headerX, headerY, _fontsize, _letterspacing) {
	FullAlpha = (FullAlpha == undefined ? 75 : FullAlpha);
	headerX=(headerX==undefined ? 75 : headerX);
	headerY=(headerY==undefined ? 15 : headerY)
	_fontsize = (_fontsize == undefined ? 25 : _fontsize);
	_letterspacing = (_letterspacing == undefined ? 3 : _letterspacing);
	Header1.style.textAlign="left";
	Header1.style.fontFamily="Arial";
	Header1.style.fontStyle="normal";
	Header1.style.fontSize=_fontsize+"";
	Header1.style.letterSpacing=_letterspacing+"";
	Header1.style.color="#999999";
	Header1.innerHTML=_txt;
	headerX = (headerX == undefined ? 40 : headerX);
	headerY = (headerY == undefined ? 30 : headerY);
	SetPos(Header1,headerX,headerY);
	Header1.Middle=(parseInt(Header1.style.left)+parseInt(Header1.clientWidth))/2;
}

function InitHeader2(_txt, FullAlpha, headerX, headerY, _fontsize, _letterspacing) {
	_fontsize = (_fontsize == undefined ? 15 : _fontsize);
	_letterspacing = (_letterspacing == undefined ? 3 : _letterspacing);
	FullAlpha = (FullAlpha == undefined ? 75 : FullAlpha);	
	Header2.style.textAlign="left";
	Header2.style.fontFamily="Arial";
	Header2.style.fontStyle="normal";
	Header2.style.fontSize=_fontsize+"";
	Header2.style.letterSpacing=_letterspacing+"";
	Header2.style.color="#999999";
	Header2.innerHTML=_txt;
	Header2.XtoBe=parseInt(parseInt(Header1.style.left)+Header1.clientWidth/2)-Header2.clientWidth/2;
	Header2.YtoBe=parseInt(Header1.style.top)+30;
	headerX = (headerX == undefined ? Header2.XtoBe : headerX);
	headerY = (headerY == undefined ? Header2.YtoBe : headerY);
	SetPos(Header2,headerX,headerY);
}

function Redirect(urlink,wndow){
	//wndow options are "same" or "new".  Default="same"
	wndow=(wndow==undefined ? "same" : wndow);
	ReportAction("Redirect: "+urlink);
	fnc=function(){
		window.location.href=urlink;
	}
	if(wndow.toLowerCase()=="new"){
		NewWindow=window.open(urlink,"test");
	} else{
		setTimeout("fnc();",1000);
	}
	
}

function DoRedirect(urlink){///Might turn part of this into an init / the other part into a call
	FormInputNames=["urlink"];
	FormInputValues=[urlink];
	FormInputTypes=["hidden"];
	FormInputLabels=[""];
	FormName="Redirect";
	FormURL="dbe10_redirect.php";
	FormFncCustom="";
	GenForm();
	document.Redirect.submit();
}

function DoEmail(eMailAddress){
	ENG.innerHTML+="Arrived email<br>";
	ReportAction("email: "+eMailAddress);
	fnc=function(){
		window.location.href="mailto:"+eMailAddress;
	}
	setTimeout("fnc();",500);
}

function XEQ_Download(SourcePath, DestPath) {
	ReportAction("Downloading "+SourcePath+" as "+DestPath);
	fnc=function(){
    	window.location="dbe10_download.php?SourcePath="+SourcePath+"&DestPath="+DestPath;
    }
    setTimeout("fnc();",500);
}

function XEQ_Upload(){
	ReportAction("Upload");
    setTimeout("window.location='http://trillionpictures.com/dbe10_upload.php';",1000);
}

function ReportActionViaSQL(ClickAction, Notify, EventID, Start, End, trt, BytesLoaded, BytesTotal){
	var fn=arguments.callee.name;
	//ENG.innerHTML+=fn+"<br>";
	VarArr=new Object();
	VarArr.action="get";
    VarArr.sql_query = "SELECT * FROM ClickAction WHERE EventID='"+EventID+"'";
    QueryStr=ArrToStr(VarArr);
	$.ajax({
		type: "POST",
		url: sqlPath,
		data: QueryStr,
		success: function(data){
			//ENG.innerHTML+=data+"<br>";
			ReturnVars=StrToArr(data);
			if(ReturnVars.FoundCount==0){//
				NowDate_Prior=NowDate;
				NowTime_Prior=NowTime;
				NowArr=GetNow().split("|");
				NowDate=NowArr[0];
				NowTime=NowArr[1];			
				VarArr=new Object();
// 				VarArr.action="get";
// 				VarArr.sql_query="INSERT INTO ClickAction";
// 				VarArr.sql_query +=" SET Date='"+NowDate+"'";
// 				VarArr.sql_query +=", Time='"+NowTime+"'";
// 				VarArr.sql_query +=", Date_Prior='"+NowDate_Prior+"'";
// 				VarArr.sql_query +=", Time_Prior='"+NowTime_Prior+"'";
// 				VarArr.sql_query +=", IP='"+remote_addr+"'";
// 				VarArr.sql_query +=", arrival_url='"+arrival_url+"'";
// 				VarArr.sql_query +=", http_host='"+http_host+"'";
// 				VarArr.sql_query +=", query_string='"+query_string+"'";
// 				VarArr.sql_query +=", http_referrer='"+http_referrer+"'";
// 				VarArr.sql_query +=", WebSite='"+WebSite+"'";
// 				VarArr.sql_query +=", Clipset='"+ActiveClipset+"'";
// 				VarArr.sql_query +=", CookieFL='"+CookieFL+"'";
// 				VarArr.sql_query +=", CookieJS='"+CookieJS+"'";
// 				VarArr.sql_query +=", http_user_agent='"+http_user_agent+"'";
// 				VarArr.sql_query +=", EventID='"+EventID+"'";
// 				VarArr.sql_query +=", IdxContacts='"+IdxContacts+"'";
// 				VarArr.sql_query +=", IdxEmailer='"+IdxEmailer+"'";
// 				VarArr.sql_query +=", ClickAction='"+ClickAction+"'";
// 				VarArr.sql_query +=", Start='"+Start+"'";
// 				VarArr.sql_query +=", End='"+End+"'";
// 				VarArr.sql_query +=", trt='"+trt+"'";
// 				VarArr.sql_query +=", SystemCapabilities='"+SystemCapabilities+"+"'";

				VarArr.action="ClickAction";
				VarArr.Date=escape(NowDate);
				VarArr.Time=escape(NowTime);
				VarArr.Date_Prior=escape(NowDate_Prior);
				VarArr.Time_Prior=escape(NowTime_Prior);
				VarArr.remote_addr=escape(remote_addr);
				VarArr.arrival_url=escape(arrival_url);
				VarArr.http_host=escape(http_host);
				VarArr.query_string=escape(query_string);
				VarArr.http_referrer=escape(http_referrer);
				VarArr.WebSite=escape(WebSite);
				VarArr.Clipset=escape(ActiveClipset);
				VarArr.CookieFL=escape(CookieFL);
				VarArr.CookieJS=escape(CookieJS);
				VarArr.http_user_agent=escape(http_user_agent);
				VarArr.EventID=escape(EventID);
				VarArr.IdxContacts=escape(IdxContacts);
				VarArr.IdxEmailer=escape(IdxEmailer);
				VarArr.ClickAction=escape(ClickAction);
				VarArr.Start=escape(Start);
				VarArr.End=escape(End);
				VarArr.trt=escape(trt);
				VarArr.SystemCapabilities=escape(SystemCapabilities);
 				QueryStr=ArrToStr(VarArr);
 				$.ajax({
 					type: "POST",
 					url: sqlPath,
 					data: QueryStr,
 					success: function(data){
 						//ENG.innerHTML+=data+"<br>";
 						ReturnVars=StrToArr(data);
 					}
 				});
 			} else {
 				if(http_host!="Local"){
					ENG.innerHTML+="Local<br>";
 				} 			
			}
			//ENG.innerHTML+="FoundCount: "+ReturnVars.FoundCount+"<br>";
			//ENG.innerHTML+="ReturnVars:"+data+"<br>";
		}
	});
}

function ReportAction(ClickAction, Notify, EventID, Start, End, trt, BytesLoaded, BytesTotal) {
	var fn=arguments.callee.name;
	//ENG.innerHTML+=fn+"<br>";
	ClickActionReport=new Object();
	ClickActionReport.Version = "ClickAction2";
	if(get_cookie("ClickActionCookie")==undefined || get_cookie("ClickActionCookie")==null){
		CurrentDate=new Date();
		ClickActionCookie=CurrentDate.getTime()+"_"+remote_addr;//.replace(/\./g,"")
		//ENG.innerHTML+=ClickActionCookie+"<br>";
		document.cookie = "ClickActionCookie="+ClickActionCookie+"; expires=1728000000; path=/";
	}
	CookieJS=get_cookie("ClickActionCookie");
	//Date, Time, Date_Prior, Time_Prior, remote_addr handled below
	ClickActionReport.arrival_url = arrival_url;
	ClickActionReport.http_host = http_host;
	ClickActionReport.query_string = query_string;
	ClickActionReport.http_referrer = http_referrer;
	ClickActionReport.http_user_agent = http_user_agent;
	ClickActionReport.WebSite = WebSite;
	ClickActionReport.Clipset = ActiveClipset;
	ClickActionReport.CookieFL = CookieFL;
	ClickActionReport.CookieJS = CookieJS;
	ClickActionReport.IdxContacts = "";
	ClickActionReport.IdxEmailer = "";
	ClickActionReport.ClickAction = ClickAction;
	ClickActionReport.SystemCapabilities = escape(SystemCapabilities);
	if (Arrival == true) {
		Notify = "Notify";
		Arrival = false;
	}
	ClickActionReport.Notify = "Never";
	if (EventID == undefined) {
		EventID = new Date().getTime();
	}
	ClickActionReport.EventID = EventID;
	Start=(Start == undefined ? "" : Start);
	End=(End == undefined ? "" : End);
	trt=(trt == undefined ? "" : trt);
	ClickActionReport.Start = Start;
	ClickActionReport.End = End;
	ClickActionReport.trt = trt;
	QueryStr=ArrToStr(ClickActionReport);
	ReportActionViaSQL(ClickAction, Notify, EventID, Start, End, trt, BytesLoaded, BytesTotal);
	/*
    $.ajax({
        type: "POST",
        url: "dbe10_ClickAction.php",
        data: QueryStr,
        success: function(data){
            ReturnVars=StrToArr(data);
            //ENG.innerHTML+="FoundCount: "+ReturnVars.FoundCount+"<br>";
            //ENG.innerHTML+="ReturnVars:"+data+"<br>";
        }
    });
    */
	if (Notify == "Notify") {
		Notify="";
		emailer=new Object();
		emailer.emode = "post";
		emailer.to = "centralservices@totallypostal.net";
		emailer.from = emailer.to;
		emailer.subject = WebSite+": "+ClickAction;
		emailer.body = "WebSite„ "+WebSite+"\nClickAction„ "+ClickAction+"\nremote_addr„ "+remote_addr+"\nCookieFL„ "+CookieFL+"\nCookieJS"+CookieJS+"\nhttp_host„ "+http_host+"\nquery_string„ "+query_string+"\narrival_url„ "+arrival_url+"\nhttp_referrer„ "+http_referrer+"\nhttp_user_agent„ "+http_user_agent;
		//emailer.pwd = sql_key;
		DoEmailer(false);
	}
}

function DoEmailer(IfReportAction){
	if(IfReportAction!=false){
		ReportAction(encodeURI("email\nfrom: "+emailer.from+"\nto: "+emailer.to+"\nMessage: "+emailer.body));
	}
	QueryStr=ArrToStr(emailer);
	$.ajax({
		type: "POST",
		url: "dbe10_email.php",
		data: QueryStr,
		success: function(data){
			ReturnVars=StrToArr(data);
			//ENG.innerHTML+="FoundCount: "+ReturnVars.FoundCount+"<br>";
			//ENG.innerHTML+="ReturnVars:"+data+"<br>";
		}
	});
}

