var xmlHttp;

function showBiog()
{
	document.getElementById("biog").style.display = 'block';
	document.getElementById("biog_image").style.display = 'none';
	document.getElementById("biog_close").style.display = 'block';
}
function closeBiog()
{
	document.getElementById("biog").style.display = 'none';
	document.getElementById("biog_image").style.display = 'block';
	document.getElementById("biog_close").style.display = 'none';
}

function createXMLHttpRequest()
{
	if(window.ActiveXObject)
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		if(window.XMLHttpRequest)
		{
			xmlHttp = new XMLHttpRequest();
		}
	}
}

function getNews(direction)
{
	createXMLHttpRequest();
	xmlHttp.onreadystatechange = return_news;
	
	newsID = document.getElementById("newsID").innerHTML;
	
	url = "getNews.php?direction=" + direction + "&id=" + newsID;
	//alert(url);
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
function gallery_get(direction, id)
{
	if(document.getElementById("flashcontent"))
	{
		document.getElementById("flashcontent").style.display = 'none';
	}

	document.getElementById("gallery_image").style.display = 'inline';
	
	createXMLHttpRequest();
	xmlHttp.onreadystatechange = return_image;
	
	imageURL = document.getElementById("gallery_image").src;
	
	url = "getImage.php?direction=" + direction + "&id=" + id + "&url=" + imageURL;
// alert(url)
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}
function return_image()
{
	if(xmlHttp.readyState == 4)
	{
		if(xmlHttp.status == 200)
		{
			xmlObj = xmlHttp.responseXML;

			imageObj = xmlObj.getElementsByTagName("image");
			if(imageObj.length > 0)
			{
				imageTitle = imageObj[0].getElementsByTagName("title")[0].firstChild.nodeValue;
				imageURL = imageObj[0].getElementsByTagName("url")[0].firstChild.nodeValue;
				
				//alert(document.getElementById("gallery_image").src)
				document.getElementById("gallery_image").src=imageURL;
				document.getElementById("gallery_image").alt=imageTitle;
				document.getElementById("image_title").innerHTML=imageTitle;
			}
		}
	}
}

function return_news()
{
	if(xmlHttp.readyState == 4)
	{
		if(xmlHttp.status == 200)
		{
			//alert(xmlHttp.responseText)
			xmlObj = xmlHttp.responseXML;
			
			// logic here for extracting the information from the news xml
			newsObj = xmlObj.getElementsByTagName("news");
			if(newsObj.length > 0)
			{
				newsTitle = newsObj[0].getElementsByTagName("title")[0].firstChild.nodeValue;
				newsID = newsObj[0].getElementsByTagName("id")[0].firstChild.nodeValue;
				newsDate = newsObj[0].getElementsByTagName("date")[0].firstChild.nodeValue;
				newsContent = newsObj[0].getElementsByTagName("content")[0].firstChild.nodeValue;
				newsDivision = newsObj[0].getElementsByTagName("division")[0].firstChild.nodeValue;

				document.getElementById("newsID").innerHTML = newsID;
				newsHolder = document.getElementById("news_content");
				newsDivs = newsHolder.getElementsByTagName("div");
				for(i=0; i<newsDivs.length; i++)
				{
					switch(newsDivs[i].className)
					{
						case 'date':
						{
							newsDivs[i].innerHTML = newsDate;
							break;
						}
						case 'title':
						{
							newsDivs[i].innerHTML = newsTitle;
							break;
						}
						case 'content':
						{
							newsDivs[i].innerHTML = newsContent;
							break;
						}
					}
				}
			}
		}
	}
}

function changeState(obj, state1, state2)
{
	// if the entire string of one state exists within another (e.g. over & overRed) then the longer string should occur first in the state list sent as a parameter to this function
	if(obj.src.indexOf(state1) > -1)
	{
		obj.src = obj.src.replace(state1, state2);
	}
	else
	{
		obj.src = obj.src.replace(state2, state1);
	}
	return true;
}
/*
function changeHeadings(page, subsection)
{
	switch(page)
	{
		case 'index.php':
		{
			if(typeof sIFR == "function"){
    				sIFR.replaceElement("h1", named({sFlashSrc: "./sifr.swf", sColor: "#000000", sCase: "upper", nPaddingTop: "0", nPaddingBottom: "15", nPaddingLeft: "0", nPaddingRight: "0", sHoverColor: "#ee009b", sBgColor: "#c50028"}));
			};
			break;
		}
		case 'directors.php':
		{
			if(typeof sIFR == "function"){
				sIFR.replaceElement("h2", named({sFlashSrc: "./sifr_small.swf", sColor: "#000000", sCase: "upper", nPaddingTop: "0", nPaddingBottom: "0", nPaddingLeft: "0", nPaddingRight: "0", sHoverColor: "#ffffff", sBgColor: "#c50028"}));
			};
			if(typeof sIFR == "function"){
				sIFR.replaceElement("h1", named({sFlashSrc: "./sifr.swf", sColor: "#ef019c", sCase: "upper", nPaddingTop: "0", nPaddingBottom: "0", nPaddingLeft: "0", nPaddingRight: "0", sBgColor: "#320c0a"}));
			};
			break;
		}
		case 'contact.php':
		{
			if(typeof sIFR == "function"){
				sIFR.replaceElement("h2", named({sFlashSrc: "./sifr_small.swf", sColor: "#000000", sCase: "upper", nPaddingTop: "0", nPaddingBottom: "0", nPaddingLeft: "0", nPaddingRight: "0", sHoverColor: "#ffffff", sBgColor: "#c50028"}));
			};
			if(typeof sIFR == "function"){
				sIFR.replaceElement("h1", named({sFlashSrc: "./sifr.swf", sColor: "#ffffff", sCase: "upper", nPaddingTop: "0", nPaddingBottom: "0", nPaddingLeft: "0", nPaddingRight: "0", sBgColor: "#2b0826"}));
			};
			break;
		}
		case 'longform.php':
		case 'about.php':
		{
			if(typeof sIFR == "function"){
				sIFR.replaceElement("h2", named({sFlashSrc: "./sifr_small.swf", sColor: "#02c5d1", sCase: "upper", nPaddingTop: "0", nPaddingBottom: "0", nPaddingLeft: "0", nPaddingRight: "0", sHoverColor: "#ffffff", sBgColor: "#006372"}));
			};
			if(typeof sIFR == "function"){
				sIFR.replaceElement("h1", named({sFlashSrc: "./sifr.swf", sColor: "#02c5d1", sCase: "upper", nPaddingTop: "0", nPaddingBottom: "0", nPaddingLeft: "0", nPaddingRight: "0", sHoverColor: "#ffffff", sBgColor: "#006372"}));
			};
			break;
		}
		case 'production.php':
		{
			if(typeof sIFR == "function"){
				sIFR.replaceElement("h2", named({sFlashSrc: "./sifr_small.swf", sColor: "#ffffff", sCase: "upper", nPaddingTop: "0", nPaddingBottom: "0", nPaddingLeft: "0", nPaddingRight: "0", sHoverColor: "#000000", sBgColor: "#bc0071"}));
			};
			if(typeof sIFR == "function"){
				sIFR.replaceElement("h1", named({sFlashSrc: "./sifr.swf", sColor: "#ffffff", sCase: "upper", nPaddingTop: "0", nPaddingBottom: "0", nPaddingLeft: "0", nPaddingRight: "0", sHoverColor: "#000000", sBgColor: "#bc0071"}));
			};
			break;
		}
	}
}
*/
function showClip(uri, colour)
{
	clipArea = document.getElementById("video");
	
	/*
	videoCode = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="400" height="300" style="width: 400px !important;" id="ashPlayer" align="middle">';
	videoCode += '<param name="allowScriptAccess" value="sameDomain" />';
	videoCode += '<param name="allowFullScreen" value="false" />';
	videoCode += '<param name="movie" value="ashPlayer.swf" />';
	videoCode += '<param name="quality" value="high" />';
	videoCode += '<param name="bgcolor" value="' + colour + '" />';
	videoCode += '<param name="flashvars" value="vFlvURL=' + uri + '" />';
	videoCode += '<embed src="ashPlayer.swf" flashvars="vFlvURL=' + uri + '" quality="high" bgcolor="' + colour + '" width="400" height="300" style="width: 400px !important;" name="ashPlayer" align="middle" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />';
	videoCode += '</object>';
	*/
	
	videoCode = '<object width="532" height="333" type="application/x-shockwave-flash" data="player.swf" id="flashcontent" style="visibility: visible;">';
	videoCode += '<param name="scale" value="noScale"/>';
	videoCode += '<param name="allowfullscreen" value="true"/>';
	videoCode += '<param name="allowscriptaccess" value="always"/>';
	videoCode += '<param name="bgcolor" value="' + colour + '"/>';
	videoCode += '<param name="flashvars" value="sourcePath=' + uri + '&amp;autoplay=true&amp;skinBackgroundColor=0x666666&amp;skinBackgroundAlpha=0.5&amp;volume=1&amp;skin=yourflvskin.swf"/>';
	videoCode += '</object>';
/*
<script type="text/javascript">
		
				var flashvars =  {};
				flashvars.sourcePath = "media/$clip";
				flashvars.autoplay = "true";
				flashvars.url = "$nextClip";
				flashvars.skinBackgroundColor = "0x666666";                          //use to control the background colour of the skin
				flashvars.skinBackgroundAlpha = "0.5";                                   //use to control the background alpha of the skin
				flashvars.volume = "1";                                                           //use to control the intial starting volume of the video
				flashvars.skin = "yourflvskin.swf";                                            //path your your chosen skin.

				var params = {};
				params.scale = "noScale";
				params.allowfullscreen = "true";
				params.allowscriptaccess = "always";
				params.bgcolor = "#1E202C";
				swfobject.embedSWF("player.swf", "flashcontent", "532", "333", "9.0.124", false, flashvars, params);
				swfobject.createCSS("#flashcontent","outline:none"); 
			</script>
			
			<div id="flashcontent">
				<p>You place your alternate non-flash content here... ie, "you need to upgrade your flash, click here...".</p>
			</div>
*/

	clipArea.innerHTML = videoCode;
}

function showClipList(listName, listHeaderObj)
{
	tables = document.getElementsByTagName("table");
	// loop through tables as we only need to change those that have the clips class
	
	for(var i=0; i<tables.length; i++)
	{
		table_class = tables[i].className;	// cannot use a true DOM checker, as IE can screw it up with the class attribute
		if(table_class == 'clips')
		{
			tables[i].style.display = 'none';		// again, ie screws this up so we have to use the traditional method to change the style
		}
	}
	
	reels = document.getElementById("reels");
	headings = reels.getElementsByTagName("div");
	for(i=0; i<headings.length; i++)
	{
		headings[i].className = 'inactive';
	}
	listHeaderObj.className = 'active';
	
	document.getElementById(listName).style.display = 'table';
	reel_clips = document.getElementById(listName).getElementsByTagName('a');
	url = reel_clips[0].href;
	
	// this bit added to make display the image gallery/video player when the gallery/showreel label is clicked
	if(listHeaderObj.innerHTML == 'Image Gallery')
	{
		document.getElementById("flashcontent").style.display = 'none';
		document.getElementById("gallery_image").style.display = 'inline';
	}
	else
	{
		if(document.getElementById("gallery_image"))
		{
			document.getElementById("gallery_image").style.display = 'none';
		}
		document.getElementById("flashcontent").style.display = 'block';
		location.href = url;
	}
}

