
function BO_jumpMenu(targ,selObj,restore){ //v3.0
 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
 if (restore) selObj.selectedIndex=0; }

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x; }

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; } }

function itemSelect(outputitem, outputlink) {

	$("selected_item").update ("<img src=\"/data/divinematch/assets/images/" + outputitem + "\" alt=\"\" title=\"\" />");
	$("selected_value").update(outputitem);

}

function ajax_update(s_to, s_from, s_send) {

	var s_message = "";
	var s_subject = ""
	var s_smile = "";
	var s_icon = "";

	if (s_send=="sendmessage") {
		s_subject = document.getElementById("subject").value;
		s_message = document.getElementById("message").value;
	}
	
	if (s_send=="sendgift") {
		s_message = document.getElementById("message").value;
		s_icon = document.getElementById("selected_value").innerHTML;

		if($("selected_item").innerHTML!="") {
			$("gift-list").update("");
			$("action").update("");
		}	
	}
	
	if (s_send=="sendsmile") {
		if($("selected_item").innerHTML!="") {
			$("smile-list").update("");
			$("action").update("");
		}
		s_icon = document.getElementById("selected_value").innerHTML;
	}
	
	if (s_send=="blockuser"||s_send=="hideuser"||s_send=="unblockuser"||s_send=="unhideuser") {
		$("popup-body").update("");
	}

	if (s_send=="closebox") {
		s_send = "popup-window";
	}

	String.prototype.trim = function() {
		return this.replace(/^\s+|\s+$/g,"");
	}
	
	 new Ajax.Updater(s_send, '/data/divinematch/scripts/ajax_divinematch.php', { 
		method: 'get',
		parameters: {sendoption: s_send, to: s_to, from: s_from, icon: s_icon, subject: s_subject, message: s_message},
		onComplete: function() {
			if(s_send=="blockuser") {
				$("popup-body").update("The user has now been blocked! <a  href=\"#\" class=\"cross\" onclick=\"Control.Modal.close(); window.location.reload();\" >Close</a>");
			
			}

			if(s_send=="hideuser") {
				$("popup-body").update("The user has now been hidden! <a  href=\"#\" class=\"cross\" onclick=\"Control.Modal.close(); window.location.reload();\" >Close</a>");
			
			}

			if(s_send=="unblockuser") {
				$("popup-body").update("The user has now been unblocked! <a  href=\"#\" class=\"cross\" onclick=\"Control.Modal.close(); window.location.reload();\" >Close</a>");
			
			}

			if(s_send=="unhideuser") {
				$("popup-body").update("The user has now been unhidden! <a  href=\"#\" class=\"cross\" onclick=\"Control.Modal.close(); window.location.reload();\" >Close</a>");
			
			}

			if(($(s_send).innerHTML.trim())=="1") {
				$("popup-body").update("Your message has been sent! <a  href=\"#\" class=\"cross\" onclick=\"Control.Modal.close();\" >Close</a>");
			}
		}
	});


}

function ajax_referrer(s_from) {
	 new Ajax.Updater('sendreferrer', '/data/divinematch/scripts/ajax_divinematch.php', { 
		method: 'get',
		parameters: {sendoption: 'referrer', from: s_from, message: $("referrer_message").innerHTML,email_address_1: $F("email_address_1"), email_address_2: $F("email_address_2"), email_address_3: $F("email_address_3"), email_address_4: $F("email_address_4"), email_address_5: $F("email_address_5")},
		onComplete: function() {
			$("popup-body").update("Your message have been sent! <a  href=\"#\" class=\"cross\" onclick=\"Control.Modal.close();\" >Close</a>");
		}
	});
}

function ajax_addreferrer(s_from) {

	 new Ajax.Updater('referrer_email', '/data/divinematch/scripts/ajax_divinematch.php', { 
		method: 'get',
		parameters: {sendoption: 'addreferrer', from: s_from, email_address_1: $F("email_address_1")}
	});
}




function manage_mbrelationships(matchbox, mb_action, mb_to, mb_from) {

	if(mb_action=="favouriteadd") {
	  if($F("inform_favorate")=="1") {
	    s_url_extra="&inform=1";
	  } else {
	    s_url_extra="&inform=0";
	  }
	} else {
	  s_url_extra="&inform=0";
	}

	var s_url = "http://www.divinematch.co.uk/index.php?type=" + matchbox + "&action=" + mb_action + "&user_id=" + mb_to + s_url_extra;

	new Ajax.Request(s_url,
	  {
	    method:'get',
	    onSuccess: function(transport){
	      Control.Modal.close();
		window.location.reload();
	    },
	    onFailure: function(){ alert('Something went wrong...') }
	  });



}

function manage_mbblockusers(matchbox, mb_action, mb_to, mb_from) {


	var s_url = "http://www.divinematch.co.uk/index.php?type=" + matchbox + "&action=" + mb_action + "&user_id=" + mb_to;

	new Ajax.Request(s_url,
	  {
	    method:'get',
	    onSuccess: function(transport){
	      Control.Modal.close();
		window.location.reload();
	    },
	    onFailure: function(){ alert('Something went wrong...') }
	  });



}

function manage_mbhideusers(matchbox, mb_action, mb_to, mb_from) {


	var s_url = "http://www.divinematch.co.uk/index.php?type=" + matchbox + "&action=" + mb_action + "&user_id=" + mb_to;

	new Ajax.Request(s_url,
	  {
// 	    method:'get',
	    onSuccess: function(transport){
	      Control.Modal.close();
		window.location.reload();
	    },
	    onFailure: function(){ alert('Something went wrong...') }
	  });



}

// Following 4 functions used for advanced search

function switchid(id){	
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}
