_editor_url = "../";                     // URL to htmlarea files
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }
if (win_ie_ver >= 5.5) {
document.write('<scr' + 'ipt src="' +_editor_url+ 'images/editor.js"');
document.write(' language="Javascript1.2"></scr' + 'ipt>');  
} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }

		
		
var remail=/^([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+\.+[a-zA-Z0-9-]+|[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+\.+[a-zA-Z0-9-]+\.+[a-zA-Z0-9-]+)$/;
var checkIfAlphabet=/[a-zA-Z]/;
var selectedFlag = 0;

function checkEmail(fieldvalue) {
	if(remail.test(fieldvalue)) {
		return false;
	} else {
		return true;
	}
}

function checkNumber(fieldvalue) {
	if(isNaN(fieldvalue)) {
		return true;
	} else {
		return false;
	}
}


function changeAdminPassword(formNm,Action,ActionType) {
	if(formNm.txt_OldPassword.value == "") {
		alert("Please enter your old password");
		formNm.txt_OldPassword.focus();
    } else if(formNm.txt_NewPassword.value == "") {
		alert("Please enter your new password");
		formNm.txt_NewPassword.focus();
	} else if(formNm.txt_ReConfirmNewPassword.value == "") {
		alert("Please re-confirm your new password");
		formNm.txt_ReConfirmNewPassword.focus();
	} else if(formNm.txt_NewPassword.value != formNm.txt_ReConfirmNewPassword.value) {
		alert("Your passwords did not match");
		formNm.txt_ReConfirmNewPassword.select();
	} else {
		formNm.action = Action;
		//formNm.hid_ActionType.value = ActionType;
		formNm.submit();		
	}
}

function submitRegistrationForm(formNm,Action,ActionType) {
	if(formNm.txt_SignInName.value == "") {
		alert("Please enter your sign-in name");
		formNm.txt_SignInName.focus();
	} else if(checkBlank(formNm.txt_SignInName.value)) {
		alert("Please enter your sign-in name");
		formNm.txt_SignInName.focus();
	} else if(checkSpace(formNm.txt_SignInName.value)) {
		alert("Blank spaces are not allowed");

		formNm.txt_SignInName.focus();
	} else if(checkIfIsChar(formNm.txt_SignInName.value)) {
		alert("The first character of the sign-in name should be a character");
		formNm.txt_SignInName.focus();
	} else if (checkSymbol(formNm.txt_SignInName.value)) {
		alert("Only letters,numbers,or underscores are allowed");
		formNm.txt_SignInName.focus();
	} else if(formNm.txt_Password.value == "") {
		alert("Please enter your password");
		formNm.txt_Password.focus();
	} else if(checkBlank(formNm.txt_Password.value)) {
		alert("Please enter your password");
		formNm.txt_Password.focus();
	} else if(checkLength(formNm.txt_Password.value)) {
		alert("Password should be atleast 6 characters long");
		formNm.txt_Password.focus();
	} else if(checkSpace(formNm.txt_Password.value)) {
		alert("Blank spaces are not allowed between the password");
		formNm.txt_Password.focus();
	} else if(checkSymbol(formNm.txt_Password.value)) {
		alert("Only letters,numbers,or underscores are allowed");
		formNm.txt_Password.focus();
	} else if(formNm.txt_ReConfirmPassword.value == "") {
		alert("Please reconfirm your password");
		formNm.txt_ReConfirmPassword.focus();
	} else if(checkBlank(formNm.txt_ReConfirmPassword.value)) {
		alert("Please reconfirm your password");
		formNm.txt_ReConfirmPassword.focus();
	} else if(formNm.txt_Password.value != formNm.txt_ReConfirmPassword.value) {
		alert("Your passwords did not match.");
		formNm.txt_Password.focus();
	} else if(formNm.txt_Name.value == "") {
		alert("Please enter your name");
		formNm.txt_Name.focus();
	} else if(checkBlank(formNm.txt_Name.value)) {
		alert("Please enter your name");
		formNm.txt_Name.focus();
	} else if(checkIfSelected(formNm)) {
		alert("Please select category from the drop down box");
	} else if(formNm.txt_Email.value == "") {
		alert("Please enter your email");
		formNm.txt_Email.focus();
	} else if(checkBlank(formNm.txt_Email.value)) {
		alert("Please enter your email");
		formNm.txt_Email.focus();
	} else if(checkEmail(formNm.txt_Email.value)) {
		alert("Invalid email address");
		formNm.txt_Email.focus();
	} else if(formNm.txt_Phone.value == "") {
		alert("Please enter your Phone number");
		formNm.txt_Phone.focus();
	} else if(checkBlank(formNm.txt_Phone.value)) {
		alert("Please enter your Phone number");
		formNm.txt_Phone.focus();
	}   else if(formNm.txt_Address1.value == "") {
		alert("Please enter your First Address");
		formNm.txt_Address1.focus();
	} else if(checkBlank(formNm.txt_Address1.value)) {
		alert("Please enter your First Address");
		formNm.txt_Address1.focus();
	}   else if(formNm.txt_City.value == "") {
		alert("Please enter your City");
		formNm.txt_City.focus();
	} else if(checkBlank(formNm.txt_City.value)) {
		alert("Please enter your City");
		formNm.txt_City.focus();
	} else if(formNm.txt_State.value == "") {
		alert("Please enter your State");
		formNm.txt_State.focus();
	} else if(checkBlank(formNm.txt_State.value)) {
		alert("Please enter your State");
		formNm.txt_State.focus();
	} else if(formNm.txt_Country.value == "") {
		alert("Please enter your Country");
		formNm.txt_Country.focus();
	} else if(checkBlank(formNm.txt_Country.value)) {
		alert("Please enter your Country");
		formNm.txt_Country.focus();
	} else if(formNm.txt_ZipCode.value == "") {
		alert("Please enter your Zip Code");
		formNm.txt_ZipCode.focus();
	} else if(checkBlank(formNm.txt_ZipCode.value)) {
		alert("Please enter your Zip Code");
		formNm.txt_ZipCode.focus();
	} else if(formNm.txtar_Comments.value == "") {
		alert("Please enter the description of your Company");
		formNm.txtar_Comments.focus();
	} else if(checkBlank(formNm.txtar_Comments.value)) {
		alert("Please enter the description of your Company");
		formNm.txtar_Comments.focus();
	} else {
		formNm.action = Action;
		formNm.hid_ActionType.value = ActionType;
		formNm.submit();
	}
}


function openWindow(pathName,windowName,widthNumber,heightNumber) {
	window.open(pathName,windowName,"toolbar=no,scrollbars=no,width="+widthNumber+",height="+heightNumber+",menubar=no,status=no,resizable=no,left=200px,top=100px");
}

function submitForm(formNm,action,moduleName,moduleId,Id,actionType) {
	formNm.action = action;
	formNm.hid_ModuleName.value = 	moduleName;
	formNm.hid_ModuleId.value = moduleId;
	formNm.hid_Id.value = Id;
	formNm.hid_ActionType.value = actionType;
	formNm.submit();
}

function validateFaq(frm) {
 if(frm.faqCategory.value=="default"){
 alert("please select category");
 frm.faqCategory.focus();
 return false;
 }
 
 else if(frm.txt_question.value==""){
 alert("please write question");
 frm.txt_question.focus();
 return false;
 }
 else if(frm.txt_answer.value==""){
 alert("please write answer");
 frm.txt_answer.focus();
 return false;
 }
 
 if(frm.faqCategory.value=="new"){
 a = prompt("enter new category name","");
 frm.newCategory.value = a;
 }
 
 return true;
}

function showFaqById(val){
window.location="index.php?file=viewfaq.php&id="+val
}

// **** START CAPITAL LETTER **** //
function capitalLetter (string) {
  var match;
  var r = '';
  string = string.toLowerCase();
  if (document.all) {
    var re = /\b\w/g;
    while ((match = re.exec(string))) {
      re = /(.|\n)\b\w/g;
      r += string.substring(0, match.index) + match[0].toUpperCase();
      string = string.substring(match.index + match[0].length);
    }
    r += string;
  }
  else {
    var re = /\b\w/g;
    var ind = 0;
    while ((match = re.exec(string))) {
      r += string.substring(ind, match.index) + match[0].toUpperCase();
      ind = re.lastIndex;
    }
    r += string.substring(ind)
  }
  return r;
}
// **** END CAPITAL LETTER **** //

// **** START ERROR ALERT WINDOW **** //
 var wndAlert = null;
 function errAlert(strMessage) {
	var strHtml=""
	var intScWidth,intScHeight,intXPos,intYPos;
	intScWidth = screen.availWidth;
	intScHeight = screen.availHeight;
	intXPos = ((intScWidth - 280) / 2);
	intYPos = ((intScHeight - 200) / 2);
	if (wndAlert != null) { // if the window has been created at some point
		if (wndAlert.closed) { // if the window has been closed by the kill icon
			wndAlert=null;
		}
		else {
			// close the window
			wndAlert.close();
			wndAlert=null;
		} // endif
	} // endif
	wndAlert=null;
 	strMessage = escape(strMessage);
  wndAlert=window.open("http://www.drinkingpartners.com/scripts/error1.php?frmMessage=" + strMessage,"DDErrRoot","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=360,height=200,screenX=" + intXPos + ",screenY=" + intYPos + ",left=" + intXPos + ",top=" + intYPos)
  wndAlert.focus();
}



// **** END ERROR ALERT WINDOW **** //


// registration form step one 
function validateinput(strValue)  {
	var objRegExp = /[\&\;\`\'\\\"\|\*\?\~\<\>\^\(\)\[\]\{\}\$]/;
	return !objRegExp.test( strValue );
}


function validateForm(theForm) {

var err_str_msg;
err_str_msg="Following characters are not allowed <br> &&nbsp;&nbsp; ;&nbsp;&nbsp; `&nbsp;&nbsp; '&nbsp;&nbsp; \\&nbsp;&nbsp; &quot&nbsp;&nbsp; |&nbsp;&nbsp; *&nbsp;&nbsp; ?&nbsp;&nbsp; ~&nbsp;&nbsp; <&nbsp;&nbsp; >&nbsp;&nbsp; ^&nbsp;&nbsp; (&nbsp;&nbsp; )&nbsp;&nbsp; {&nbsp;&nbsp; }&nbsp;&nbsp; $";


if (theForm.txt_gender_mine.selectedIndex == 0) {
	errAlert("You must specify your Gender")
	return false
}

if (theForm.txt_gender_looking.selectedIndex == 0) {
	errAlert("You must specify the Gender you are looking for")
	return false
}

if (!validateinput(theForm.txt_firstName.value))
{
	errAlert(err_str_msg);
	return false;
}

else if (theForm.txt_firstName.value == "")
{
		errAlert("You must enter your First Name")
		return false
}


if (theForm.txt_firstName.value.length < 2) {
		errAlert("We do not accept Inititals.<br>Please enter your First Name")
		return false
	}

if (!validateinput(theForm.txt_Email1.value))
{
	errAlert(err_str_msg);
	return false;
}
if (theForm.txt_Email1.value == "" ) {
		errAlert("The E-mail addresses is empty")
		return false
	}

	
if(!remail.test(theForm.txt_Email1.value)) {
    errAlert("EmailID is invalid");
	return false
	}

if (!validateinput(theForm.txt_Email2.value))
{
	errAlert(err_str_msg);
	return false;
}
if (theForm.txt_Email1.value != theForm.txt_Email2.value) {
		errAlert("The E-mail addresses entered do not match")
		return false
	}

if (!validateinput(theForm.txt_password.value))
{
	errAlert(err_str_msg);
	return false;
}	
if (theForm.txt_password.value.length < 4) {
		errAlert("Passwords must be a least 4 characters long")
		return false
	}
	
 if (frm.txt_dd.value == "default") {
    frm.txt_dd.focus();
	errAlert("Please enter day of birth");
	return false;
 }

 else if (frm.txt_mm.value == "default") {
    frm.txt_mm.focus();
	errAlert("Please enter month of birth");
	return false;
 }
 
 else if (frm.txt_yyyy.value == "default") {
    frm.txt_yyyy.focus();
	errAlert("Please enter year of birth");
	return false;
 }
 
 else if (frm.txt_country.value == "default") {
 	frm.txt_country.focus();
	errAlert("Please enter country");
	return false;
 }
 
 else if (frm.txt_state.value == "") {
    frm.txt_state.focus();
	errAlert("Please enter state");
	return false;
 }
 
if(frm.txt_town.value==2){
frm.txt_town.focus();
errAlert("Please select the town");
return false; 
}

if(frm.txt_town.value==47){
frm.txt_town.focus();
errAlert("Please select the town");
return false; 
}
if(frm.txt_town.value==54){
frm.txt_town.focus();
errAlert("Please select the town");
return false; 
}
 if(frm.txt_town.value==75){
frm.txt_town.focus();
errAlert("Please select the town");
return false; 
}

 if(frm.txt_town_near.value==""){
frm.txt_town_near.focus();
errAlert("Please select the town");
return false; 
}
 if (!validateinput(frm.txt_town_near.value))
{
	errAlert(err_str_msg);
	return false;
}
 if (frm.txt_zipcode.value == "") {
	frm.txt_zipcode.focus();
	errAlert("Please enter zip code");
	return false;
 }
 if (!validateinput(frm.txt_zipcode.value))
{
	errAlert(err_str_msg);
	return false;
}

	
 return true
}


function popSendMessage(file){
window.open(file,"Window1","menubar=no,width=500,height=300,toolbar=no,resizable=no,status=no,scrollbars=no,left=250,top=100");
}


function validateFormLocation(frm){

var err_str_msg;
err_str_msg="Following characters are not allowed <br> &&nbsp;&nbsp; ;&nbsp;&nbsp; `&nbsp;&nbsp; '&nbsp;&nbsp; \\&nbsp;&nbsp; &quot&nbsp;&nbsp; |&nbsp;&nbsp; *&nbsp;&nbsp; ?&nbsp;&nbsp; ~&nbsp;&nbsp; <&nbsp;&nbsp; >&nbsp;&nbsp; ^&nbsp;&nbsp; (&nbsp;&nbsp; )&nbsp;&nbsp; {&nbsp;&nbsp; }&nbsp;&nbsp; $";

 if (frm.txt_dd.value == "default") {
    frm.txt_dd.focus();
	errAlert("Please enter day of birth");
	return false;
 }

 else if (frm.txt_mm.value == "default") {
    frm.txt_mm.focus();
	errAlert("Please enter month of birth");
	return false;
 }
 
 else if (frm.txt_yyyy.value == "default") {
    frm.txt_yyyy.focus();
	errAlert("Please enter year of birth");
	return false;
 }
 
 else if (frm.txt_country.value == "default") {
 	frm.txt_country.focus();
	errAlert("Please enter country");
	return false;
 }
 
 else if (frm.txt_state.value == "") {
    frm.txt_state.focus();
	errAlert("Please enter state");
	return false;
 }
 
else if(frm.txt_town.value==2){
frm.txt_town.focus();
errAlert("Please select the town");
return false; 
}
else if(frm.txt_town.value==47){
frm.txt_town.focus();
errAlert("Please select the town");
return false; 
}
else if(frm.txt_town.value==54){
frm.txt_town.focus();
errAlert("Please select the town");
return false; 
}
else if(frm.txt_town.value==75){
frm.txt_town.focus();
errAlert("Please select the town");
return false; 
}

else if(frm.txt_town_near.value==""){
frm.txt_town_near.focus();
errAlert("Please select the town");
return false; 
}
else if (!validateinput(frm.txt_town_near.value))
{
	errAlert(err_str_msg);
	return false;
}
 else if (frm.txt_zipcode.value == "") {
	frm.txt_zipcode.focus();
	errAlert("Please enter zip code");
	return false;
 }
 else if (!validateinput(frm.txt_zipcode.value))
{
	errAlert(err_str_msg);
	return false;
}
return true;
}

function validateFormProfile(frm){

var err_str_msg;
err_str_msg="Following characters are not allowed <br> &&nbsp;&nbsp; ;&nbsp;&nbsp; `&nbsp;&nbsp; '&nbsp;&nbsp; \\&nbsp;&nbsp; &quot&nbsp;&nbsp; |&nbsp;&nbsp; *&nbsp;&nbsp; ?&nbsp;&nbsp; ~&nbsp;&nbsp; <&nbsp;&nbsp; >&nbsp;&nbsp; ^&nbsp;&nbsp; (&nbsp;&nbsp; )&nbsp;&nbsp; {&nbsp;&nbsp; }&nbsp;&nbsp; $";

 if (frm.txt_employment.value == "default") {
    frm.txt_employment.focus();
	errAlert("Please enter employment");
	return false;
 }

 else if (frm.txt_profession.value == "default") {
    frm.txt_profession.focus();
	errAlert("Please enter profession");
	return false;
 }
  else if (frm.txt_drinker.value == "default") {
    frm.txt_drinker.focus();
	errAlert("Please enter drinker");
	return false;
 }
 
  else if (frm.txt_education.value == "default") {
    frm.txt_education.focus();
	errAlert("Please enter education");
	return false;
 }
 

  else if (frm.txt_familyStatus.value == "default") {
    frm.txt_familyStatus.focus();
	errAlert("Please enter family status");
	return false;
 }
 
  else if (frm.txt_description.value == "") {
    frm.txt_description.focus();
	errAlert("Please enter description");
	return false;
 }
 /*
  else if (!validateinput(frm.txt_description.value))
{
	errAlert(err_str_msg);
	return false;
}
*/
  else if (frm.txt_accept_terms.checked!=true) {
    frm.txt_accept_terms.focus();
	errAlert("Please accept terms and conditions");
	return false;
 }
 
 frm.store.disabled = true;
return true;
}

function validateHomeSearch(frm){
 errAlert(frm.select_area.value);
 return true;
}

function FastSearch(frm){
 if(document.frmFastFind.txt_memberProfileId.value==""){
 alert("Please enter profile id ");
 document.frmFastFind.txt_memberProfileId.focus();
 return false;
 }

 else if(isNaN(document.frmFastFind.txt_memberProfileId.value)){
 alert("Please input Profile Id");
 document.frmFastFind.txt_memberProfileId.focus();
 return false;
 }
 document.frmFastFind.submit();
}

function performAction(iid){
window.location="delete_ignoredlist.php?iid="+iid;
}


function swaps(obj){
for(var i=1;i<=10;i++){
  if(i==obj){a = document.getElementById(i);a.className='ext4_over';}
  if(i==10 ){a = document.getElementById(i);a.className='ext5';}
  if(i!=obj && i!=10 ){a = document.getElementById(i);a.className='ext4';}
 }
}

 function showNewDimensionalImageCat(imgName,new_width){
	
 im         = new Image();
 im.src     = "photo_small/"+imgName;
 
 old_width  = parseInt(im.width);
 old_height = parseInt(im.height);
 
 if(old_width==0) old_width=200;
 if(old_height==0) old_height=200;
 
 new_width  = parseInt(new_width);
 ratio = (old_height/old_width);
 
 //	document.write("old height "+im.height+" and old width "+im.width+"<br>");
 new_height = parseInt(Math.ceil(ratio*new_width));
//document.write("<img src='../photo/"+imgName+"' width='"+new_width+"' height='"+new_height+"' border='0'>");
 document.write("<img src='../photo/"+imgName+"' width=100 border='0'>");
// document.write("<img src='"+imgName+"' width='"+new_width+"' height='"+new_height+"' border='0'>");
 //document.write("new height "+new_height+" and new width "+new_width+"<br>");
 }
 function showNewDimensionalImage(imgName,new_width){
 im         = new Image();
// im.src     = "/photo/"+imgName;
 im.src     = imgName;

 
 old_width  = parseInt(im.width);
 old_height = parseInt(im.height);
 
 if(old_width==0) old_width=200;
 if(old_height==0) old_height=200;
 
 new_width  = parseInt(new_width);
 ratio = (old_height/old_width);
 
 //	document.write("old height "+im.height+" and old width "+im.width+"<br>");
 new_height = parseInt(Math.ceil(ratio*new_width));
 //document.write("<img src='/photo/"+imgName+"' width='"+new_width+"' height='"+new_height+"' border='0'>");
 //document.write("<img src='"+imgName+"' width='"+new_width+"' height='"+new_height+"' border='0'>");
 document.write("<img src='../photo_small/"+imgName+"' width='100' height='100' border='0'>");
 
 //document.write("new height "+new_height+" and new width "+new_width+"<br>");
 }
 