// preloading
//playImg = new Image();
//playImg.src = 'image/play_button_green_32.png';
playOverImg = new Image();
playOverImg.src = 'image/play_button_green_32_lit.png';

function rollpng(id, over) {
	if (over) {
		styleClass = 'playpng_over';
		imgSrc = 'image/play_button_green_32_lit.png';
	} else {
		styleClass = 'playpng';
		imgSrc = 'image/play_button_green_32.png';
	}

	// this is just a precaution, IE showed the shifted bugged png on first load
	// a couple times
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	// IE 5.5 and 6
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
		imgSrc = 'image/transparent_play.gif';
	}

    $(id).className = styleClass;	
	$(id).src = imgSrc;
}

function popup(loc, tWidth, tHeight, name) {
	if (!tWidth) {
		window.open(loc);
		return;
	}

	var _params;
	if (screen.width < tWidth) {
		tWidth = screen.width;
	}

	if (screen.height < tHeight) {
		tHeight = screen.height;
	} 
	
	var top = (screen.height - tHeight)/8;
	var left = (screen.width - tWidth)/2;
    _params = "top="+top+",left="+left+",width="+tWidth+",height="+tHeight+",location=0,directories=0,toolbar=0,menubar=0,resizable=0,scrollbars=1,status=0";
  	var newWin = window.open(loc, name, _params);
}

function showTutorial(url) {
	popup('tutorial/' + url, 1024, 770);	
}

function savedNavigate(url) {
	var ovAuthorObject = $('OverstreamAuthor');	
	if (!ovAuthorObject) {
		// we are on page with no author or flash is not installed 
		// either way, just go to the url
		window.location.href = url;
	} else {
		//showAuthorTab();
		// ovAuthorObject.checkSavedRedirect(url);
		ovAuthorObject.checkSavedExecute("window.location.href='" + url+"'");
	}
}

function savedSubmit(formId) {
	var ovAuthorObject = $('OverstreamAuthor');	
	if (!ovAuthorObject) {
		$(formId).submit();
	}
	// showAuthorTab();
	ovAuthorObject.checkSavedExecute("$('"+formId+"').submit()");
}

function showAuthorTab() {
	showTab('ov_author','ov_properties');
}

function showTab(show){
	// alert($('nav_'+show));
	// $(show).style.display='';
	$(show).style.visibility = "visible"; 
	$('nav_'+show).className='active';
	var args = showTab.arguments;	  
	for (var i = 1; i < args.length; i++) {		
		// $(args[i]).style.display='none';
		$(args[i]).style.visibility = "hidden"; 
		$('nav_'+args[i]).className = $('nav_'+args[i]).className.replace('active','');
	}
}

function showSearchOptions($show) {
	$soDiv = $('soSearchOptions');
	$plusminus = $('soPlusMinus');
	if ($show == null) {
		$show = ($soDiv.style.display=='none');
	}

	if ($show) {
		$soDiv.style.display='block';
		$plusminus.innerHTML = '<a href="#" onclick="showSearchOptions();return false;"><b>-</b></a><input type="hidden" name="a" value="1">';
	} else {
		$soDiv.style.display='none';
		$plusminus.innerHTML = '<a href="#" onclick="showSearchOptions();return false;"><b>+</b></a>';
	}
}

function showFullTagsDiv(divNum, show) {
	var trunc_div = $('trunc_tags_'+divNum);
	var full_div = $('full_tags_'+divNum);
	if (show) {
		trunc_div.style.display = 'none';
		full_div.style.display = 'inline';
	} else {
		trunc_div.style.display = 'inline';
		full_div.style.display = 'none';
	}
}


function ovExecOnLoadFunctions() {
	if (window.ovOnLoadFunctionList) {
		for (var i=0; i<ovOnLoadFunctionList.length; i++)
			{
				ovOnLoadFunctionList[i]();
			}
	}
}
window.onload = ovExecOnLoadFunctions;
