/*
*	Copyright VisConPro Ltd. 2007
*/

//---------------------------------------------------------------------------------
//	Clear Text Functions

/**
* Function removes the default text from a text box when it's selected.
*/
function clear_text(thefield){
	
	// If the text currently contains the defualt text...
	if ( thefield.value == thefield.defaultValue ){
		thefield.value = "";
		thefield.style.color="#000000"; //black
	} else if ( thefield.value == "" ){
		//Else if it current contains no value...
		thefield.value = thefield.defaultValue;
		thefield.style.color="#b1b1b1"; //grey
	}
	
}

/**
* Function removes the default text from a text box when it's selected, and converts it into a password bax.
*/
function clear_password(thefield){
	
	clear_text(thefield);
	
	// If the text currently contains the defualt text...
	if ( thefield.value == thefield.defaultValue ){
		thefield.type = "text";
	} else {		
		thefield.type = "password";
	}	
	
}

//---------------------------------------------------------------------------------
//	Bookmark Page...


function add_bookmark( url, title ) {
	// ----
	
	if( window.sidebar && window.sidebar.addPanel ) {
		//Gecko (Netscape 6 etc.) - add to Sidebar
		// window.sidebar.addPanel( url, title, '' );
	} else if( window.external && ( navigator.platform == 'Win32' ||
		  ( window.ScriptEngine && ScriptEngine().indexOf('InScript') + 1 ) ) ) {
		//IE Win32 or iCab - checking for AddFavorite produces errors in
		//IE for no good reason, so I use a platform and browser detect.
		//adds the current page page as a favourite; if this is unwanted,
		//simply write the desired page in here instead of 'location.href'
		window.external.AddFavorite( url, title );
	} else if( window.opera && window.print ) {
		//Opera 6+ - add as sidebar panel to Hotlist
		return true;
	} else if( document.layers ) {
		//NS4 & Escape - tell them how to add a bookmark quickly (adds current page,
		//not target page)
		window.alert( 'Please click OK then press Ctrl+D to create a bookmark' );
	} else {
		//other browsers - tell them to add a bookmark (adds current page, not target page)
		window.alert( 'Please use your browser\'s bookmarking facility to create a bookmark' );
	}
	return false;
	
	// ----
} // <- add_bookmark->

//---------------------------------------------------------------------------------
//	Pre-load objects...

var runOnload = false

function doOnload() {
	
	if (runOnload){
		// Do the downloading awhile AFTER the onload.
		setTimeout("downloadComponents()", 1000);
	}
	
}

window.onload = doOnload;

//Download an image dynamically.
function downloadImage(url) {
	var elem = document.createElement("img");
	elem.src = url;
	elem.alt = "Cached Image";
	elem.style.display = "none";
	document.body.appendChild(elem);
}



// Download a stylesheet dynamically.
function downloadCSS(url) {
	var elem = document.createElement("link");
	elem.rel = "stylesheet";
	elem.type = "text/css";
	elem.href = url;
	document.body.appendChild(elem);
}

// Download a script dynamically.
function downloadJS(url) {
	var elem = document.createElement("script");
	elem.src = url;
	document.body.appendChild(elem);
}


