<!--
/* global vars*/
var helpURL = "http://help.thevoiceinternet.com";
/**** general functions ****/
function _init(){
	/* call any preload image functions throughout the template */
	if(typeof window.preloadGlobalImages == "function" ) window.preloadGlobalImages();
	if(typeof window.preloadHeaderImages == "function" ) window.preloadHeaderImages();
	if(typeof window.preloadContextImages == "function" ) window.preloadContextImages();
	if(typeof window.preloadFooterImages == "function" ) window.preloadFooterImages();
	if(typeof window.preloadPopUpImages == "function" ) window.preloadPopUpImages();

	/* call any specified onLoadExtras methods within the core page */
	if(typeof window.onLoadExtras == "function" ) window.onLoadExtras();

	// focus the first textfield/textarea if it exists
	try
	{
	    if(document.forms[0] != "undefined" && document.forms[0] != null){
    		var elements = document.forms[0].elements
		    for(var a=0; a<elements.length;a++){
    			if((elements[a].type == "text" || elements[a].type == "textarea" || elements[a].type == "password") && !elements[a].readOnly && !elements[a].disabled){
				    elements[a].focus()
				    break;
			    }
		    }
	    }
	}catch(err){}
}
function goBack(steps){
	// check optional steps arg
	if( !isNaN(parseFloat(steps)) ){
		// if a valid value was passed 
		// then go back that many steps
		history.go(-steps);
	}else{
		// default - go back 1
		history.go(-1);
	}
}
function goTo(url){
	window.location = url;
}
function goTo_frompopup(url){
	var ow = window.opener;
	if(ow == null || typeof ow == "undefined" || ow.closed){
		// (nonIE, IE, IE)
		// HAD or NO opener
		var nw = window.open(url);
		nw.focus();
	}else{
		// HAS opener
		ow.location.href=url;
		ow.focus();
	}
}
function SetAllCheckboxes(bool)
{
	var e = document.forms[0];
	// loop through the element and select/deselect the boxes
	for (var n=0; n < e.length; n++){
		if (e.elements[n].type=='checkbox'){
			e.elements[n].checked=bool;
		}
	}
	return false;
}
function getQueryString(){
	var q = window.location.search
	q = q.substring(1, q.length);
	return q;
}
function getQSArgs() {
	var args = new Object();
	var query = location.search.substring(1);
	var pairs = query.split("&");
	for (var i = 0; i < pairs.length; i++){
		var pos = pairs[i].indexOf('=');
		if (pos == -1) continue;
		var argname = pairs[i].substring(0,pos);
		var value = pairs[i].substring(pos+1);
		args[argname] = unescape(value);
	};
	return args;
};


/**** help functions ****/
function show_help(id)
{
    var url = '/help/GetArticle.ashx?ID=' + id;
    $.ajax({
        type: "GET", //POST
        url: url, //Set call to Page Method
        data: null, // Set Method Params
        success: function(msg, status) {
            overlib(msg,CAPTION,'HELP',WIDTH,350, BGCLASS, 'ol_bg', FGCLASS, 'ol_fg', CELLPAD, 5, 10);
            },
        error: function(xhr,msg,e){
            overlib('Error retrieving Help information',CAPTION,'HELP',WIDTH,300, BGCLASS, 'ol_bg', FGCLASS, 'ol_fg', CELLPAD, 5, 10);
            }
        });
}
function registerForHelp(ev, articleid)
{
    // register the calling element for help mouse events
    ev.onmouseover = function(){show_help(articleid);}
    ev.onmouseout = function(){return nd();}
    // forward the initial call
    show_help(articleid);
}

// add the RoboHelp logic file
document.write("<script language='JavaScript1.2' src='/_JS/RoboHelp_CSH.js' type='text/javascript'><\/script>");

function getHelp(topicID, windowType){
	if(typeof topicID == 'undefined'){topicID = 0;}
	if(typeof helpType == 'undefined'){helpType = HH_HELP_CONTEXT;}
	if(typeof windowType == 'undefined'){windowType = "Main";}
	// Check the browser...we're looking for ie/win, but not aol
	var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // true if we're on ie
	var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; // true if we're on windows
	var strPathAndWindow;

	/* deliver only WebHelp for now
	 * other help formats do not contribute to reporting
	 */
	strPathAndWindow = helpURL + "/roboapi.asp>" + windowType;
	//strPathAndWindow = "http://mikey/roboapi.asp>" + windowType;
	/*
	if(isWin && isIE){
		// WIN can handle RoboEngine
		strPathAndWindow = "http://help.thevoiceinternet.com/roboapi.asp>" + windowType;
	}else{
		// all other browsers get Flash version for compatibility reasons
		strPathAndWindow = "http://localhost/Callwords/help/FlashHelp/Callwords.htm>" + windowType;
	}
	*/
	//var prompt1 = prompt("test",strPathAndWindow,"");
	RH_ShowHelp(0, strPathAndWindow, helpType, topicID)
}
function getTutorial(topicID){
	var tutURL = helpURL + "/tutorials/?id=" + topicID;
	popWin(tutURL, 'tutorialWin', 740, 525, 'status=1');
}
//-->