var gotPoints = -1;


/*
 * Summary:	check to see if the Visual Basic bridge is required
 * Usage: 	fo.addVariable("ie", getVBCheckString());
 * 
 */
function getVBCheckString() {
	if (navigator.plugins && navigator.mimeTypes.length) { // netscape plugin architecture
		return "0";
	} else {
		return "1";
	}
}



function openWindow(url){
	newwindow = window.open(url,'mywindow','width=620,height=500,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no')
	if (window.focus) {newwindow.focus()}
}

function openFullWindow(url){
	newwindow = window.open(url,'myhelpwindow','width=900,height=600,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes')
	if (window.focus) {newwindow.focus()}
	//return false;
}

function loadscav(url){
	newwindow = window.open(url,'ScavengerHunt','width=1019,height=595,resize=1');
	if (window.focus) {newwindow.focus()}
}

function awardpoints(guidassetid, pass, intuserpointid){
	new Ajax.Request('/ajax/addUserPoints.cfm?guidAssetid=' + guidassetid  + '&pass=' + pass + '&intuserpointid=' + intuserpointid, {asynchronous:true,onComplete:pointsid});	

}

function pointsid(e){
	gotPoints = e.responseText;
	if(gotPoints == ''){
		gotPoints = 0;
	}
}



function strGowebmath(url){
	newwindow = window.open('/webmath.cfm?linkurl=' + url + '&title=Webmath','WebMath','width=900,height=690,status=yes,scrollbars=yes,resizable=yes');
	if (window.focus) {newwindow.focus()}
}

function JavascriptCommand(command, args) {
	if(command != '' && args != '' && command != null & args!= null){
		command = command + "(" + args + ")";
		eval(command);
	}
}

function showmenu(){
	//This is for a flash work around, DO NOT DELETE
}

function go(url){
	location.href=url;
}

function goparent(url){
	top.location.href=url;
}

function goTarget(url, target){
	frames[target].location.href=url;
}


function checkAll(field)
{
	for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}



function BlockContent(guidAssetId, target, closepartner)
{
	//Clear favorites panel
	if($(closepartner)){
		$(closepartner).innerHTML = "";
		Element.hide(closepartner);
	}
	
	Element.show(target);
	if($(target).innerHTML.length == 0){
		new Ajax.Updater($(target), "/ajax/blockasset.cfm?guidAssetId=" + guidAssetId + "&Video=1&target=" + target, {asynchronous:true});
	}else{
		$(target).innerHTML = "";
		Element.hide(target);
	}
}

function closeBlockContent(target)
{
	Element.hide(target);
}


function SaveBlockContent(guidassetid, target)
	{
	useridfield = document.block.guiduserid;
	useridstring = '';
	delim = '';
	for (i = 0; i < useridfield.length; i++){
		if(useridfield[i].checked == true)
			useridstring += delim + useridfield[i].value;
			delim = ','
	}
		
	new Ajax.Updater($(target), "/ajax/blockasset.cfm?process=1&guidAssetId=" + guidassetid + "&guiduserId=" + useridstring + "&target=" + target, {asynchronous:true});
	
	}
	
function signup(){
	$('signup').style.display = '';
}


FancyButton = Class.create();
Object.extend(FancyButton.prototype, {
	initialize: function(button, onclick) {
		this.button = $(button);
		this.onclick = onclick;
		this.pressed = false;
		
		Event.observe(this.button, 'mouseover', this.rollover.bind(this));
		Event.observe(this.button, 'mousedown', this.mousedown.bind(this));
		Event.observe(this.button, 'mouseout', this.rollout.bindAsEventListener(this));
		Event.observe(this.button, 'mouseup', this.mouseup.bindAsEventListener(this));
	},
	rollover: function() {
		if (this.pressed){
			this.button.className = "active";
		} else {
			this.button.className = "hover";
		}
	},
	rollout: function() {
		this.button.className="";
	},
	mousedown: function() {
		this.button.className = "active";
		this.pressed = true;
		this.addWindowListener();
	},
	mouseup: function() {
		this.pressed = false;
		this.button.className = "hover";
		this.removeWindowListener();
		
		if (this.onclick) {
			this.onclick();
		}		
	},
	addWindowListener: function() {
		Event.observe(window, 'mouseup', this.removeWindowListener.bind(this));
	},
	removeWindowListener: function() {
		this.pressed = false;		
		Event.stopObserving(window, 'mouseup', this.removeWindowListener.bind(this));
	}
});
