/**
* LAST MOD: OCT 26 2009: DREW @ WWW.DREAMDESIGNSWEB.COM
* ------------------------------------------------------
*/
/**
* HIDE/SHOW HIP OPTION BASED ON MALE/FEMALE SELECTION
* t = self ref
* e = self event
* r = registration type (model, user)
*/
function hideHips(t,e,r) {
	//do nothing at the moment. we may need to utilize this.
}
/**
* SHOW SUDO UPLOAD PROGRESS WHEN SUBMIT IS CLICKED
*/
function sudoProgress() {
	document.getElementById('sudoUploadDiv').style.display="block";
	//first let's remove our scrollbars
	document.getElementById('mainBlock').scrollTop=0;
	document.getElementById('mainBlock').style.overflow="hidden";
}
/**
* DISPLAYS POST PROCESS MESSAGE (RESULTs)
* m = message type: success, duplicate or failed
* r = reg type: user or model
*/
function passResult(m,r) {
	var obj=document.getElementById('sudoUploadDiv');
	var divS="<div style=\"margin-top: 100px;\"><br /><br /><br /><br />";
	var divE="</div>";
	var retryButton="<p><input type=\"button\" id=\"tryAgain\" class=\"form-button\" value=\"Try Again\" onclick=\"closeErrorDiv(this,event);\" /></p>";
	if(m=="success") {
		obj.innerHTML=divS+"<img src=\"images/icon_checkbox.gif\" border=\"0\" />&nbsp; Thank you for submitting your information.<p>We will get back to you with the results as soon as possible.</p>"+divE;
	}else if(m=="failed") {
		obj.innerHTML=divS+"<img src=\"images/icon_alert.gif\" border=\"0\" />&nbsp; I'm sorry but your information could not be saved at this moment.<p>Please refresh your page and try again.</p>"+divE;
	}else if(m=="imgfailed") {
		obj.innerHTML=divS+"<img src=\"images/icon_notice.gif\" border=\"0\" />&nbsp; One or more of your images do not meet the specified criteria.<p>The following image formats are acceptable...<ul><li>JPG</li><li>PNG</li><li>BMP</li><li>GIF</li></ul></p><p><a href=\"#_self\" onclick=\"closeDiv(this,event,'sudoUploadDiv');\">Click here</a> to re-upload your pics</p>"+retryButton+divE;
	}else if(m=="duplicate") {
		obj.innerHTML=divS+"<img src=\"images/icon_notice.gif\" border=\"0\" />&nbsp; Thank you however, this information is already in our system."+retryButton+divE;
	}else if(m=="captcha") {
		obj.innerHTML=divS+"<img src=\"images/icon_alert.gif\" border=\"0\" />&nbsp; The code you entered did not match what was displayed.<p>Please try again.</p>"+retryButton+divE;
	}
}
/**
* CLOSES SUBMISSION RESULT DIV (WHICH DISPLAYS UPON FORM POST RESULT)
*/
function closeErrorDiv(t,e) {
	document.getElementById('mainBlock').style.overflow="auto";
	document.getElementById('sudoUploadDiv').style.display="none";
	var content="<br /><br /><br /><br />";
		content+="<p class=\"px13\">";
		content+="<strong>Please wait, uploading in progress....</strong>";
		content+="</p>";
		content+="<br /><br />";
		content+="<img src=\"images/icon_loading.gif\" border=\"0\" />";
	document.getElementById('sudoUploadDiv').innerHTML=content;
	//
	changeCaptcha(t,'captchaImg');
}
/**
* CLOSE DIV
*/
function closeDiv(t,e,i) {
	document.getElementById(i).style.display="none";
}
/**
* CHECK REQUIRED FIELDS UPON SUBMISSION
*/
function erCheck(t) {
	//first check input fields
	var reqs={"fname":"First Name","lname":"Last Name","city":"City","email":"Email Address"};
	for(var i in reqs) {
		var val=document.getElementById(i).value.replace(/ /g,'');
		if(val=="") {
			alert("Please enter your "+reqs[i]);
			return false;
		}
	}
	//check country & state
	var isC=document.getElementById('country').selectedIndex;
	/*if(isC==0) {
		alert("Please enter your Country.");
		return false;
	}*/
	try{
		var isS=document.getElementById('state').selectedIndex;
		var isS=document.getElementById('state').value;
		if(isS==0 || isS=="") {
			alert("Please enter your State or Province");
			return false;
		}
	}catch(er) {
		var isS=document.getElementById('state').value;
		if(isS=="") {
			alert("Please enter your State or Province");
			return false;
		}
	}
	//now check gender
	var isM=document.getElementById('genderMale').checked;
	var isF=document.getElementById('genderFemale').checked;
	if(isM==false && isF==false) {
		alert("Please choose your gender.");
		return false;
	}
	//lastly let's make sure they've got a mobile number
	var mArea=document.getElementById('mobile_ac').value;
	var mPre=document.getElementById('mobile_px').value;
	var mNum=document.getElementById('mobile_num').value;
	if(mArea=="area code" || mArea=="are" || mArea=="") {
		alert("Please enter your full Mobile Number");
		return false;
	}else if(mPre=="prefix" || mPre=="pre" || mPre=="") {
		alert("Please enter your full Mobile Number");
		return false;
	}else if(mNum=="number" || mNum=="num" || mNum=="") {
		alert("Please enter your full Mobile Number");
		return false;
	}
	// Now we copy over our notes & captcha
	var isNotes=document.getElementById('notes').value;
	document.getElementById('hiddenNotes').value=isNotes;
	var isCaptcha=document.getElementById('forgotCaptcha').value;
	document.getElementById('hiddenCaptcha').value=isCaptcha;
	//
	sudoProgress();
	//
	document.getElementById('editUser').submit();
}
/**
* CLEARS INPUT FIELDS OR RESETS THEM TO DEFAULT VALUES IF BLANK
*/
function clearText(t,e,v) {
	if(e.type=="focus" && (t.value=="area code" || t.value=="prefix" || t.value=="number" || t.value=="5 - 10 characters")) {
		t.value="";
		t.style.color="#000000";
	}else if(e.type=="blur" && t.value=="") {
		t.value=v;
		t.style.color="#c0c0c0";
	}
}
/**
* CLEAR OUR INPUT FIELDS UPON FOCUS
*/
function clearField(t,e,v) {
	if(t.value=="email" || t.value=="password" || t.value=="5 - 10 characters") {
		t.style.color="#000000";
		t.value="";
	}else if(t.value=="") {
		t.style.color="#c0c0c0";
		t.value=v;
	}
}
/**
* SHOW/HIDE MORE UPLOAD PIC INPUTS
*/
function showMoreUpload(t,e) {
	var obj=document.getElementById('moreUploadDiv');
	if(obj.style.height=="75" || obj.style.height=="75px") {
		obj.style.height="1px";
	}else{
		obj.style.height="75px";
	}
}
/**
* CLOSE OUR PROFILE VIEWER
*/
function closeViewer() {
	document.getElementById('pvIframe').src="";
	document.getElementById('profileViewDiv').style.display="none";
}
/**
* LOAD REGISTRATION FORM
* t= self ref
* e = self event
*/
function loadForm(t,e) {
	window.location.replace('event_registration.php?load=registration&amp;reg_type=user');
}
/**
* CAPTURE KEYSTROKES + VALUE SO WE CAN DO AN AJX TO SEE IF SCREEN NAME IS TAKEN
* t = self ref
* e = self event
*/
function captureStroke(t,e) {
	try{
		var val=t.value;
		var kCode=e.keyCode;
		if(kCode!=32 && val.length>=4) {
			var rq=xmlObject(2500);
			if(typeof(rq)!="object") {
				alert(rq);
				return false;
			}
			var url="admin/ajax/ajax_calls.php";
			var params="action=checkavailable&row_id=null&user_id=null&user_name=null&value="+val+"&nocache="+(Math.random()*99999);
			var xmlSet=xmlParam(rq,url,params);
			rq.xmlSet;
			if(typeof(xmlSet)!="object") {
				alert(xmlSet);
				return false;
			}
			//if xml object is created, let's move on
			rq.onreadystatechange=function() {
				if(rq.readyState==4) {
					try{
						window.clearTimeout(timer);
					}catch(er) {
						//nothing needed here
					}
					//finally, if all looks well, let's process our info
					if(rq.status==200) {
						myInfo=rq.responseText;
						if(myInfo=="nomatch") {
							document.getElementById('ajaxMsgDiv').innerHTML="<img src=\"images/icon_checkbox.gif\" border=\"0\" /> - available";
						}else if(myInfo=="match") {
							document.getElementById('ajaxMsgDiv').innerHTML="<span style=\"color: #ff0000; font-size: 15px;\">*</span> <span style=\"color: #ff0000;\">already taken</span>";
						}
					}
				}
			}
 		}
	}catch(er) {
		//do nothing
	}
}
/**
* REQUESTING PASSWORD REMINDER FROM 'LOST PASSWORD' LINK
*/
function fetchPassword(t,e) {
	//first let's get our info
	var cap=document.getElementById('forgotCaptcha').value;
	var eml=document.getElementById('forgotEmail').value;
	if(cap.replace(/ /g,'')=="" || eml.replace(/ /g,'')=="") {
		alert("Please enter both the Captcha Code and Email Address.");
		return false;
	}
	//show our loading window
	document.getElementById('lpMessageDiv').style.display="block";
	//if good, let's do our ajax
	var rq=xmlObject(2500);
	if(typeof(rq)!="object") {
		alert(rq);
		return false;
	}
	var url="admin/ajax/ajax_calls.php";
	var params="action=requestpassword&row_id=null&user_id=null&user_name=null&cap="+cap+"&eml="+eml+"&nocache="+(Math.random()*99999);
	var xmlSet=xmlParam(rq,url,params);
	rq.xmlSet;
	if(typeof(xmlSet)!="object") {
		alert(xmlSet);
		return false;
	}
	//if xml object is created, let's move on
	rq.onreadystatechange=function() {
		if(rq.readyState==4) {
			try{
				window.clearTimeout(timer);
			}catch(er) {
				//nothing needed here
			}
			//finally, if all looks well, let's process our info
			if(rq.status==200) {
				myInfo=rq.responseText;
				if(myInfo=="wrongcaptcha") {
					document.getElementById('lpMessageDiv').innerHTML="<br /><br />The Captcha code you entered does not match.<p><a href=\"#_self\" onclick=\"closeLPMessage(this,event);\">Please try again</a></p>";
				}else if(myInfo=="noemail") {
					document.getElementById('lpMessageDiv').innerHTML="<br /><br />This Email address does not exist in our records.<p><a href=\"#_self\" onclick=\"closeLPMessage(this,event);\">Please try again</a></p>";
				}else if(myInfo=="sent") {
					document.getElementById('lpMessageDiv').innerHTML="<br /><br />An email has been sent with your password.<p>Please be sure to also check your spam box as sometimes these emails may end up there.</p>";
				}else if(myInfo=="emailfailed") {
					document.getElementById('lpMessageDiv').innerHTML="<br /><br />The email that was sent was returned.<p>Please contact us <a href=\"contact.php\">here</a> for assistance.</p>";
				}
			}
		}
	}
}
/**
* OPEN PASSWORD REMINDER POPUP DIV
*/
function openReminder(t,e) {
	document.getElementById('forgotPassDiv').style.display="block";
}
/**
* CLOSE PASSWORD REMINDER RESULT DIALOGUE DIV
*/
function closeLPMessage(t,e) {
	document.getElementById('lpMessageDiv').style.display="none";
}

/**
* DYNAMIC IMG UPLOAD
*/
function dynamicUpload(t,e,i) {
	// Show sudo progress
	document.getElementById('sudoLoad_'+i).src="images/icon_loading_4.gif";
	document.getElementById('sudoLoad_'+i).style.display="inline";
	// submit form
	document.getElementById('picUploadForm_'+i).submit();
}

function callbackUpload(m,r,i,a) {
	//
	if(typeof(a)=="object") {
		var brk=a['pic'][0].split('/');
		document.getElementById('pics_'+i).value=brk[brk.length-1];
		document.getElementById('sudoLoad_'+i).src="images/icon_checkbox.gif";
	}else if(a=="overlimit") {
		alert("This upload is over the max allowed limit");
		// Hide our sudo progress
		document.getElementById('sudoLoad_'+i).style.display="none";
	}else if(a=="notallowed") {
		alert("This file type is now allowed.\nPlease upload only....\nJPEG\nJPG\nPNG\nBMP\nGIF");
		// Hide our sudo progress
		document.getElementById('sudoLoad_'+i).style.display="none";
	}else{
		alert("An error occurred. Please try again.");
		// Hide our sudo progress
		document.getElementById('sudoLoad_'+i).style.display="none";
	}
}

/**
* RELOAD CAPTCHA
* t =	self ref
* d =	(opt) captcha div ID
*/
function changeCaptcha(t,d) {
	d=(!d ? "captchaImg" : d);
	document.getElementById(d).src="securimage/securimage_show.php?sid="+(Math.random()*99999);
}


/*=======================================*/
/**
* ONLY FOR THE SCW.JS FILE
*/
try{
	scwBaseYear=scwDateNow.getFullYear()-50;
	scwDropDownYears=40;
}catch(er) {
	//no scw.js loaded
}



