//=============================
//Redirect alert
//=============================
function redirectAlert() {
	window.alert("You are being redirected - please wait...");
}

//=============================
//Simple close window function
//=============================
function closeWindow () {
	window.close();
}

//=============================
//This function opens a pop up window with width and height as parametres
//=============================
function openNewWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

//=============================
//This function opens a pop up window for images and passes the image name as a variable through the url 
//=============================
function openImageWindow(imageName){
		myWindow = window.open('../../images/image-opener.htm', 'newwindow', 'width=1200,height=900,location=yes');
		myWindow.document.location = "../../images/image-opener.htm?imageName=" + imageName;
}


//=============================
//This function clears an input on focus
//Use the this parameter when calling the function
//=============================

function clearField(theText) {
     if (theText.value == theText.defaultValue) {
         theText.value = ""
     }
 }
 
 


//=============================
//This function opens a full screen pop up window 
//=============================
function openFullScreen (input) {
	window.open(input, '','fullscreen=yes, scollbars=no');

}

//=============================
//This function maximises the current page to full screen 
//=============================
function maximiseWindow() {
			window.moveTo(0,0);
			window.resizeTo(screen.width,screen.height);
}
	
	
//=============================
//This function forces the save as dialogue box for any input 
//=============================
function saveAs(input, w, h){
		//str = input; //document.forms[0].input.value;
		theFile = window.open(input,'windowname','width=w,height=h');
		//mydoc.document.write(input);
		theFile.document.execCommand("saveAs",true,input);
		theFile.close();
		return false;
}


function embedFlash() {
	var newDiv = document.createElement("div")
	var paraText = document.createTextNode("Testing the text")
	newDiv.appendChild(paraText)
	document.getElementById("body").appendChild(newDiv);	
}


function openWinFullOpacity(theUrl, id, opacStart, opacEnd, millisec) {
				
		//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}	
	
	window.open(theUrl, '','fullscreen=yes, scollbars=no');
	
}



