function ContactUs(website_description)
{
	document.write("<a href=\"mailto:info@heritagecommunityfdn.org?Subject="+website_description+" Web Site\" title=\"Contact us by Email\">Contact us by Email</a>");
}

//Function to open new windows
function openWin(URL, Width, Height)
{

aWindow=window.open(URL,"PopUp","width="+Width+",height="+Height+",resizable=yes,scrollbars=yes,left=100,top=60");
    
    aWindow.resizeTo(Width, Height);
    
    aWindow.focus();
    if(aWindow.opener == null)
    {
        aWindow.opener = window;
        aWindow.opener.name = "opener";
    }

}

//Function to pop up windows for images.
function ImgPop(zeTitle, zeDescription, zeCopyright, zeSource, level)
{
    popTitle = zeTitle;
	popDescription = zeDescription;
    popCopyright = zeCopyright;
    popSource = zeSource;
	popUrl = "";

    if (popDescription == "description")
        popDescription = "";
    
    width=650;
    height=750;

    //If resolution is 640x480
    if(screen.width < 800)
        height=350;
    //If resolution is 800x600
    else if(screen.width < 1024)
        height=500;

   for(i=1; i<=level; i++)
	{
		popUrl = popUrl + "../";
	} 

	popUrl = popUrl + "inc/popup.html";
//	confirm("The Url is " + popUrl);
	openWin(popUrl,width,height);
}
// The following code uses the AJAX technology to update the SubCategories 
var xmlHttp

function showGroupCategory(group_category_id)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url="../administration/getgroupcategory.php"
	url=url+"?group_category_id="+group_category_id
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChangedGroup 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChangedGroup() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("txtcategory").innerHTML=xmlHttp.responseText 
	} 
}

function showSubCategory(category_id)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url="../administration/getsubcategory.php"
	url=url+"?category_id="+category_id
	url=url+"&sid="+Math.random()	
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("txtsubcategory").innerHTML=xmlHttp.responseText 
	} 
}
function LookupDisplayImage(image_name, accession_number, position, level)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url="administration/getimageinfo.php";
	url=url+"?image_name="+image_name;
	url=url+"&accession_number="+accession_number;
	url=url+"&image_position="+position;
	url=url+"&image_level="+level;
	url=url+"&sid="+Math.random();
	confirm(url);
	xmlHttp.onreadystatechange=foundedImageInfo; 
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function foundedImageInfo() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		xmlDoc=xmlHttp.responseXML;
		confirm(xmlHttp.responseXML);
		var image_name			= xmlDoc.getElementsByTagName("image_name")[0].childNodes[0].nodeValue;
		var image_title 		= xmlDoc.getElementsByTagName("title")[0].childNodes[0].nodeValue;
		var image_description 	= xmlDoc.getElementsByTagName("description")[0].childNodes[0].nodeValue;
		var detail_image_name 	= xmlDoc.getElementsByTagName("detail_name")[0].childNodes[0].nodeValue;
		var thumbnail_image_name= xmlDoc.getElementsByTagName("thumbnail_name")[0].childNodes[0].nodeValue;
		var file_path 			= xmlDoc.getElementsByTagName("path")[0].childNodes[0].nodeValue;
		var image_copyright 	= xmlDoc.getElementsByTagName("copyright")[0].childNodes[0].nodeValue;
		var float_position 		= xmlDoc.getElementsByTagName("position")[0].childNodes[0].nodeValue;
		var level 				= xmlDoc.getElementsByTagName("level")[0].childNodes[0].nodeValue;
		var error_message		= xmlDoc.getElementsByTagName("error_message")[0].childNodes[0].nodeValue;
		if (error_message == "Found")
		{
			DisplayFoundImage(image_name, image_title, image_description, detail_image_name, thumbnail_image_name, file_path, image_copyright, float_position, level);
		}
		else
		{
			document.getElementById(image_name).innerHTML=error_message;
		}
	}
}
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		//Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
function DisplayVideo(file_path, video_name, video_type)
{
	var video_code = '';
	if ((video_type == 'MP4') || (video_type == 'mp4'))
	{
		video_code =  '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" ';
		video_code += '	codebase="http://www.apple.com/qtactivex/qtplugin.cab" ';
		video_code += '	width="320" height="256"> ';
		video_code += '	<param name="src" value="' + file_path + video_name + '.mp4" /> ';
		video_code += '	<param name="autoplay" value="true" /> ';
		video_code += '	<param name="controller" value="true" /> ';
		video_code += '	<object data="' + file_path + video_name  + '.mp4" ';
		video_code += '  		type="video/mp4" ';
		video_code += '  		width="320" height="256"> ';
		video_code += '		<param name="autoplay" value="true" /> ';
		video_code += '		<param name="controller" value="true" /> ';
		video_code += '	</object> ';
		video_code += '</object> ';
		video_code += '<!-- <a href="' + file_path + video_name + '.mp4"></a> -->';
	} else if ((video_type == 'WVX') || (video_type == 'wvx'))
	{
		video_code =   '<object data="' + file_path + video_name + '.wvx" type="video/x-ms-wvx"';
		video_code +=  '	width="320" height="256">';
		video_code +=  '	<param name="src" value="' + file_path + video_name + '.wvx">';
		video_code +=  '</object>';
	}
	if (video_code == '')
	{
		alert('The video type <' + video_type + '> has not been setup.');
	}
	document.write(video_code);
}
function DisplayImage(level, file_path, image_name, image_type, image_title, image_description, image_copyright, float_position)
{
	var image_url = '';
	var single_quot = "'";
	var image_code = '';
    for(i=1; i<=level; i++)
	{
		image_url += "../";
	}
	image_code += '<a href="javascript:ImgPop(' + single_quot + image_title + single_quot + ', ' + single_quot + image_description + single_quot + ', ' + single_quot + image_copyright + single_quot + ', ' + single_quot + '../' + file_path + image_name + '_det.' + image_type + single_quot + ', ' + level + ');">';
	image_code += '<img src="' + image_url + file_path + image_name + '_thu.' + image_type + '" class="' + float_position + '" alt="' + image_description + '" title="' + image_title + '" /></a>';
	document.write(image_code);
}
function DisplayFoundImage(image_name, image_title, image_description, detail_image_name, thumbnail_image_name, file_path, image_copyright, float_position, level)
{
	var image_url = '';
	var single_quot = "'";
	var image_code = '';
    for(i=1; i<=level; i++)
	{
		image_url += "../";
	}
	image_code += '<a href="javascript:ImgPop(' + single_quot + image_title + single_quot + ', ' + single_quot + image_description + single_quot + ', ' + single_quot + image_copyright + single_quot + ', ' + single_quot + '../' + file_path + detail_image_name + single_quot + ', ' + level + ');">';
	image_code += '<img src="' + image_url + file_path + thumbnail_image_name + '" class="' + float_position + '" alt="' + image_description + '" title="' + image_title + '" /></a>';
//	document.write(image_code);
	document.getElementById(image_name).innerHTML=image_code;	
}

