function include_CSS(file)
{
	var headID = document.getElementsByTagName("head")[0];         
	var cssNode = document.createElement('link');
	cssNode.type = 'text/css';
	cssNode.rel = 'stylesheet';
	cssNode.href = file;
	cssNode.media = 'screen';
	headID.appendChild(cssNode);
}

function include_Javascript(file)
{
	var headID = document.getElementsByTagName("head")[0];         
	var newScript = document.createElement('script');
	newScript.type = 'text/javascript';
	newScript.onload=scriptLoaded;
	newScript.src = file;
	headID.appendChild(newScript);
}

function swapImage(image_el, image_url)
{
  image_el.src = image_url;
}

function reloadDocument()
{
	window.location.reload();
}

function safeString(name){
	return name.replace("'", "'\\");
}

/*
function toggleDiv(id) {
	var el = document.getElementById(id);
	if (el.style.display == "none") {
		el.style.display = "block";
	}else {
		el.style.display = "none";
	}
}
function showDiv(id) {
	var el = document.getElementById(id);						
	el.style.display = "block";
}
function hideDiv(id) {
	var el = document.getElementById(id);						
	el.style.display = "none";
}
*/

function check_box_switch_all(obj_form, s_check_box_id) { 
	for (var i = 0; i < obj_form.elements.length; i++) { 
		var obj = obj_form.elements[i]; 
		if ((obj.id == s_check_box_id) && (obj.type == 'checkbox')) { 
			obj.checked = obj_form.chk_all.checked; 
		} 
	} 
} 

function clearField (field)
{
	if (field.value == field.defaultValue)
		field.value = '';
}
function restoreField (field)
{
	if (field.value == "")
		field.value = field.defaultValue;
}

function openToolkit(register) {
	var url = (!register) ? "../site/toolkit.php" : "../site/member/register_main.php";
	var w = 730;
	var crop_size = 80;
	var screen_height = 910;
	
	if (screen.height - crop_size > screen_height) {
		var h = screen_height;
	}else {
		var h = screen.height - crop_size;
	}

	var newwin = window.open(url,'toolkit','width='+w+',height='+h+',top='+(screen.height-h)/4 +',left='+(screen.width-w)/2+',location=0,directories=0,status=no, menuBar=no,scrollBars=yes,resizable=yes');
	if (newwin != null) {
		newwin.focus();
	}else{
		alert("The Citizens Toolkit was blocked! Please enable popups in your web browser!");
	}
}

function openToolkitURL(url) {
	var w = 730;
	var crop_size = 80;
	var screen_height = 910;
	
	if (screen.height - crop_size > screen_height) {
		var h = screen_height;
	}else {
		var h = screen.height - crop_size;
	}

	var newwin = window.open(url,'toolkit','width='+w+',height='+h+',top='+(screen.height-h)/4 +',left='+(screen.width-w)/2+',location=0,directories=0,status=no, menuBar=no,scrollBars=yes,resizable=yes');
	if (newwin != null) {
		newwin.focus();
	}else{
		alert("The Citizens Toolkit was blocked! Please enable popups in your web browser!");
	}
}

function openToolkitParam(page, id) {
	var url = "toolkit.php?page=" + page + "&id=" + id;
	var w = 730;
	var crop_size = 80;
	var screen_height = 910;
	
	if (screen.height - crop_size > screen_height) {
		var h = screen_height;
	}else {
		var h = screen.height - crop_size;
	}

	var newwin = window.open(url,'popup','width='+w+',height='+h+',top='+(screen.height-h)/4 +',left='+(screen.width-w)/2+',location=0,directories=0,status=no, menuBar=no,scrollBars=yes,resizable=yes');
	if (newwin != null) {
		newwin.focus();				
	}
}

function openEditWin(url, width, height) {		
	var w = width;
	var crop_size = 100;
	var screen_height = height;
	
	if (screen.height - crop_size > screen_height) {
		var h = screen_height;
	}else {
		var h = screen.height - crop_size;
	}
	
	var start = url.lastIndexOf('/')+1;
	var end = url.indexOf('.',start);
	if (end == 0) end = url.indexOf('?',start);	
	var identifier = url.substr(start,(end-start));	
	
	var edit_win = window.open(url,identifier,'width='+w+',height='+h+',top='+(screen.height-h)/4 +',left='+(screen.width-w)/2+',location=0,directories=0,status=yes, menuBar=no,scrollBars=yes,resizable=yes');
	if (edit_win != null) {
		edit_win.focus();		
	}else{
		alert("The window was blocked! Please enable popups in your web browser!");
	}
}

function openAddFriend(nID) {
	openEditWin('templates/modules/iframe/profile_addfriend.php?user=' + nID, 420,250)
}