//here you place the ids of every element you want.	

//These IDs used in editprofile
var ids_editprofile = new Array('basic_info','graffiti','places','photos','extended','blog','languages');
var ids_searchresults = new Array('place_results','product_results','event_results');

function switchid(id,file){	
	hideallids(ids_searchresults);
	showdiv(id);
}
function hideallids(file){
	//loop through the array and hide each element by id	
	for (var i=0;i<file.length;i++){
		if (document.getElementById(file[i]))
		{
			hidediv(file[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';
		}
	}
}
function showvis(id){
		//safe function to show an element with a specified id		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.visibility = 'visible';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.visibility = 'visible';
		}
		else { // IE 4
			document.all.id.style.visibility = 'visible';
		}
	}
}

function togglediv(id) {
	//safe function to show an element with a specified id		  
	if (document.getElementById) 
	{ // DOM3 = IE5, NS6
		if (document.getElementById(id).style.display == 'block')
		{
			document.getElementById(id).style.display = 'none';
		}
		else
		{ 
			document.getElementById(id).style.display = 'block';
		}
	}
	else 
	{
		if (document.layers) 
		{ // Netscape 4
			if (document.id.display == 'block')
			{	
				document.id.display = 'none';
			}
			else
			{
				document.id.display = 'block';
			}
		}
		else 
		{ // IE 4
			if(document.all.id.style.display == 'block')
			{
				document.all.id.style.display == 'none';
			}
			else
			{
				document.all.id.style.display == 'block';
			}
				
		}
	}
}

//alert to confirm deletion, will pick up the text from a hidden input field
//Used: editproduct.php, uploadphoto.php
function delete_confirm(form){
	var answer = confirm(document.getElementById('delete_confirm_text').innerHTML);
	if (answer){
		form.submit();
	}
}

//Following two functions highlight and de-highlight as you mouse over stuff.
//i is the ID of the check box, j is the id of the div to be colored
//Used: editproduct.php
//Change the color if the box has not been checked already.
function HL_over(i,j){
	var temp = document.getElementById(i)
		if (!temp.checked){			
			document.getElementById(j).style.backgroundColor=document.getElementById('selected_bgcolor').innerHTML;
		}
}
//only change the color back to white if the box has not been checked.
//otherwise, just leave it. 
function HL_out(i,j){
	var temp = document.getElementById(i)
		if (!temp.checked){			
			document.getElementById(j).style.backgroundColor='';
		}
}

//This funtion toggles to make all the textarea and input text boxes on the page with class="input_readonly" and readonly=readonly active and de-active.
//It also toggles what the text link that activates the text says
//The magic words to say: <div id="edit_text"><a href="javascript: toggle_text_active();">Edit</a></div>
//Controlling subjects with <input type="text" class="input_readonly" readonly="readonly"> OR <textarea class="input_readonly" readonly="readonly">
//XW
function toggle_text_active(){
	var i;
	var otherthing =  document.getElementById('edit_text');
	if (otherthing.firstChild.innerHTML == 'Cancel')
	{
		otherthing.firstChild.innerHTML = 'Edit';
	}else{
		otherthing.firstChild.innerHTML = 'Cancel';
	}
	var thing = document.product_edit_form.getElementsByTagName('input');
	for (i=0; i<thing.length; i++ )
	{
			if (thing[i].className == 'input_readonly')
			{
				thing[i].removeAttribute('readonly');
				thing[i].className = 'temp';			
			}else
				{
				thing[i].readonly = 'readonly';
				thing[i].className = 'input_readonly';			
			}					
	}
	var thing = document.product_edit_form.getElementsByTagName('textarea');
	for (i=0; i<thing.length; i++ )
	{
			if (thing[i].className == 'input_readonly')
			{
				thing[i].removeAttribute('readonly');
				thing[i].className = 'temp';			
			}else
				{
				thing[i].readonly = 'readonly';
				thing[i].className = 'input_readonly';			
			}					
	}
	
}

//this function takes care of the ugly side of popping a blank window with nothing in it. 
//if the win_width and win_height fields are left blank, then default 640 / 450 in opened

function popup_blank(url,win_width,win_height){
	if (win_width!=null &&win_width!='' && win_height!=null && win_height!='')
	{
		var settings = "width="+win_width+", height="+win_height+", scrollbars=no, toolbar=no, location=no, directories=no, status=no, menubar=no";
	}else{
		var settings = "width=640, height=450, scrollbars=no, toolbar=no, location=no, directories=no, status=no, menubar=no";
	}
	window.open(url,'mywindow',settings);
}