/*************************SEARCH***************************/
function getPlaceResult_Search()
{
	var zip = $("zip").value;
	var city = $("city").value;
	var state = $("state").value;
	
	var url = HTTPURL+'dispatch/getcitybyzip.php?zip='+zip+'&city='+city;
	var myAjax = new Ajax.Updater('div_city',url,{ method: 'get' });
	
	url = HTTPURL+'dispatch/getstatebyzip.php?zip='+zip+'&state='+state;
	myAjax = new Ajax.Updater('div_state',url,{ method: 'get' });
}

function getPlaceResult_Register(field_id)
{
	var zip;
	var city;
	var state;
	var field;

	if(field_id==1)
	{
		zip = $("ind_zip").value;
		
		city = $("ind_city").value;
		state = $("ind_state").value;
		
		field = "ind_";
	}
	else
	{
		zip = $("zip").value;
		
		city = $("city").value;
		state = $("state").value;
		
		field = "";
	}
	var url = HTTPURL+'dispatch/getcitybyzip_register.php?zip='+zip+'&city='+city+'&field='+field_id;
	var myAjax = new Ajax.Updater(field+'div_city',url,{ method: 'get' });
	
	url = HTTPURL+'dispatch/getstatebyzip_register.php?zip='+zip+'&state='+state+'&field='+field_id;
	var myAjax1 = new Ajax.Updater(field+'div_state',url,{ method: 'get' });
}

function showAlphabet()
{
	var zip = $("zip").value;
	var city = $("city").value;
	var state = $("state").value;
	if((zip.length==0 || zip=='Enter ZIP') && (city.length==0 || state.length==0))
	{
		ErrorAlert();
		return false;
	}
	$("alphabet").style.display="block";
	return true;
}

function ErrorAlert()
{
	alert("Please enter zip code or city and state");
}

function ClearInputField(id)
{
	$(id).value = "";
}

function showAlphabetByZip()
{
	var city_found = parseInt($("s_city_found").innerHTML,10);
	
	if(city_found>0)
	{
		$("alphabet_by_city").style.display="block";
		
		$("city").innerHTML = $("s_city").value;
	}
	else
	{
		$("alphabet_by_city").style.display="none";
	}
}
/*************************SEARCH***************************/

function showWarningBox()
{
	/*alert("By clicking the OK button below you agree that you are 100% fully responsible for the authenticity of posted photos, videos and information included in the profile.\n\nTHIS WEBSITE IS NOT INTENDED FOR REVENGE.\n\nIT IS INTENDED TO PROMOTE COMMUNICATION BETWEEN TWO PEOPLE BEFORE SOMEONE IS POSTED.\n\nIF ONE OF THEM IS THINKING OF OR HAS ALREADY CHEATED THEY SHOULD HAVE A CONVERSATION TO SEE IF THE RELATIONSHIP IS WORTH CONTINUING.");*/
	/*alert("By clicking the OK button below you agree that you are 100% fully responsible for the authenticity of posted photos, videos and information included in the profile.");*/
	/*alert("By clicking the OK button below you agree that you are at least 18 years of age and that you are 100% fully responsible for the authenticity of posted photos, videos and information included in the profile.");*/
	alert("By clicking the OK button below you agree that you are at least 18 years of age and that you are 100% fully responsible for the authenticity of posted photos, videos and information included in the profile.\n\nPornography is ABSOLUTELY NOT permitted in any profile. We strongly discourage photos with people's kids in them.");
}

function showConfirmPost()
{
	/*return confirm("If the person you are posting contacts CheaterRegistry.com and states that the information\nor other evidence you've provided is false then we will contact you for verification.\n\nTo remove someone that you have posted to this site please email\n support@CheaterRegistry.com\nand their profile will be taken down within 24 hours.");*/
	/*return confirm("If the person you are posting contacts CheaterRegistry.com and states that the information or other evidence you've provided is false then we will contact you for verification.\n\nTo remove someone that you have posted to this site please email support@CheaterRegistry.com\nand their profile will be taken down within 24 hours.");*/
	return confirm("If the person you are posting contacts CheaterRegistry.com and states that the information or other evidence you've provided is false then we will contact you for verification.\n\nTo remove someone that you have posted to this site please go to the Contact Us page, email us their full name and the reason you are taking it down and their profile will be removed within 24 hours.");
}

function SwapImage(el,uri)
{
	el.src=uri;
}	

function Document_Click(e)
{
	if (!e) var obj = window.event.srcElement;
	else var obj = e.target;
	while (obj.nodeType != 1)
	{
		obj = obj.parentNode;
	}
	if (obj.tagName == 'DIV') return;
	
	if(typeof g_oMenu != 'undefined' && g_oMenu)
	{
		g_oMenu.style.display = "none"
		g_oMenu = null;
		document.onclick = null;
	}
	else return;
}

function HideMenu(div)
{
	if(typeof g_oMenu != 'undefined' && g_oMenu && (div.id != g_oMenu.id))
	{
		g_oMenu.style.display = "none"
		g_oMenu = null;
		document.onclick = null;
	}
	else return;
}

function switchdiv(div_1, div_2)
{
	if (document.getElementById)	{
	    if(!document.getElementById(div_1)) return ;
	    if(!(document.getElementById(div_1).style)) return ;
	    if(!(document.getElementById(div_1).style.display)) return ;

		var state_1 = document.getElementById(div_1).style.display;
		if(state_1=="none") {
        		document.getElementById(div_1).style.display="block";
        		document.getElementById(div_2).style.display="none";
	     }
	    if(state_1=="block") {
        		document.getElementById(div_2).style.display="block";
        		document.getElementById(div_1).style.display="none";
	     }
	}
	else if (document.all)	{
	    if(!document.all[div_1]) return ;
	    if(!(document.all[div_1].style)) return ;
	    if(!(document.all[div_1].style.display)) return ;

		var state_1 = document.all[div_1].style.display;
		if(state_1=="none") {
		        document.all[div_1].style.display = "block";
		        document.all[div_2].style.display = "none";
		}
		if(state_1=="block") {
        		document.getElementById(div_1).style.display="none";
        		document.getElementById(div_2).style.display="block";
	     }
    }
}

function showhide()
{
	var nArguments = arguments.length;
	
	function __showhide_one_argument(div)
	{
		HideMenu(document.getElementById(div));
		state = document.getElementById(div).style.display;
		g_oMenu = document.getElementById(div);
		
		if(state == "none")
		{
			g_oMenu.style.display="block";
			g_oMenu.style.visibility = 'visible';
			g_oMenu = document.getElementById(div);
			setTimeout("document.onclick = Document_Click",100);
		}
		else
		{
			g_oMenu.style.display="none";
			g_oMenu.style.visibility = 'visible';
			g_oMenu = null;
		}
		g_oMenu = document.getElementById(div);
		
	}
	
	function __showhide_two_arguments(div,ensurevis)
	{
//		HideMenu(document.getElementById(div));
		state = document.getElementById(div).style.display;
		g_oMenu = document.getElementById(div);
		
		if(state == "none") { g_oMenu.style.display="block";}
		else { g_oMenu.style.display = "none";}
		g_oMenu.style.visibility = 'visible';
	}
		
	if(nArguments == 1) return __showhide_one_argument(arguments[0]);
	else if(nArguments == 2) return __showhide_two_arguments(arguments[0],arguments[1]);
	else return false;
}

// Multiple combo functions =============================

function moveUpList(listField)
{
	if ( listField.length == -1) {  // If the list is empty
	  alert("There are no values which can be moved!");
	} else {
	  var selected = listField.selectedIndex;
	  if (selected == -1) {
	     alert("You must select an entry to be moved!");
	  } else {  // Something is selected
	     if ( listField.length == 0 ) {  // If there's only one in the list
	        alert("There is only one entry!\nThe one entry will remain in place.");
	     } else {  // There's more than one in the list, rearrange the list order
	        if ( selected == 0 ) {
	           alert("The first entry in the list cannot be moved up.");
	        } else {
	           // Get the text/value of the one directly above the hightlighted entry as
	           // well as the highlighted entry; then flip them
	           var moveText1 = listField[selected-1].text;
	           var moveText2 = listField[selected].text;
	           var moveValue1 = listField[selected-1].value;
	           var moveValue2 = listField[selected].value;
	           listField[selected].text = moveText1;
	           listField[selected].value = moveValue1;
	           listField[selected-1].text = moveText2;
	           listField[selected-1].value = moveValue2;
	           listField.selectedIndex = selected-1; // Select the one that was selected before
	        }  // Ends the check for selecting one which can be moved
	     }  // Ends the check for there only being one in the list to begin with
	  }  // Ends the check for there being something selected
	}  // Ends the check for there being none in the list
}

//Hopefully the code makes sense. It is commented pretty well, so that should help. For moving down in the list, the code is quite similar:

function moveDownList(listField)
{
	if ( listField.length == -1) {  // If the list is empty
	  alert("There are no values which can be moved!");
	} else {
	  var selected = listField.selectedIndex;
	  if (selected == -1) {
	     alert("You must select an entry to be moved!");
	  } else {  // Something is selected
	     if ( listField.length == 0 ) {  // If there's only one in the list
	        alert("There is only one entry!\nThe one entry will remain in place.");
	     } else {  // There's more than one in the list, rearrange the list order
	        if ( selected == listField.length-1 ) {
	           alert("The last entry in the list cannot be moved down.");
	        } else {
	           // Get the text/value of the one directly below the hightlighted entry as
	           // well as the highlighted entry; then flip them
	           var moveText1 = listField[selected+1].text;
	           var moveText2 = listField[selected].text;
	           var moveValue1 = listField[selected+1].value;
	           var moveValue2 = listField[selected].value;
	           listField[selected].text = moveText1;
	           listField[selected].value = moveValue1;
	           listField[selected+1].text = moveText2;
	           listField[selected+1].value = moveValue2;
	           listField.selectedIndex = selected+1; // Select the one that was selected before
	        }  // Ends the check for selecting one which can be moved
	     }  // Ends the check for there only being one in the list to begin with
	  }  // Ends the check for there being something selected
	}  // Ends the check for there being none in the list
}

function allSelect(el)
{
	for (i=0;i<el.length;i++) el.options[i].selected = true;
}

// End Multiple combo fncs

function SwichImgs(img,src)
{
	document.getElementById(img).src = src;
}