//THIS FUNCTION SET CKECHED ALL OR NOT
function setCheckAll(objfrm){
	var chkall = objfrm.chkAll.checked;
	var chkitemlength = objfrm.chkitem.length;
	if(chkall){
		if(chkitemlength == undefined ){
			objfrm.chkitem.checked = true;
		}else{
			 for(i=0;i<chkitemlength;i++){
				objfrm.chkitem[i].checked = true;
			 }
		}
	}else{
		if(chkitemlength == undefined ){
			objfrm.chkitem.checked = false;
		}else{
			 for(i=0;i<chkitemlength;i++){
				objfrm.chkitem[i].checked = false;
			 }
		}
	}
}

//THIS FUNCTION CHANGE MASSAGES STATUS UNREAD OR DELETE
function call_ajax_req(URL){
		 new Ajax.Updater('mid_body', URL, { parameters: $('frmSexP').serialize(true)
			, onLoading: showWaitingImage( 'mid_body' ),	evalScripts: true});
}

//THIS FUNCTION CHANGE MASSAGES STATUS UNREAD OR DELETE
function chngStatus(objfrm,action,file){
	var chkitemlength = objfrm.chkitem.length;
	var flg = 1;
	var count = 0 ;
	var tmp=0;
	//var memid=objfrm.memid.value;

	if(chkitemlength == undefined ){
			if(objfrm.chkitem.checked == true ){
				flg = 1;
				tmp = objfrm.chkitem.value ;
			}else{
				flg = 0;
			}
	}else{
			 for(i=0;i<chkitemlength;i++){
				if(objfrm.chkitem[i].checked == false){
					count++;
				}else{
					if(tmp == 0){
						tmp = objfrm.chkitem[i].value ;
					}else{
						tmp = objfrm.chkitem[i].value +","+tmp;
					}
				}
			  }
	}

	if(count == chkitemlength)
		flg = 0;
	if(flg == 0){
		alert("Please select atleast one RECORD(s)");
		return false;
	 }
	 objfrm.action.value =  action;
	 objfrm.message_ids.value =  tmp;
	 objfrm.file.value = 'check_messages_a';

	 if(action == 'delete') {
		 if(confirm("Are you Sure You Want to Delete the record(s).?")){
			  new Ajax.Updater('mid_body', 'index_ajax.php', { parameters: $('frmMsg').serialize(true)
			, onLoading: showWaitingImage( 'mid_body' ),	evalScripts: true});
			  //new Ajax.Updater('inbox', 'user/update_inbox.php', { onLoading: showWaitingImage( 'inbox' ),	evalScripts: true});
			 //objfrm.submit();
		 }

	 }else{
		 new Ajax.Updater('mid_body', 'index_ajax.php', { parameters: $('frmMsg').serialize(true)
			, onLoading: showWaitingImage( 'mid_body' ),	evalScripts: true});

		 //objfrm.submit();
	 }
}

//THIS FUNCTION CHANGE MASSAGES STATUS UNREAD OR DELETE
function chngStatus_new(objfrm,action){

	var chkitemlength = objfrm.chkitem.length;
	var flg = 1;
	var count = 0 ;
	var tmp=0;
	if(chkitemlength == undefined ){
			if(objfrm.chkitem.checked == true ){
				flg = 1;
				tmp = objfrm.chkitem.value ;
			}else{
				flg = 0;
			}
	}else{
			 for(i=0;i<chkitemlength;i++){
				if(objfrm.chkitem[i].checked == false){
					count++;
				}else{
					if(tmp == 0){
						tmp = objfrm.chkitem[i].value ;
					}else{
						tmp = objfrm.chkitem[i].value +","+tmp;
					}
				}
			  }
	}

	if(count == chkitemlength)
		flg = 0;
	if(flg == 0){
		alert("Please select atleast one checkbox");
		return false;
	 }
	 objfrm.action.value =  action;
	 objfrm.message_ids.value =  tmp;
	 objfrm.file.value = 'private_photos_a';

	 /*if(action == 'delete') {
		 if(confirm("Are You Sure ?")){
			objfrm.submit();
		 }
	 }else{
		 objfrm.submit();
	 }*/
	 if(action == 'delete') {
		 if(confirm("Are you Sure You Want to Delete the record(s).?")){
			  new Ajax.Updater('mid_body', 'index_ajax.php', { parameters: $('form2').serialize(true)
			, onLoading: showWaitingImage( 'mid_body' ),	evalScripts: true});
			 //objfrm.submit();
		 }
	 }else{
		 new Ajax.Updater('mid_body', 'index_ajax.php', { parameters: $('form2').serialize(true)
			, onLoading: showWaitingImage( 'mid_body' ),	evalScripts: true});
		 //objfrm.submit();
	 }
}
function openPopupabc(URL)
{
	//alert(URL);

	
			//new Ajax.Updater('inbox', 'http://www.bareback.com/user/update_inbox.php', { onLoading: showWaitingImage( 'inbox' ),	evalScripts: true});
			//ajax_req_forgotlogin('http://www.bareback.com/index_ajax.php?file=check_messages');
	
	


}
//THIS FUNCTION IS USE FOR OPEN POPUP
function openPopup(URL){

	var handelPopup;
	var checkbrow;
	//server_path= document.frmsearch.server_url.value;	
	handelPopup = window.open(URL, '', 'scrollbars=yes, resizable=no, menubar=no');
	handelPopup.resizeTo(810, 627);
	//code written by Ram on Wednesday, January 02, 2008 at 8:09 PM
    var sURL = URL;//window.document.URL.toString();
	if (sURL.indexOf("?") > 0)
	{
		var arrParams = sURL.split("?");

		var arrURLParams = arrParams[1].split("&");

		var arrParamNames = new Array(arrURLParams.length);
		var arrParamValues = new Array(arrURLParams.length);

		var i = 0;
		for (i=0;i<arrURLParams.length;i++)
		{
			var sParam =  arrURLParams[i].split("=");
			arrParamNames[i] = sParam[0];
			if (sParam[1] != "")
				arrParamValues[i] = unescape(sParam[1]);
			else
				arrParamValues[i] = "No Value";
		}
		//alert(arrParamValues[0]);
		if(arrParamValues[0]=='read_message')
		{
			new Ajax.Updater('inbox', 'http://www.bareback.com/user/update_inbox.php', { onLoading: showWaitingImage( 'inbox' ),	evalScripts: true});
			ajax_req_forgotlogin('index_ajax.php?file=check_messages');
		}
	}

}

//THIS FUNCTION USE FOR OPEN REPLAY TEMPLET //
function openReplyPopup(URL){
	var handelPopup;
	handelPopup = window.open(URL, '_self', 'scrollbars=yes, resizable=no, menubar=no');
	handelPopup.resizeTo(810, 627);

}

//THIS FUNCTION VALID FORWORD MESSAGE HANDLE
function validForwordMsg(){
	objfrm=document.frmFwdMessage;
	if(objfrm.txt_to.value == '') {
		alert("Please Select To")
		objfrm.txt_to.focus();
		return false;
	}
	if(objfrm.txt_subject.value == '') {
		alert("Please Enter Subject")
		objfrm.txt_subject.focus();
		return false;
	}
}
//add for the reply message functionality.
function validReplyMsg(){
	objfrm=document.frmReplayMessage;
	if(objfrm.txt_subject.value == '') {
		alert("Please Enter Subject")
		objfrm.txt_subject.focus();
		return false;
	}

}

//THIS IS SET VELUE //
function setValue(username,receiver_id){
	window.opener.document.frmFwdMessage.txt_to.value = username;
	window.opener.document.frmFwdMessage.receiver_id.value = receiver_id;
	//self.close();
	window.close();
}


//THIS FUNCTION DELETE MSG
function delConfirm(objfrm,message_id){
	if(confirm("Are You Sure ?")){
		window.opener.location.href = "index.php?file=check_messages&action=delete&message_id="+ message_id;
		self.close();
	}
}

//THIS FUNCTION DELETE MSG
function saveMsg(objfrm,message_id){

		window.opener.location.href = "index.php?file=check_messages&action=savemessage&message_id="+ message_id;

		self.close();
}

//this function for save msg in lightbox

function saveMsgLightbox(message_id){

		 var docObj = null;
	if (typeof window.ActiveXObject != 'undefined')
	{
		docObj = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		docObj = new XMLHttpRequest();
	}
	docObj.open("GET",'http://www.bareback.com/index.php?file=check_messages&action=savemessage&message_id='+ message_id, false);
	docObj.send(null);
	var Res = docObj.responseText;
	
   alert('The message has been saved.');
	
	
	
}


//THIS FUNCTION DELETE SAVE MSG
function delSaveMessageConfirm(objfrm,save_massege_id){
	if(confirm("Are You Sure ?")){
		window.opener.location.href = "index.php?file=save_messages&action=deletesave&save_massege_id="+ save_massege_id;
		self.close();
	}
}

//THIS FUNCTION CHANGE MASSAGES STATUS UNREAD OR DELETE
function chngSaveMsgStatus(objfrm,action){
	var chkitemlength = objfrm.chkitem.length;
	var flg = 1;
	var count = 0 ;
	var tmp=0;
	if(chkitemlength == undefined ){
			if(objfrm.chkitem.checked == true ){
				flg = 1;
				tmp = objfrm.chkitem.value ;
			}else{
				flg = 0;
			}
	}else{
			 for(i=0;i<chkitemlength;i++){
				if(objfrm.chkitem[i].checked == false){
					count++;
				}else{
					if(tmp == 0){
						tmp = objfrm.chkitem[i].value ;
					}else{
						tmp = objfrm.chkitem[i].value +","+tmp;
					}
				}
			  }
	}

	if(count == chkitemlength)
		flg = 0;
	if(flg == 0){
		alert("Please select atleast one checkbox");
		return false;
	 }
	 objfrm.action.value =  action;
	 objfrm.message_ids.value =  tmp;
	 objfrm.file.value = 'save_messages_a';

	 /*if(action == 'delete') {
		 if(confirm("Are You Sure ?")){
			objfrm.submit();
		 }
	 }else{
		 objfrm.submit();
	 }*/
	 if(action == 'delete') {
		 if(confirm("Are you Sure You Want to Delete the record(s).?")){
			  new Ajax.Updater('mid_body', 'index_ajax.php', { parameters: $('frmMsg').serialize(true)
			, onLoading: showWaitingImage( 'mid_body' ),	evalScripts: true});
		 }
	 }else{
		 new Ajax.Updater('mid_body', 'index_ajax.php', { parameters: $('frmMsg').serialize(true)
			, onLoading: showWaitingImage( 'mid_body' ),	evalScripts: true});
	 }
}

 //THIS OPEN POPUP FOR SEND MESSAGE
 function popUpOfSendMail(rowpal_member_id,ses_member_id){
	 server_path= document.frmsearch.server_url.value;
	 if(ses_member_id != ''){
		window.open(server_path+"index.php?file=send_msg&rowpal_member_id="+rowpal_member_id,'_new','scrollbars, width=800, height=593');
	 }else{
		location.href = "index.php?file=login&MSG_CODE=MUST_LOGIN"
	 }
 }


 //THIS FUNCITON CONFIRM MEMBER DETELE RAWPALS
 function deleteRawpals(objfrm , rowpal_id){
 	if(confirm("Are you Sure You Want to Delete the record(s).?")){
		objfrm.action.value = "deleterawpals"
		objfrm.file.value = "raw_pals_a"
		objfrm.rowpal_id.value = rowpal_id
		objfrm.submit();
	}
}

//THIS FUNCITON CONFIRM MEMBER DETELE CIRCUIT PARTIES
 function deleteRawpals1(objfrm , rowpal_id){
 	if(confirm("Are you Sure You Want to Delete the record(s).?")){
		objfrm.action.value = "deleterawpals"
		objfrm.file.value = "cir_parties_a"
		objfrm.rowpal_id.value = rowpal_id
		objfrm.submit();
	}
 }

function blockMember(URL){
	var handelPopup;
	server_path= document.frmsearch.server_url.value;
	handelPopup = window.open(server_path+URL, '_new', 'scrollbars=no, resizable=yes, menubar=no');
	handelPopup.resizeTo(420, 240);
}



function submitResone(objfrm , member_id, message_id , resone){
	window.opener.location.href = "index.php?file=block_user_resone_a&action=blockusers&member_id="+member_id+"&message_id="+message_id+"&resone="+resone;
	self.close();
}

function block_mem_profile(url,member_id, from_file)
{	
	window.location.href = url+"index.php?file=block_user_resone_a&action=blockusersprofile&member_id="+member_id+"&from_file="+from_file;	
}

function turnoff()
{
	if(confirm("Do you really want to Turn Off Your Profile?"))
	 {
		new Ajax.Updater('mid_body', 'index_ajax.php?file=turnoff', { onLoading: showWaitingImage( 'mid_body' ),	evalScripts: true});
	 }
}

//for guestbook to delete guest
function chkConfirm(objfrm , guestbook_id){
		if(confirm("Are You Sure ?")){
			new Ajax.Updater('mid_body', 'index_ajax.php?file=guestbook_a&guestbook_id='+guestbook_id, { onLoading: showWaitingImage( 'mid_body' ),	evalScripts: true});
		}
		return false;
	}
//for guestbook to approve guest
function chkApprove(objfrm , guestbook_id){
		new Ajax.Updater('mid_body', 'index_ajax.php?file=guestbook_a&act=approve&guestbook_id='+guestbook_id, { onLoading: showWaitingImage( 'mid_body' ),	evalScripts: true});
		return false;
	}
function setpref(frmObj,mem_id,img)
{
	imgval = '';
	for(x=0; x < document.frmPref.imager.length; x++){
		if(document.frmPref.imager[x].checked ){
			imgval = document.frmPref.imager[x].value;
			break;
		}
	}
	emailval = '';
	for(x=0; x < document.frmPref.email.length; x++){
		if(document.frmPref.email[x].checked ){
			emailval = document.frmPref.email[x].value;
			break;
		}
	}

	commval = '';
	for(x=0; x < document.frmPref.comm.length; x++){
		if(document.frmPref.comm[x].checked ){
			commval = document.frmPref.comm[x].value;
			break;
		}
	}
	lv_prefval = '';
	for(x=0; x < document.frmPref.lv_pref.length; x++){
		if(document.frmPref.lv_pref[x].checked ){
			lv_prefval = document.frmPref.lv_pref[x].value;
			break;
		}
	}

	mem_vis = '';
	for(x=0; x < document.frmPref.mem_vis.length; x++){
		if(document.frmPref.mem_vis[x].checked ){
			mem_vis = document.frmPref.mem_vis[x].value;
			break;
		}
	}

	url="index_ajax.php?file=member_preferences&action=set&member_id="+mem_id+"&email="+emailval+"&imager="+imgval+"&comm="+commval+"&lv_pref="+lv_prefval+"&mem_vis="+mem_vis;
	//alert(url);
	if(confirm("Do you really want to Set new preferences?"))
	 {
		new Ajax.Updater('mid_body', url, { onLoading: showWaitingImage( 'mid_body' ),	evalScripts: true});
	 }
}

function pphotostatus(frmObj,sts)
{
	document.frmReadMsg.action.value=sts;
	document.frmReadMsg.submit();
}

/*@cc_on @*/
/*@if (@_win32 && @_jscript_version>=5)

function window.confirm(str)
{
    execScript('n = msgbox("'+str+'","4132")', "vbscript");
    return(n == 6);
}

@end @*/

//for guestbook to delete guest
function confirmDeleteProfile()
{
	
	if(confirm("If you Delete this profile, you will not be able to use this Screen name or E-mail address again and you will not be able to have this account reactivated. If you want to simply Turn Off your profile, there is an area to do that. Do you wish to Delete your Profile?"))
	 {
		new Ajax.Updater('mid_body', 'index_ajax.php?file=turnoff&action=del_profile', { onLoading: showWaitingImage( 'mid_body' ),	evalScripts: true});
	 }
}

function chngSearchStatus(objfrm,action,file){
	var chkitemlength = objfrm.chkitem.length;
	var flg = 1;
	var count = 0 ;
	var tmp=0;
	//var memid=objfrm.memid.value;

	if(chkitemlength == undefined ){
			if(objfrm.chkitem.checked == true ){
				flg = 1;
				tmp = objfrm.chkitem.value ;
			}else{
				flg = 0;
			}
	}else{
			 for(i=0;i<chkitemlength;i++){
				if(objfrm.chkitem[i].checked == false){
					count++;
				}else{
					if(tmp == 0){
						tmp = objfrm.chkitem[i].value ;
					}else{
						tmp = objfrm.chkitem[i].value +","+tmp;
					}
				}
			  }
	}

	if(count == chkitemlength)
		flg = 0;
	if(flg == 0){
		alert("Please select atleast one RECORD(s)");
		return false;
	 }
	 objfrm.action.value =  action;
	 objfrm.message_ids.value =  tmp;
	 objfrm.file.value = 'view_saved_searches_a';

	 if(action == 'delete') {
		 if(confirm("Are you Sure You Want to Delete the record(s).?")){
			  new Ajax.Updater('mid_body', 'index_ajax.php', { parameters: $('frmMsg').serialize(true)
			, onLoading: showWaitingImage( 'mid_body' ),	evalScripts: true});
			  //new Ajax.Updater('inbox', 'user/update_inbox.php', { onLoading: showWaitingImage( 'inbox' ),	evalScripts: true});
			 //objfrm.submit();
		 }

	 }else{
		 new Ajax.Updater('mid_body', 'index_ajax.php', { parameters: $('frmMsg').serialize(true)
			, onLoading: showWaitingImage( 'mid_body' ),	evalScripts: true});

		 //objfrm.submit();
	 }
}
function funsel(val,objname)
{
	var abst=eval("document.frmAdvSearch."+objname);
	if(val.checked==true) {
		if(abst.value=='')
			abst.value=val.value;
		else
			abst.value=abst.value + "," +val.value;
	}else{
		var str="";
		if(abst.value!=''){
			var TempArray = abst.value.split(",");
			for(var i=0;i<TempArray.length;i++){
				if(val.value!=TempArray[i]){
					if(str=="")
						str=TempArray[i];
					else
						str +="," + TempArray[i];
				}
			}
		}
		abst.value=str;
	}
}
function OpenSortOrder(fileName)
{
   window.open (fileName,"mywindow",'width=800,height=290,scrollbars=no,resizable=no');
}