//make the whole tab clickable
function tabclick(url)
{
	//redirect the page to the specified url
	window.location=url;
}

//Smooth image resize code
//Settings
var maxsize = 310;
var minsize = 150;
var resizeby = 20;

//launch the growing sequence
function srlaunch(image)
{
	//set the argument parsed to this as a public variable
	img = image;
	if (document.getElementById(img).width == maxsize)
	{
		//start the shrink function every 5 milliseconds
		interval = setInterval('shrink()',5);
	}
	else
	{
		//start the grow function every 5 milliseconds
		interval = setInterval('grow()',5);
	}
}

function grow()
{
	//if the image size is bigger than the max size stop resizing
	if (document.getElementById(img).width>=maxsize)
	{
		//stop launching the grow function
		clearInterval(interval);
	}
	else
	{
		//make the image bigger
		document.getElementById(img).width += resizeby;	
	}

}

function shrink()
{
	//if the image size is smallerr than the max size stop resizing
	if (document.getElementById(img).width<=minsize)
	{
		//stop launching the shrink function
		clearInterval(interval);
	}
	else
	{
		//make the image smaller
		document.getElementById(img).width -= resizeby;	
	}

}

//Show the specified element
function show(divid)
{
	document.getElementById(divid).style.display = "block";
}

//Insert textbox form field into specified form control
function inserttag(tag)
{
	document.getElementById('textbox').value += tag;
}

//confirm then submit
function check_submit(msgtxt)
{
	show_confirm = confirm(msgtxt);
	if(show_confirm == true)
	{
		return true;
	}
	else
	{
		return false;
	}
}

//
//------------------------------------------------------------------WYSIWYG EDITOR JAVASCRIPT-------------------------------------------------------------------------------------------------------------------------------
//
function insstdcode(frmobjectid,code)
{
	document.getElementById(frmobjectid).value += "<" + code + "></" + code + ">";
}

function inslink(frmobjectid)
{
	var linkurl = prompt("URL: (e.g. http://www.google.co.uk)","http://");
	var linktxt = prompt("Link text: (e.g. Google)","");

	if (linkurl == "" || linktxt == "" || linkurl == null || linktxt == null)
	{
		alert("You must fill in both boxes!");
	}
	else
	{
		document.getElementById(frmobjectid).value += "<a href='" + linkurl + "'>" + linktxt + "</a>";
	}
}

function insimg(frmobjectid)
{
	var imgurl = prompt("Image URL: (e.g. http://www.google.co.uk/intl/en_uk/images/logo.gif)","http://");
	var alttxt = prompt("Image's alternative (descriptive) text: (e.g. Google's Logo)","");
	
	if (imgurl == "" || alttxt == "" || imgurl == null || alttxt == null)
	{
		alert("You must fill in both boxes!");
	}
	else
	{
		document.getElementById(frmobjectid).value += "<img src='" + imgurl + "' alt='" + alttxt + "' />";	
	}
}

function preview(frmobjectid)
{
	document.getElementById("ppane").innerHTML = document.getElementById(frmobjectid).value.replace(/\n/g, "<br />");
	window.location = "#ppaneanchor";
}
