var ajax_url='/includes/cfc/ajaxBridge_user.cfc?wsdl';
/*
* function chkUserNameExists
* This function is ran after all default form validations pass
* By default the form will not submit, if this Ajax Call returns false
* then it submits the form for you, if not the username exists error displays
*/
function chkUserNameExists(cnt){
	if ($F('email') == $F('cEmail') || !cnt){
		// Parameters
		var pars='method=checkUserName&qUserName='+ $F('email');
		// New Ajax Request
		new Ajax.Request(ajax_url,{
			// changed method to post due to IE7 cache bug
			method: 'post',
			parameters:pars,
			onSuccess: function (transport){
				// une = Name Exists
				var une=transport.responseText.stripTags().strip();
				if (une == 0){
					if (cnt){
					// Name is good call submit form function
					// Set the action value
					$('theFrm')['action2'].value='CREATING REGISTRATION...';
					//
					$('theFrm')['action2'].disabled=true;
					// Submit Form
					document.theFrm.submit();
					}
				}else{
					// Name already exists call alert function
					if (cnt){alert('The e-mail address '+ $F('email') +' is already in use, please enter another e-mail address.');}
					$('email').className='inputWithError';
					$('cExists').update('E-mail already in use');
					$('cExists').show();
					if (!cnt){Effect.Pulsate('cExists',{ duration:.5, pulses:2, from:.25 });}
				}			
			}
		});
	}else{
		if (cnt){
			alert('Your e-mail entries do not match');	
		}
	}
}

function chkUserNameExists2(cnt){
	if ($F('email') != $F('oEmail')){
		// Parameters
		var pars='method=checkUserName&qUserName='+ $F('email');
		// New Ajax Request
		new Ajax.Request(ajax_url,{
			// changed method to post due to IE7 cache bug
			method: 'post',
			parameters:pars,
			onSuccess: function (transport){
				// une = Name Exists
				var une=transport.responseText.stripTags().strip();
				if (une == 0){
					if (cnt){
					// Name is good call submit form function
					// Set the action value
					$('theFrm')['action2'].value='UPDATING ACCOUNT...';
					$('theFrm')['action2'].disable();
					// Submit Form
					document.theFrm.submit();
					}
				}else{
					// Name already exists call alert function
					if (cnt){alert('The e-mail address '+ $F('email') +' is already in use, please enter another e-mail address.');}
					$('email').className='inputWithError';
					$('cExists').update('E-mail already in use');
					$('cExists').show();
					if (!cnt){Effect.Pulsate('cExists',{ duration:.5, pulses:2, from:.25 });}
				}			
			}
		});
	}else{
		if (cnt){
			// Submit Form
			$('theFrm')['action2'].value='UPDATING ACCOUNT...';
			$('theFrm')['action2'].disable();
			document.theFrm.submit();	
		}
	}
}

/*
*	function showMyMenu
*	Shows the myMenu menu using the blindDown scriptaculous effect
*/
function showMyMenu(){
	new Effect.BlindDown ('myMenuList',{duration:.2});
	
	// Parameters
	var pars='method=setMemberMenu&menuStatus=1';
	// New Ajax Request
	new Ajax.Request(ajax_url,{method: 'post',parameters:pars});
	
	$('myMenuControl').update('Click to close <img src="/includes/images/global/myMenu_arrowUp.gif" border="0" width="12" height="12" alt="" align="absmiddle" />');
	$('myMenuControl').onclick=function(){
			hideMyMenu();return false;
	}
}
/*
*	function hideMyMenu
*	Hides the myMenu menu using the blindUp scriptaculous effect
*/
function hideMyMenu(){
	new Effect.BlindUp ('myMenuList',{duration:.2});
	
	// Parameters
	var pars='method=setMemberMenu&menuStatus=0';
	// New Ajax Request
	new Ajax.Request(ajax_url,{method: 'post',parameters:pars});	
	
	$('myMenuControl').update('Click to open <img src="/includes/images/global/myMenu_arrowDown.gif" border="0" width="12" height="12" alt="" align="absmiddle" />');
	$('myMenuControl').onclick=function(){
			showMyMenu();return false;
	}
}
/*
**********************************
WINDOW OBJECT VARIABLES
**********************************
*/
	var WindowObjectReference = null; // global variable
	var PreviousUrl;	
/*
*	function openWin (Opens a centered window object)
*
*	@url = URL String (Required)
*	@win = Window Name (Required)
*	@myWidth = Window Width (Required)
*	@myHeight = Window Height (Required)
*	@scrollBars = Yes/No Value (Required)		
*/
function openWin(url,win,myWidth,myHeight,scrollBars){
	var tHeight=screen.height/2;
	var tWidth=screen.width/2;
	var top=tHeight-myHeight/2;
	var left=tWidth-myWidth/2;
	var Feats="width="+myWidth+",height="+myHeight+",top="+top+",left="+left+", screenY=" +top+",screenX="+left+",scrollbars="+scrollBars+", toolbar=no, status=yes, resizable=no,alwayRaised=yes";
	if(WindowObjectReference == null || WindowObjectReference.closed)
		{
			WindowObjectReference=window.open(url,win,Feats);
			WindowObjectReference.focus();
		}
		else if(previousUrl !=url)
		{
			WindowObjectReference=window.open(url,win,Feats);
			WindowObjectReference.focus();
		}
		else
		{
			WindowObjectReference.focus();
		}
	previousUrl=url;
}
/*
*	function chkPWDLen 
*	passed from user management cfforms to check the password minimum length
*	this function is set here because it is a global value which can be changed here
*/
function chkPWDLen(form, ctrl, value){
	if (value.length < 6){
		return false;
	}else{
		return true;
	}
}
function chkPWDLen2(form, ctrl, value){
	if (value.length!=0 && value.length < 6){
		return false;
	}else{
		return true;
	}
}

/*
*	function chkPWDMatch
*	passed from password reset form
*/
function chkPWDMatch(form, ctrl, value){
	if (form.n_password.value != form.c_password.value){
		return false;
	}else{
		return true;
	}
}


function hideArrow(elem){
	document.getElementById(elem).style.display="none";
}

function showArrow(elem){
	document.getElementById(elem).style.display="block";
}

/*
*	function showHideSimple (Closes one div object and displays another based on list)
*
*	@theList = List with 2 divs (div to close, div to open)
*/
function showHideSimple(theList){
	//split the list
	thisList=theList.split(',');
	// show the specified div
	document.getElementById(thisList[0]).style.display = "block";
	document.getElementById(thisList[1]).style.display = "none";
}
/*
*	function chkSelectValue 
*	passed from user management cfforms to check the select field has returned a positive value
*/
function chkSelectValue (form, ctrl, value){
	if (value == 0){
			return false;
		}else{
			return true;
		}
}

function loadAnimation(theMovie,theDiv,theSWF,theWidth,theHeight){
	var temp = theDiv + '_flsw';
	var so = new SWFObject("/includes/swf/"+theSWF,temp, theWidth, theHeight, "7");
	so.addParam("menu","false");
	so.addParam("bgcolor","#ffffff");
	so.addVariable("ldmov",theMovie);
	so.write(theDiv);		
}

// functions used in press player
function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		 return window[movieName];
	} else {
		 return document[movieName];
	}
}
function loadVid(theVid) {
	thisMovie("pressPlayerVid").loadVideo(theVid);
}
function stopVid(){
	thisMovie("pressPlayerVid").stopVideo();
}
