if (document.images)
{
  loadingImage = new Image(15,15); 
  loadingImage.src="/sysimages/ajax-flower_f0f0f0.gif";
}
else{
	var loadingImage ={
	src: '/sysimages/ajax-flower_f0f0f0.gif'
	};
}

function ajxr(r){
	eval(r);
}

function ajaxSaveForm(formid,action){
	ColdFusion.Ajax.submitForm(formid,action,ajxr);
}

function trim(str){
	return str.replace(/^\s*|\s*$/g,"");
}

function showWaitMessage(id,m,w,h){
	if(!w){
		var w = '300px';
	}
	if(!h){
		var h = '50px';
	}
	$(id).innerHTML = '<table width="'+w+'" align="center"><tr><td align="center" valign="middle" height="'+h+'"><img src="" alt="" width="15" height="15" border="0" align="absmiddle" id="loadImg'+id+'">&nbsp;' + m +'</td></tr></table>';
	$('loadImg'+id).src = loadingImage.src;
}

function zLoading(bID,action,loadClass){
	// Note this function assumes that the button class names are "myClassName", "myClassName:hover" and "myClassNameOver"
	// by default the button class willbe replaced with 'zButtonWorking', you can overide this with the 'loadClass' var.
	if(!action){action = 'start';}
	if(!loadClass){loadClass = 'zButtonWorking';}
	myButton = document.getElementById(bID);
	
	if (action == 'start'){		
		myButton.onmouseout = function(){};
		myButton.onmouseover = function(){};
		myButton.className = loadClass;	
	}else{
		myButton.onmouseout = function(){changeclass(action)};
		myButton.onmouseover = function(){changeclass(action+'Over')};
		myButton.className = action;
	}
}

function setPointer(theRow, thePointerColor)
{
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        var theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    for (var c = 0; c < rowCellsCnt; c++) {
        theCells[c].style.backgroundColor = thePointerColor;
    }

    return true;
} 

// Pop-Up Position

var cX = 0; var cY = 0; var rX = 0; var rY = 0;

function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}
function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}

if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }

function AssignPosition(d,xo,yo,height) {
try{
if(!xo){ xo = 1 }
if(!yo){ yo = -1 }
if(!height){height = 0}

if(self.pageYOffset) {
	rX = self.pageXOffset;
	rY = self.pageYOffset;
	}
else if(document.documentElement && document.documentElement.scrollTop) {
	rX = document.documentElement.scrollLeft;
	rY = document.documentElement.scrollTop;
	}
else if(document.body) {
	rX = document.body.scrollLeft;
	rY = document.body.scrollTop;
	}
if(document.all) {
	cX += rX; 
	cY += rY;
	}
d.style.left = (cX+xo) + "px";
if (yo != 'auto'){
	d.style.top = (cY-yo) + "px";
}else{
	bh = document.body.clientHeight;
	scrolled = getScrollXY();
	th = cY + height - scrolled;
	alert(th+' = '+cY+' + '+height+' - '+scrolled+' || bh='+bh);
	if (th > height){ 
		alert('too low gotta move it '+th+' calcd pos:'+cY);
		cY = (bh - height);
		alert(cY);
		}else{alert('it fits '+th);

		}
	d.style.top = (cY) + "px";
}
}
catch(e){
	alert('Error in AssignPosition: \n' + e.message);
}
}

function AssignPositionByID(d,xo,yo) {
try{
if(!xo){ xo = 1 }
if(!yo){ yo = -1 }
if(self.pageYOffset) {
	rX = self.pageXOffset;
	rY = self.pageYOffset;
	}
else if(document.documentElement && document.documentElement.scrollTop) {
	rX = document.documentElement.scrollLeft;
	rY = document.documentElement.scrollTop;
	}
else if(document.body) {
	rX = document.body.scrollLeft;
	rY = document.body.scrollTop;
	}
if(document.all) {
	cX += rX; 
	cY += rY;
	}
var id = document.getElementById(d);
id.style.left = (cX+xo) + "px";
id.style.top = (cY-yo) + "px";
}
catch(e){
	alert('Error in AssignPosition: \n' + e.message);
}
}
function hide(did,sc){
	try{
	if (!sc){ var sc = 'false';}else{this.SetCookie(group,0);}
	txt = document.getElementById(did);	
	txt.style.display = "none";	 
	}
	catch(e){	
	}
}

function show(did,sc){
	try{
	if (!sc){ var sc = 'false';}else{this.SetCookie(group,1);}
	txt = document.getElementById(did);
	txt.style.display = "block";
	}
	catch(e){	
	}
}

//<![CDATA[

//*****************************************************************************
// Do not remove this notice.
//
// Copyright 2001 by Mike Hall.
// See http://www.brainjar.com for terms of use.
//*****************************************************************************

// Determine browser and version.

function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}

//]]>
// end move a div code....

function getviewpoint(){ //get window viewpoint numbers
	var ie=document.all && !window.opera
	var domclientWidth=document.documentElement && parseInt(document.documentElement.clientWidth) || 100000 //Preliminary doc width in non IE browsers
	this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
	this.scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
	this.scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
	this.docwidth=(ie)? this.standardbody.clientWidth : (/Safari/i.test(navigator.userAgent))? window.innerWidth : Math.min(domclientWidth, window.innerWidth-16)
	this.docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
}

function checkTerms(){
	if($('agree').checked){
		zLoading('cButton');
		ajaxSaveForm('createProfile','comm_CreateProfile_Save.cfm');
	}
	else{
		alert('You must agree to the terms and conditions');
	}
}

function checkTermsNew(){
	if($('agree').checked){
		zLoading('cButton');
		document.createAccount.submit();
	}
	else{
		alert('You must agree to the terms and conditions');
	}
}
	
function commPop(template,args,load,loadWidth,loadHeight){
	if(!load){load = false;}
	if(!loadWidth){loadWidth='600';}
	if(!loadHeight){loadHeight='100';}
	this.getviewpoint();
	bw = this.docwidth;
	bh = this.docheight;
	sl = this.scroll_left;
	st = this.scroll_top;
	if(load){
		$('commPopup').innerHTML = '<div style="width:'+loadWidth+'px;padding:0px;margin:0px;height:'+loadHeight+'px;"><div style="position:absolute;top:50%;width:100%;text-align:center;"><img src="" alt="" width="15" height="15" border="0" align="absmiddle" id="loadImgPopUp">&nbsp;Loading...</div></div>';
		loadImgPopUp
		$('loadImgPopUp').src = loadingImage.src;
		$('commPopupWindow').style.display = "block";
		$('commPopupWindow').style.position = 'absolute';
		qew = document.getElementById('commPopupWindow');					
		ow=qew.offsetWidth;
		oh=qew.offsetHeight;
		lp = (sl+(bw-ow)/2);
		tp = (st+(bh-oh)/6);
		if (lp < 0){lp = 0;}
		if (tp < 0){tp = 0;}
		qew.style.left=lp+"px";
		qew.style.top=tp+"px";
	}
	DWRUtil.useLoadingImage("/sysImages/applications-internet_002t.png");
	DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'commPop', template, args, bw, bh, sl, st, ajxr);
}

var basicContent = '';
var contactContent = '';
var edworkContent = '';

function commProfileEdit(u,s,v){
	var setVar = s +'Content = $(\'profile_'+ s +'_content\').innerHTML;';
	eval(setVar);
	$('profile_' + s + '_action').style.display = 'none';
	showWaitMessage('profile_'+s+'_content','Loading...');
	DWRUtil.useLoadingImage("/sysImages/applications-internet_002t.png");
	DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'commProfileEdit', u, s, v, ajxr);
}

function commProfileView(u,s,c,v){
	if(c == 0){
		$('profile_' + s + '_action').style.display = 'inline';
		var GetVar = 'Content = $(\'profile_'+ s +'_content\').innerHTML = '+ s +'Content;';
		eval(GetVar);
	}
	else{
		DWRUtil.useLoadingImage("/sysImages/applications-internet_002t.png");
		DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'commProfileView', u, s, v, ajxr);
	}
}

function commSearch(s){
	if (trim(s) != ''){
		return true;
	}
	else{
		alert('Please enter something to search for.');
		return false;
	}
}

function commFriendReqPopUp(uID,fID){
	var args ={
		uID: uID,
		fID: fID
	};
	commPop('comm_FriendReqPopup_Form.cfm',args,true,'400');
}

function commFriendReqActPopUp(reqID,type){
	var args ={
		reqID: reqID,
		type: type
	};
	commPop('comm_FriendReqActPopup_Form.cfm',args,true,'400');
}

function commFriendReqPost(uID,fID,msg){
	DWRUtil.useLoadingImage("/sysImages/applications-internet_002t.png");
	DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'commFriendReqPost', uID, fID, msg, ajxr);
}

function commFriendReqAction(reqID,uID,fID,action,type,customD){
	if(!customD){
		var actionTxt = action;
	}
	else if(action == 'deny'){
		var actionTxt = customD;
	}
	if(confirm('Are you sure you want to ' + actionTxt + ' this request?')){
		if(type == 2){
			if($('fReqAccept')){zLoading('fReqAccept');}
			if($('fReqDeny')){zLoading('fReqDeny');}
		}
		
		//alert('nID: "'+nID+'"\nuID: "'+uID+'"\nfID: "'+fID+'"\nACT: "'+action+'"\nTYP: "'+type+'"');
		DWRUtil.useLoadingImage("/sysImages/applications-internet_002t.png");
		DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'commFriendReqAction', reqID, uID, fID, action, type, ajxr);
	}
}

function commFriendRemovePopUp(uID,fID,remRow){
	var args ={
		uID: uID,
		fID: fID,
		remRow: remRow
	};
	commPop('comm_FriendRemovePopUp_Form.cfm',args,true,'400');
}

function commFriendRemovePost(uID,fID,msg,remRow){
	DWRUtil.useLoadingImage("/sysImages/applications-internet_002t.png");
	DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'commFriendRemovePost', uID, fID, msg, remRow, ajxr);
}

function commGroupTransferPopup(gID,uID){
	var args ={
		gID: gID,
		uID: uID
	};
	commPop('comm_GroupTransferPopup_Form.cfm',args,true,'400');
}

function commGroupTransferPost(gID,uID){
	DWRUtil.useLoadingImage("/sysImages/applications-internet_002t.png");
	DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'commGroupTransferPost', gID, uID, ajxr);
}

function commCheckPost(){
	if(trim($('wbPost').value) != ''){
		ajaxSaveForm('myWbPost','comm_MyWorkbench_Submit.cfm');
		$('wbPost').value = '';
	}
	else{
		alert('Please enter a message');
	}
}

function commLoginVerify(login,password,returnPath,queryString,urID){
	if(!urID){urID='';}
	DWRUtil.useLoadingImage("/sysImages/applications-internet_002t.png");
	DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'commLoginVerify', login, password, returnPath, queryString, urID, ajxr);
}

function commLogout(){
	DWRUtil.useLoadingImage("/sysImages/applications-internet_002t.png");
	DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'commLogout', ajxr);
}

function editGallery(galID,galImgId,garageGal){
	if(!garageGal){var editUrl = 'comm_PhotoGalleryEdit.cfm';}else{var editUrl = 'comm_MyGarage_GalleryEdit.cfm';}
	if(!galImgId){
	window.location = editUrl+"?galID="+galID;
	}else{
	window.location = editUrl+"?galID="+galID+"&galImgId="+galImgId;
	}
}

function createGalleryPage(){
	window.location.href = "/comm_PhotoGalleryCreate.cfm";
}

function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

function commCarGalDelete(carGalID,userID){
	if(confirm('Are you sure you want to delete this car?')){
		showWaitMessage('garageCarInfo'+carGalID,'Deleting...',50,100);
		DWRUtil.useLoadingImage("/sysImages/applications-internet_002t.png");
		DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'commCarGalDelete', carGalID, userID, ajxr);
	}
}

function commSetStatus(userID,msg){
	if(trim(msg) == '' || trim(msg) == 'Status Message'){
		zLoading('statusB','zButton');
		alert('Please enter a Status message');
	}
	else{
		DWRUtil.useLoadingImage("/sysImages/applications-internet_002t.png");
		DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'commSetStatus', userID, msg, ajxr);
	}
}

function commClearStatus(userID){
	DWRUtil.useLoadingImage("/sysImages/applications-internet_002t.png");
	DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'commClearStatus', userID, ajxr);
}

function mySinglePhotoUpload(xo,yo,t,w,load,loadWidth){
	if(!xo){xo = 0;}
	if(!yo){yo = 'middle';}
	if(!t){t = 600;}
	if(!w){w = 900;}
	if(!load){load = false;}
	if(!loadWidth){loadWidth='600';}
	this.getviewpoint();
	bw = this.docwidth;
	bh = this.docheight;
	sl = this.scroll_left;
	st = this.scroll_top;
	
	$('myPhotoUploadWindow').style.display = "block";
				$('myPhotoUploadWindow').style.position = 'absolute';
				qew = document.getElementById('myPhotoUploadWindow');					
				ow=qew.offsetWidth;
				oh=qew.offsetHeight;
				lp = (sl+(bw-ow)/2);
				tp = (st+(bh-oh)/2);
				if (lp < 0){lp = 0;}
				if (tp < 0){tp = 0;}
				qew.style.left=lp+"px";
				qew.style.top="100px";
}

function myPhotoAlbumSelect(id){
	window.location = 'comm_PhotoGalleryEdit.cfm?galID='+id+'&choosePic=1';
}

function deleteGalImg(id,galID,imgID){
	if (confirm('Are you sure you want to Delete this Image from your Gallery?')){
	zLoading('delButton'+id);
	DWRUtil.useLoadingImage("/sysImages/applications-internet_002t.png");
	DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'commDeleteImage', id, galID, imgID, ajxr);
	}
}

function commGalDelete(galID,userID){
	if (confirm('Are you sure you want to Delete this Entire Gallery?')){
	//zLoading('delButton'+id);
	DWRUtil.useLoadingImage("/sysImages/applications-internet_002t.png");
	DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'commGalDelete', galID, userID, ajxr);
	}
}

function commentDelete(id){
	if (confirm('Are you sure you want to delete your comment?'))
	{
	DWRUtil.useLoadingImage("/sysImages/applications-internet_002t.png");
	DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'commentDelete', id, ajxr);
	}
}

function commPostComment(id,actionID,actionType,userID,toUserID){
	var commentBox = 'commentPost' + id + '' + actionID;
	$(commentBox).disabled;
	zLoading('postCommentButton' + id + '' + actionID);
	if(trim($(commentBox).value) != ''){
		DWRUtil.useLoadingImage("/sysImages/applications-internet_002t.png");
		DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'commPostComment', id, actionID, actionType, userID, toUserID, $(commentBox).value, ajxr);
	}
	else{
		alert('Please enter a comment');
	}
}
function openthread(Thread_ID,MessageCount,xo,yo,t,w,load,loadWidth){
$('innerThreadSampler').style.display = "none";
$('loadingThread').style.display = "block";
qew = document.getElementById('threadPreview');
if (qew.style.display != 'block'){
if(!xo){xo = 0;}
	if(!yo){yo = 'middle';}
	if(!t){t = 600;}
	if(!w){w = 900;}
	if(!load){load = false;}
	if(!loadWidth){loadWidth='600';}
	this.getviewpoint();
	bw = this.docwidth;
	bh = this.docheight;
	sl = this.scroll_left;
	st = this.scroll_top;
	
	$('threadPreview').style.display = "block";
				$('threadPreview').style.position = 'absolute';
				qew = document.getElementById('threadPreview');					
				ow=qew.offsetWidth;
				oh=qew.offsetHeight;
				lp = (sl+(bw-ow)/2);
				tp = (st+(bh-oh)/2);
				if (lp < 0){lp = 0;}
				if (tp < 0){tp = 0;}
				qew.style.left="10px";
				qew.style.top=tp+"px";
}	
	DWRUtil.useLoadingImage("/sysImages/applications-internet_002t.png");
	DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'commThreadPreview', Thread_ID, 0 , ajxr);
	
	//show('threadPreview');
	//<cfoutput>window.location.href = "http://www.minimania.com/web/threadid/"+Thread_ID+"/#mdtemplate#";</cfoutput>
}

function commGroupFriendInvite(chk){
	if (chk){
		$('groupInvRow').style.display = '';
		$('groupInvMsgRow').style.display = '';
	}
	else{
		$('groupInvRow').style.display = 'none';
		$('groupInvMsgRow').style.display = 'none';
	}
}

function commGroupFriendSelect(userID,chk){
	if (chk){
		$('userInv'+userID).style.border = '1px solid #2345c2';
		$('userInv'+userID).style.background = '#b6bdd2';
	}
	else{
		$('userInv'+userID).style.border = '1px solid #f0f0f0';
		$('userInv'+userID).style.background = '#FFFFFF';
	}
}

function commGroupFriendSelectAll(userIDs,chk){
	var chkArray = userIDs.split(",");
	for(var i=0; i<chkArray.length; i++){
  		commGroupFriendSelect(chkArray[i],chk);
		$('userInvChk'+chkArray[i]).checked = chk;
	}
}