<!--

/* Andrew Urquhart : Client-Side Request Object for javascript : http://andrewu.co.uk/tools/request/
COPYRIGHT:You are free to use this script for any use you wish if this comment is left intact. Feel free to enhance the script and send me the updated version. Please don't redistribute. This script is provided as is,with no warranty of any kind. Use it at your own risk. Copyright Andrew R Urquhart; VERSION:#1.3 2005-05-11 17:52 UTC*/
function RObj(ea){var LS="";var QS=new Object();var un="undefined";var x=null;var f="function";var n="number";var r="string";var e1="ERROR:Index out of range in\r\nRequest.QueryString";var e2="ERROR:Wrong number of arguments or invalid property assignment\r\nRequest.QueryString";var e3="ERROR:Object doesn't support this property or method\r\nRequest.QueryString.Key";function Err(arg){if(ea){alert("Request Object:\r\n"+arg)}};function URID(t){var d="";if(t){for(var i=0;i<t.length;++i){var c=t.charAt(i);d+=(c=="+"?" ":c)}};return unescape(d)};function OL(o){var l=0;for(var i in o){if(typeof o[i]!=f){l++}};return l};function AK(key){var auk=true;for(var u in QS){if(typeof QS[u]!=f&&u.toString().toLowerCase()==key.toLowerCase()){auk=false;return u}}if(auk){QS[key]=new Object();QS[key].toString=function(){return TS(QS[key])};QS[key].Count=function(){return OL(QS[key])};QS[key].Count.toString=function(){return OL(QS[key]).toString()};QS[key].Item=function(e){if(typeof e==un){return QS[key]}else {if(typeof e==n){var a=QS[key][Math.ceil(e)];if(typeof a==un){Err(e1+"(\""+key+"\").Item("+e+")")};return a}else {Err("ERROR:Expecting numeric input in\r\nRequest.QueryString(\""+key+"\").Item(\""+e+"\")")}}};QS[key].Item.toString=function(e){if(typeof e==un){return QS[key].toString()}else {var a=QS[key][e];if(typeof a==un){Err(e1+"(\""+key+"\").Item("+e+")")};return a.toString()}};QS[key].Key=function(e){var t=typeof e;if(t==r){var a=QS[key][e];return(typeof a!=un&&a&&a.toString()?e:"")}else {Err(e3+"("+(e?e:"")+")")}};QS[key].Key.toString=function(){return x}};return key};function AVTK(key,val){if(key!=""){var key=AK(key);var l=OL(QS[key]);QS[key][l+1]=val}};function TS(o){var s="";for(var i in o){var ty=typeof o[i];if(ty=="object"){s+=TS(o[i])}else if(ty!=f){s+=o[i]+", "}};var l=s.length;if(l>1){return(s.substring(0,l-2))}return(s==""?x:s)};function KM(k,o){var k=k.toLowerCase();for(var u in o){if(typeof o[u]!=f&&u.toString().toLowerCase()==k){return u}}}if(window.location&&window.location.search){LS=window.location.search;var l=LS.length;if(l>0){LS=LS.substring(1,l);var preAmpAt=0;var ampAt=-1;var eqAt=-1;var k=0;var skip=false;for(var i=0;i<l;++i){var c=LS.charAt(i);if(LS.charAt(preAmpAt)=="="||(preAmpAt==0&&i==0&&c=="=")){skip=true}if(c=="="&&eqAt==-1&&!skip){eqAt=i}if(c=="&"&&ampAt==-1){if(eqAt!=-1){ampAt=i}if(skip){preAmpAt=i+1};skip=false}if(ampAt>eqAt){AVTK(URID(LS.substring(preAmpAt,eqAt)),URID(LS.substring(eqAt+1,ampAt)));preAmpAt=ampAt+1;eqAt=ampAt=-1;++k}}if(LS.charAt(preAmpAt)!="="&&(preAmpAt!=0||i!=0||c!="=")){if(preAmpAt!=l){if(eqAt!=-1){AVTK(URID(LS.substring(preAmpAt,eqAt)),URID(LS.substring(eqAt+1,l)))}else if(preAmpAt!=l-1){AVTK(URID(LS.substring(preAmpAt,l)),"")}}if(l==1){AVTK(LS.substring(0,1),"")}}}};var TC=OL(QS);if(!TC){TC=0};QS.toString=function(){return LS.toString()};QS.Count=function(){return(TC?TC:0)};QS.Count.toString=function(){return(TC?TC.toString():"0")};QS.Item=function(e){if(typeof e==un){return LS}else {if(typeof e==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof QS[i]!=f&&++c==e){return QS[i]}};Err(e1+"().Item("+e+")")}else {return QS[KM(e,QS)]}};return x};QS.Item.toString=function(){return LS.toString()};QS.Key=function(e){var t=typeof e;if(t==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof QS[i]!=f&&++c==e){return i}}}else if(t==r){var e=KM(e,QS);var a=QS[e];return(typeof a!=un&&a&&a.toString()?e:"")}else {Err(e2+"().Key("+(e?e:"")+")")};Err(e1+"().Item("+e+")")};QS.Key.toString=function(){Err(e2+"().Key")};this.QueryString=function(k){if(typeof k==un){return QS}else {var k=KM(k,QS);if(typeof QS[k]==un){t=new Object();t.Count=function(){return 0};t.Count.toString=function(){return "0"};t.toString=function(){return x};t.Item=function(e){return x};t.Item.toString=function(){return x};t.Key=function(e){Err(e3+"("+(e?e:"")+")")};t.Key.toString=function(){return x};return t}if(typeof k==n){return QS.Item(k)}else {return QS[k]}}};this.QueryString.toString=function(){return LS.toString()};this.QueryString.Count=function(){return(TC?TC:0)};this.QueryString.Count.toString=function(){return(TC?TC.toString():"0")};this.QueryString.Item=function(e){if(typeof e==un){return LS.toString()}else {if(typeof e==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof QS[i]!=f&&++c==e){return QS[i]}};Err(e1+".Item("+e+")")}else {return QS[KM(e,QS)]}}if(typeof e==n){Err(e1+".Item("+e+")")};return x};this.QueryString.Item.toString=function(){return LS.toString()};this.QueryString.Key=function(e){var t=typeof e;if(t==n){var e=Math.ceil(e);var c=0;for(var i in QS){if(typeof QS[i]=="object"&&(++c==e)){return i}}}else if(t==r){var e=KM(e,QS);var a=QS[e];return(typeof a!=un&&a&&a.toString()?e:"")}else {Err(e2+".Key("+(e?e:"")+")")};Err(e1+".Item("+e+")")};this.QueryString.Key.toString=function(){Err(e2+".Key")};this.Version=1.3;this.Author="Andrew Urquhart (www.andrewu.co.uk)"};var Request=new RObj(false);

//This following is the Article manager javascript plugin file.
//This file was developed by Flock Software Creation

var CurrFrameName="";

//Resize an IFRAME
function ResizeIFrame(name,height,width)
{
	var oFrame = document.all(name);

	oFrame.style.height = height;
	
	var tmpTxtHeight = document.all("txtHeight");
	
	if (tmpTxtHeight)
	{
		tmpTxtHeight.value = height;
	}
	
	tmpTxtHeight = document.all("txtHeight2");
	
	if (tmpTxtHeight)
	{
		tmpTxtHeight.value = height;
	}
}

//Finds a name that is not already being used, and returns
//it.
function getDivName()
{
	///Set the base name
	var tmpDivName="ArticleManagerDiv";
	///Set the number to append onto it.
	var i=0;
	
	///Carry on adding 1 onto the number at the end until there is no item
	///with the same name.
	while(document.getElementById(tmpDivName + i) != null)
		i++;
	
	///Return the name.
	return tmpDivName + i;
}

//Generates the iframe content
function generateIframe(scroll, width, height, src)
{
	///The variable to hold the iframe scrolling value
	var scrolling = "";
	
	///Set the variable to use for the scrolling
	if (scroll == "auto")
	{
		scrolling = " scrolling=auto ";
	}
	else if (scroll == "scroll")
	{
		scrolling = " scrolling=yes ";
	}
	else if (scroll == "hidden")
	{
		scrolling = " scrolling=no ";
	}
	else if (scroll == "visible")
	{
		scrolling = "scrolling = no ";
	}

	///Set the global name of the frame to use.
	var FrameName = getDivName();
	
	///The variable to hold the stuff to write.
	var FrameTags = "";
	
	///Set the content
	
	var tmpSrc = src;
	
	if (scroll == 'visible')
	{
		var tmpTxtHeight = document.all("txtHeight2");
	
		if (tmpTxtHeight)
		{
			tmpSrc = tmpSrc + "&iframename=" + FrameName;
		}
	}
	
	FrameTags = "<IFRAME ID='" + FrameName + "' " + scrolling + " SRC='" + tmpSrc + "' frameborder=0 style='OVERFLOW: " + scroll + "; WIDTH: " + width + "; HEIGHT: " + height + "; BORDER-RIGHT: 0px solid; PADDING-RIGHT: 0px; BORDER-TOP: 0px solid; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: 0px solid; PADDING-TOP: 0px; BORDER-BOTTOM: 0px solid;'>";
	FrameTags = FrameTags + "Sorry but your browser is not able to view iframes.</IFRAME>";
	
	///Write the content to the page
	document.write(FrameTags);
	
	///Return the frame name
	return FrameName;
}

function getArticleHeight(frameName)
{
	///The variable to hold the height from the querystring
	var TmpHeight = 0;
	///The article id variable
	var articleID = 0;
	///The variable to say whether the document should be refreshed so the height can be added to the querystring
	var tmpBool = false;
	
	try
	{
		///Get the height from the querystring
		TmpHeight = parseInt(Request.QueryString("ArticleHeight"));
		
		if (isNaN(TmpHeight))
			TmpHeight = parseInt(Request.QueryString("amp;ArticleHeight"));
		
		///If the height wasn't there
		if (isNaN(TmpHeight))
		{
			tmpBool = true;
		}
		else
		{
			tmpBool = false;
		}
		articleID = parseInt(Request.QueryString("AID"));
		if (isNaN(articleID))
		{
			tmpBool = false;
		}
	}
	catch(err)
	{
		tmpBool = true;
	}
	
	///If we need to redirect, do it
	if (tmpBool == true)
	{
		///Get the frame object
		//var myFrame = document.getElementById(frameName);
		///Get the scroll height
		//var tmpVar = parseInt(myFrame.scrollHeight) + 50;
		//alert(tmpVar);
		///Set the new location
		//document.location.href = document.location.href +  "&ArticleHeight=" + tmpVar;
	}
	else ///Else we need to resize the iframe
	{
		///Resize the iframe
		ResizeIFrame(frameName,TmpHeight,0);
	}
}

//This function writes the iframe to the page that all the 
//rest of the content will be set to.
//It takes for the following variables.
//	Width	- The width of the div.
//	Height	- The height of the div.
//	scroll	- The scroll style of the div. ('auto', 'scroll', 'visible', 'hidden')
function writeIframe(width, height, scroll, src)
{
	
	CurrFrameName = generateIframe(scroll, width, height, src);
	
	///Get the frame object
	var myFrame = document.getElementById(CurrFrameName);
	
	if (scroll == 'visible')
	{
		myFrame.onload = 
			function()
					{
						getArticleHeight(CurrFrameName);
					}
	}
}

///Draws the article plugin with the specified values.
function DrawArticle(Scroll, Width, Height)
{
	///Set the request location
	var ReqLoc="http://articlemanager.flock.co.za/Public/ArticlePlugin.aspx?AID=" + Request.QueryString("AID");
	//var ReqLoc="http://localhost/articlemanager/Public/ArticlePlugin.aspx?AID=" + Request.QueryString("AID");
	
	writeIframe(Width,Height,Scroll,ReqLoc);
}

///Draws the featured articles plugin with the specified values.
function DrawFeaturedArticles(Scroll, Width, Height, CatID, RedirectURL)
{
	///Set the request location
	var ReqLoc="http://articlemanager.flock.co.za/Public/FeaturedArticlePlugin.aspx?CatID=" + CatID + "&RedirectURL=" + escape(RedirectURL);
	
	writeIframe(Width,Height,Scroll,ReqLoc);
}

///Draws the search plugin frame with the specified values.
function DrawSearch(Scroll, Width, Height, CatID, RedirectURL, SiteID, searchString)
{
	///Set the iframe location
	var src="http://articlemanager.flock.co.za/Public/SearchPlugin.aspx?CatID=" + CatID + "&SiteID=" + SiteID + "&RedirectURL=" + escape(RedirectURL) + "&searchString=" + searchString;
	///var src="http://localhost/articlemanager/Public/SearchPlugin.aspx?CatID=" + CatID + "&SiteID=" + SiteID + "&RedirectURL=" + escape(RedirectURL) + "&searchString=" + searchString;
	
	///Create the iframe
	var Iframe = writeIframe(Width,Height,Scroll,src);
}

///Draws the content panel plugin with the specified values.
function DrawContentPanel(Scroll, Width, Height, PanelID)
{
	///Set the plugin request location
	var src="http://articlemanager.flock.co.za/Public/ContentPanel.aspx?ID=" + PanelID;
	
	writeIframe(Width,Height,Scroll,src);
}

///Copyright Flock Software Creation 2003 - 2005 All rights reserved.

-->