//function SubmitIt()
//{
//	if(window.event.keycode == 13)
//		document.form[0].submit;
//}



// Determines if a Real Player is installed
function getReal() {

	if (plugInFound || activeXFound) {return true}
	// If IE4 Mac, plugins can't be detected
	if(plgIe4Mac) {return false}

	// Check for Plug-in presence
	plugInFound = getPlugIn("RealPlayer","G2","Plug-In")

	
	// Check for RealPlayer ActiveX
	try {
		testObject = new ActiveXObject("rmocx.RealPlayer G2 Control.1")

		// Since G2 (Real 6), all Real player version numbers begin by 6
		embedVersion = testObject.GetVersionInfo()
		
		// First version supported : 6.0.6.131 = G2 Gold
		versionArray = embedVersion.split(".")
		conditionA = versionArray[0]>=6
		conditionB = versionArray[1]>=0
		conditionC = versionArray[2]>=6
		conditionD = versionArray[3]>=131
		
		if (conditionA) {
			activeXFound = true;
		} else {
			activeXFound = true;
		}		

	} catch(e) {
		activeXFound = false
	}
	
	if (plugInFound || activeXFound) {return true} else {return false}	
}




// Parse plugins collection with strings to find
// User has to pass strings to be found in plugin name and description
// Ex. "Shockwave","Flash","5"
function getPlugIn() {

	// search for the right plugin among all those have been installed
	allFound = false
    plugInsCollection = navigator.plugins
	
	for (i=0;i<plugInsCollection.length;i++) {

		// Get plugin description
        plugInDescription = " " + plugInsCollection[i].description
		plugInName = " " + plugInsCollection[i].name

		for (j=0;j<arguments.length;j++) {
		
			if (plugInDescription.indexOf(" " + arguments[j])!=-1 || plugInName.indexOf(" " + arguments[j])!=-1) {
				allFound = true
			} else {
				allFound = false
				break
			}
		}
		
		// Send back the search result
		if (allFound) {return true}
    	}

	// Send back the search result
	return false
}





function ReturnIt(cd,track,title,myform,myvelement,myhelement)
{
	if( window.opener != null ) // dont do anything if we werent called from another page
	{
		if( !window.opener.closed )
		{
			if( confirm( 'Please confirm your selection: \"' + title + '\".  This will replace any previous selections.' ) )
			{
				if( window.opener.document.forms[myform].elements[myvelement] != null )
					window.opener.document.forms[myform].elements[myvelement].value='CD' + cd + '-TK' + track + '-' + title;
				if( window.opener.document.forms[myform].elements[myhelement] != null )
					window.opener.document.forms[myform].elements[myhelement].value='CD' + cd + '-TK' + track + '-' + title;
				window.close(); // successful close
			}
		}
			else
				window.close();
	}
}

function PopUp(ref,w,h)
{	
	var strFeatures="toolbar=no,status=no,menubar=no,location=no"
	strFeatures=strFeatures+",scrollbars=yes,resizable=yes,height=" + h + ",width=" + w;
	
	newWin = window.open(ref,"TellObj",strFeatures);
       newWin.opener = top;
}

function openWindow(page,w,h) {
    window.open(page,"","status=no,width=" + w + ",height=" + h + ",scrollbars=yes");
}

function showFBWin(pageName) {
	w = 790;
	h = 575;

	clientTop = 50;
	clientLeft = screen.Width/8;
	var page = "applications/formbuilder/formbuilder_" + pageName + ".aspx";
	window.open(page,"","status=no,width=" + w + ",height=" + h + 
                ",scrollbars=no,top=" + clientTop + ",left=" + clientLeft +
                ",resizable=yes");

}

function showHide(div) {
	if (document.all) {
		var currDiv = eval("document.all('" + div + "')");
		var currImg = eval("document.all('img" + div + "')");
		if (currDiv != null) {
			if (currDiv.style.display == "none") {
				currDiv.style.display = "block";
				currImg.src = "images/minus.gif";
			} else {
				currDiv.style.display = "none";
				currImg.src = "images/plus.gif";
			}
		}
	}
}

function DoSearch() {
	var frm = document.forms["searchForm"];
    var searchText = frm.txtSearch.value
    if (searchText == "") {
        alert("Please enter the text you would like to search for.");
    } else {
        location.href = "default.aspx?id=result&searchText=" + searchText;
        return false;
    }
}
function TestKey() {
    if (event.keyCode == 13) {        
		event.cancelBubble = true;
		event.returnValue = false;
		DoSearch();
	}
}

function onMouseOutTr(obj){
	if (document.all) {
	 	obj.style.backgroundColor="#F7F7F1";
	}
	 
}
function onMouseInTr(obj){
	if (document.all)  {
		obj.style.backgroundColor="#ffff00";
		obj.style.cursor = "hand";
	}
}



// The code by Captain <cerebrum@iname.com>
// Mead & Company, http://www.meadroid.com/wpm/

// fake print() for IE4.x
if ( !printIsNativeSupport() )
  window.print = printFrame;

// main stuff
function printFrame(frame, onfinish) {
  if ( !frame ) frame = window;

  if ( frame.document.readyState !== "complete" &&
       !confirm("The document to print is not downloaded yet! Continue with printing?") )
  {
    if ( onfinish ) onfinish();
    return;
  }

  if ( printIsNativeSupport() ) {
    /* focus handling for this scope is IE5Beta workaround,
       should be gone with IE5 RTM.
    */
    var focused = document.activeElement; 
    frame.focus();
    frame.self.print();
    if ( onfinish ) onfinish();
    if ( focused && !focused.disabled ) focused.focus();
    return;
  }

  var eventScope = printGetEventScope(frame);
  var focused = document.activeElement;

  window.printHelper = function() {
    execScript("on error resume next: printWB.ExecWB 6, 1", "VBScript");
    printFireEvent(frame, eventScope, "onafterprint");
    printWB.outerHTML = "";
    if ( onfinish ) onfinish();
    if ( focused && !focused.disabled ) focused.focus();
    window.printHelper = null;
  }

  document.body.insertAdjacentHTML("beforeEnd",
    "<object id=\"printWB\" width=0 height=0 \
    classid=\"clsid:8856F961-340A-11D0-A96B-00C04FD705A2\"></object>");

  printFireEvent(frame, eventScope, "onbeforeprint");
  frame.focus();
  window.printHelper = printHelper;
  setTimeout("window.printHelper()", 0);
}



// helpers
function printIsNativeSupport() {
  var agent = window.navigator.userAgent;
  var i = agent.indexOf("MSIE ")+5;
  return parseInt(agent.substr(i)) >= 5 && agent.indexOf("5.0b1") < 0;
}



function printFireEvent(frame, obj, name) {
  var handler = obj[name];
  switch ( typeof(handler) ) {
    case "string": frame.execScript(handler); break;
    case "function": handler();
  }
}



function printGetEventScope(frame) {
  var frameset = frame.document.all.tags("FRAMESET");
  if ( frameset.length ) return frameset[0];
  return frame.document.body;
}
