function tb_select_image(id) {
	alert("select image: " + id);
}

function tb_show_hide_info(div_id, link_open, link_close) {
	//alert(div_id);
	//alert(link_open);
	//alert(link_close);
	var elem = document.getElementById(div_id);
	if (elem == null) {
		alert('main div is null');
	}
	//alert('1');
	var elem_link_open = document.getElementById(link_open);
	//alert('2');
	var elem_link_close = document.getElementById(link_close);
	//alert('3');
	//alert(elem.style.display);
	if (elem != null && elem.style.display == 'none') {
		//alert('none');
		elem.style.display = 'inline';
		if (elem_link_close != null) {
			//alert('change to display close');
			elem_link_close.style.display = 'inline';
		}
		if (elem_link_open != null) {
			//alert('change to shut display open');
			elem_link_open.style.display = 'none';
		}
	}		
	else if (elem != null && (elem.style.display == 'inline' || elem.style.display == '')) {
		//alert('inline');
		elem.style.display = 'none';
		if (elem_link_close != null) {
			//alert('change to shut display close');
			elem_link_close.style.display = 'none';
		}
		if (elem_link_open != null) {
			//alert('change to display open');
			elem_link_open.style.display = 'inline';
		}
	}
		
}

function tb_sponsor_manager_logo_add(div_id,logo_id,the_html,the_select_id) {
	//alert('div: ' + div_id + ' logo_id: ' + logo_id);
	var logo_bucket = document.getElementById(div_id);
	//alert('2');
	if (logo_bucket != null) {
		//alert(the_html);
		the_html = decodeURIComponent((the_html + '').replace(/\+/g, '%20'));
		
		// Add a random marker to the div id
		the_rand = 'logos_for_this_sign_' + Math.random();
		
		the_html = the_html.replace(/logos_for_this_sign/g,the_rand);
		//alert(the_html);
		//if (logo_bucket.innerHTML == '(Sponsor logos will appear here)')
		//	logo_bucket.innerHTML = '';
		logo_bucket.innerHTML = logo_bucket.innerHTML + the_html;
		//alert(the_html);
		//alert('3');
		
		//alert('update select');
		the_select = document.getElementById(the_select_id);

		//var aryOptions=the_select.getElementsByTagName('option');
		if (logo_id != 0) {
			var opt=document.createElement('option');
			//alert('4');
			opt.appendChild(document.createTextNode(logo_id));
			opt.value=logo_id;
			the_select.appendChild(opt);
		}
		//alert('5');
		the_select.multiple=true;
		for (var i = 0; i < the_select.options.length; i++) {
            the_select.options[i].selected = true;
        }
        
		//the_select.selectedIndex=logo_id
		
		
		//var logo_checkboxes = document.getElementById(div_id);
	}
	//alert('finished adding a logo');
}

function tb_preprocess_sign_edit_select(select_id) {
	var the_select = document.getElementById(select_id);
	//alert(the_div);
	// Hide the div and select all options in the div
	if (the_select != null) {
		the_select.style.display = 'none';
		for (var i = 0; i < the_select.options.length; i++) {
            the_select.options[i].selected = true;
        }	
	}
}


function tb_draw_logo(nid,path,the_div) {
	if (nid != '') {
		alert('"' + 'nid: ' + nid + ', path: ' + path + ', the_div: ' + the_div + '"');		
	}
}


function tb_update_div(div_id,div_type,div_contents) {

	var the_div = document.getElementById(div_id);
	//alert(div_id);
	if (the_div == null) {
		//alert('null');
	}
	if (the_div != null && div_type == 'label') {
		//alert('1');
		the_div.innerHTML = div_contents;
	}
	else if (the_div != null && div_type == 'name') {
		//alert('2');
		the_div.innerHTML = div_contents;
	}
	else if (the_div != null && div_type == 'status') {
		//alert('3');
		if (div_contents == 'Completed') 
			the_div.setAttribute("class","signStatusCompleted");
		else
			the_div.setAttribute("class","signStatusInProgress");
		the_div.innerHTML = div_contents;
	}
	else if (the_div != null) {
		//alert('4');
		the_div.innerHTML = div_contents;
	}
}

function tb_replace_div_contents(div_id,the_html) {


	var the_div = document.getElementById(div_id);
	alert(div_id);
	if (the_div != null) {	
		the_html = decodeURIComponent((the_html + '').replace(/\+/g, '%20'));
		the_div.innerHTML = the_html;
	}
	
}

function tb_move_order_link_div(div_id,parent_id) {
	
	//alert('div: ' + div_id + ', parent: ' + parent_id);
	
	var the_parent = document.getElementById(parent_id);
	var the_div = document.getElementById(div_id);
	
	if (the_parent != null && the_div != null) {
		the_parent.appendChild(the_div);
	}
}


function tb_sponsor_manager_logo_remove(div_id,logo_id,the_select_id) {
	//alert('div: ' + div_id + ' logo: ' + logo_id + ' the_select_id: ' + the_select_id);
	var logo_shell = document.getElementById(div_id);
	//alert('2');
	if (logo_shell != null) {
		logo_shell.innerHTML = '';
		logo_shell.style.visibility = 'hidden';
	}
	
	// Remove the logo from the select
	var the_select = document.getElementById(the_select_id);
	if (the_select != null) {
		//the_select.style.display = 'none';
		//alert('looking to remove');
		for (var i = 0; i < the_select.options.length; i++) {
            if (the_select.options[i].value == logo_id) {
				//alert('removing');
				the_select.options[i] = null;
			}
        }	
	}
}



function increaseFontSize() {
	var min=8;
	var max=18;
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() {
	var min=8;
	var max=18;
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}

function tb_get_gallery_image (image) {
	
	alert(image);
	
}


function tb_admin_window_open (url,name) {

   my_window = window.open(url, name, "status=1,width=980,resizable=1,location=0,menubar=0,toolbar=0,scrollbars=1");

}

function tb_upload_window_open (url,name) {

   my_window = window.open(url, name, "status=1,width=680,height=400,resizable=1,location=0,menubar=0,toolbar=0,scrollbars=1");

}


