	// Common variable setup
var topcol1='#D72700'; topcol2='#cccccc'; ; topcol3='#ff0012'; topcol4 = '#FF9900';
var midcol1='#FF9933'; midcol2='#cccccc'; midcol3='#ffffff'; midcol4='#999999'
var midnav1=''; topnav1=''; myrowname='';
document.bgColor ='#585858'
cookie_name="textsize"; 
font1="0.66pc"; font2="0.80pc";

function dcsMultiTrack() {
//  black script to be replaced with code from Webtrends
}

//	setnav highlights the bars underneath/next to menu items.  Depending on what is passed in
//	it will highlight the given section by finding the id that is passed in.
function setnav(topnav, midnav, bodnav, sidnav, dropper) { 
	if (topnav!='') {topnav1="ln_"+topnav; topnav2="td_"+topnav;}
	if (midnav!='') {midnav1="ln_"+midnav; midnav2="td_"+midnav;}

	if (topnav!='') {document.getElementById(topnav1).style.background=topcol1}
	if (midnav!='') {document.getElementById(midnav1).style.background=midcol1}
	if (bodnav!='') {document.getElementById(bodnav).className = 'highlight'}
	if (sidnav!='') {	
			namer=sidnav.substring(1,sidnav.length);
			if (dropper=='') {myarr=eval("arr_"+namer); myarr.src="images/shim.gif";}

			myblk=eval("blk_"+namer); myblk.src="images/icon_block.gif"; 
			myrowname="row_"+namer; myrow=eval(myrowname); colorhi1='#dddddd'; colorhi2='#cccccc';
			mynum=sidnav.substring(0,1); myrow.style.backgroundColor=eval("colorhi"+mynum);
	}
	if (dropper!='') {
			myprompt=dropper.lastIndexOf('_')
			mydrop=eval(dropper.substring(0,myprompt))
			myindex=dropper.substring(myprompt+1,dropper.length); 
			mydrop.selectedIndex=myindex;
	}
}

// navover and navoff are called to change the colors of the bars when the mouse hovers over a link in a nav bar	
function navover(which,col) {document.getElementById("ln_"+which).style.background=col}
function navoff(which,col,nav) {if (("ln_"+which)!=nav) {document.getElementById("ln_"+which).style.background=col}}

//putCookie adds the cookie that is used to store the text size settings
function putCookie() {
	if(document.cookie != document.cookie) {index = document.cookie.indexOf(cookie_name);} else { index = -1;}
	if (index == -1){
		document.cookie=cookie_name+"="+mysize+"; expires=Monday, 04-Apr-2010 05:00:00 GMT; path=/";
	} 
}

//	setRule is called to change the size of the font when the user clicks on the link in 
//	the site tools bar in the banner.
function setRule(stylesheet,rule,attribute,value){
	if (!document.styleSheets) return false;
	var lRules = new Array();

	if (document.styleSheets[stylesheet].cssRules) 
		lRules = document.styleSheets[stylesheet].cssRules
	else if (document.styleSheets[stylesheet].rules)
		lRules = document.styleSheets[stylesheet].rules
	else return false;

	//alert(lRules[0].style.fontSize)
 	if (value=="") {if (lRules[0].style.fontSize==font1) {value=font2} else {value=font1}	}

	mysize=value; //alert('value is '+value)
	lSuccess = eval("lRules[" + rule + "].style." + attribute + " = value")
	putCookie();
	return lSuccess;
}

//	getCookie reads the cookie from the user and sets the font size accordingly.
function getCookie() {
	if(document.cookie) {
		index = document.cookie.indexOf(cookie_name);
		if (index != -1) {
			namestart = (document.cookie.indexOf("=", index) + 1);
			nameend = document.cookie.indexOf(";", index);
			if (nameend == -1) {nameend = document.cookie.length;}
			mysize = document.cookie.substring(namestart, nameend);
			setRule(0,0,'fontSize',mysize);
		}
	} //else {alert('no cookie')}
}

//	showOnly is used to show specified expandable section on a page in the site.
function showOnly(namer,id_all,id_show) {
	for (i=1; i<id_all+1; i++) {
		if (i<10) {spacer="0"} else {spacer=""}
		the_id=namer+spacer+i
		var obj = (dom)? document.getElementById(the_id): document.all[the_id];
	
	if (i!=id_show) {
			obj.style.visibility = "hidden";
			obj.style.display = "none";
		} else {
			obj.style.visibility = "visible";
			obj.style.display = "block";
		} 
	}		
}

//	show_hide is used to show/hide expandable sections in the site.  It also
//	will change the image of the + to a - or vice versa.
var dom = (document.getElementById && !document.all)? 1: 0;
function show_hide(the_id,icon) {
	var obj = (dom)? document.getElementById(the_id): document.all[the_id];
	if (icon!='') {arr=eval(the_id+"_"+icon)}
	
	if(obj.style.visibility == "hidden"){ // show
		obj.style.visibility = "visible";
		obj.style.display = "block"; // If this looks wrong, try 'inline'
		if (icon!='') {arr.src = "images/nav_minus.gif";}
	} else { // hide
		obj.style.visibility = "hidden";
		obj.style.display = "none";
		if (icon!='') {arr.src = "images/nav_plus.gif"; }
	}
}

//	showH_hideall is used to show/hide all expandable sections on a page in the site.  It also
//	will change the image of the + to a - or vice versa.
function show_hideall(id_start,id_end,icon,the_act) {
for (i=id_start; i<id_end+1; i++) {
	if (i<10) {spacer="0"} else {spacer=""}
	the_id="q"+spacer+i
	var obj = (dom)? document.getElementById(the_id): document.all[the_id];
	if (icon!='') {arr=eval("q"+spacer+i+"_"+icon)}
	
	if(the_act=="show"){ // show
		obj.style.visibility = "visible";
		obj.style.display = "block"; // If this looks wrong, try 'inline'
		if (icon!='') {arr.src = "images/nav_minus.gif";}
	} else { // hide
		obj.style.visibility = "hidden";
		obj.style.display = "none";
		if (icon!='') {arr.src = "images/nav_plus.gif"; }
	}
}
}

//-- may replace popup and popupgeneric below
function openWin(url, winName) { //v2.0
 	width=screen.width-170; height=screen.height-230
	sizer='yes'; scrollstat='yes'
  
  	newWin=window.open(url, winName,'width=' + width + ',height=' + height + ',resizable=' + sizer + ',scrollbars=' + scrollstat + ',menubar=yes,status=yes,toolbar=yes,location=yes,top=30,left=85' );
	newWin.focus()
	}


//	popup will create a popup showing the given URL with the specified width and height.  The user can also
//	choose to show the scrollbar and whether or not to allow the user to resize the popup.
function popup(url, width, height, scrollstat, sizer) {
  window.open(url,'','width=' + width + ',height=' + height + ',resizable=' + sizer + ',scrollbars=' + scrollstat + ',menubar=no,status=no,toolbar=yes,location=yes,top=30,left=85' );
}

//	popupgeneric opens an url in a popup window with a width of 835
function popupgeneric(theurl) {
 	width=835; height=screen.height-250
	sizer='yes'; scrollstat='yes'
	popup(theurl, width, height, scrollstat, sizer)
}

function selecturl(theurl) { //v2.0
  starturl=theurl.substring(0,7)
  if ((starturl=="http://")||(starturl=="https:/")) {openWin(theurl,'')} else {MM_goToURL('parent',theurl)}
}

/* printit is called when the user clicks the print button in site tools */
function printit(){  
	if (window.print) {window.print();}
}

/* bookit is called when the user clicks the bookmark button in site tools */
function bookit(linkUrl,linkTitle){
   if (!document.all) {
      alert('Please hit ctrl-d to bookmark this page');
   }
   else external.AddFavorite(linkUrl,linkTitle);
   return false;
}

/* forwards a user to the url */
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

/* used to find an object in the DOM */
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/* MM_validateForm is used to validate the forms on the site */
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;

  /* loop through the arguments passed in */
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
	  /* if we are checking an email field */
      if (test.indexOf('isEmail')!=-1) { 
	  		var err_found = 0; //was it invalidated
			var at="@" // at character
			var dot="." // dot character
			var lat=val.indexOf(at) //find leftmost position of at character
			var lval=val.length     // find length
			var ldot=val.indexOf(dot) // find index of the dot in the string
			// if we didn't find an @ throw error
			if (val.indexOf(at)==-1){
				if( err_found == 0)
				{
					errors+='- '+nm+' must contain an e-mail address.\n';
					err_found = 1;
				}
			}
			// if we didn't find an at, or it was at position zero or the end of the string
			// throw and error
			if (val.indexOf(at)==-1 || val.indexOf(at)==0 || val.indexOf(at)==lval){
				if( err_found == 0)
				{
					errors+='- '+nm+' must contain an e-mail address.\n';
					err_found = 1;
				}
			}
			// if we can't find a dot or if it is at pos 0 or end, throw error
			if (val.indexOf(dot)==-1 || val.indexOf(dot)==0 || val.indexOf(dot)==lval){
				if( err_found == 0)
				{
					errors+='- '+nm+' must contain an e-mail address.\n';
					err_found = 1;
				}
			}
			// if there is a 2nd at after the first throw an error
			if (val.indexOf(at,(lat+1))!=-1){
				if( err_found == 0)
				{
					errors+='- '+nm+' must contain an e-mail address.\n';
					err_found = 1;
				}
			}
			// Check dot position
			if (val.substring(lat-1,lat)==dot || val.substring(lat+1,lat+2)==dot){
				if( err_found == 0)
				{
					errors+='- '+nm+' must contain an e-mail address.\n';
					err_found = 1;
				}
			}
			// Check dot position
			if (val.indexOf(dot,(lat+2))==-1){
				if( err_found == 0)
				{
					errors+='- '+nm+' must contain an e-mail address.\n';
					err_found = 1;
				}
			}
			// Make sure no spaces
			if (val.indexOf(" ")!=-1){
				if( err_found == 0)
				{
					errors+='- '+nm+' must contain an e-mail address.\n';
					err_found = 1;
				}
			}

      } 
	  else if (test!='R') {
		  num = parseFloat(val);
		  if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
		  if (test.indexOf('inRange') != -1) { 
			  p=test.indexOf(':');
			  min=test.substring(8,p); max=test.substring(p+1);
			  if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
		  }
	  } 
	  } 
	  else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

/* MM_validateForm2 is a slight variation of MM_validateForm where second arg the name if not blank */
function MM_validateForm2() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm2.arguments;

  /* loop through the arguments passed in */
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]); nm1=args[i+1];
    if (val) { nm=val.name; if ((val=val.value)!="") {
	  /* if we are checking an email field */
      if (test.indexOf('isEmail')!=-1) { 
	  		var err_found = 0; //was it invalidated
			var at="@" // at character
			var dot="." // dot character
			var lat=val.indexOf(at) //find leftmost position of at character
			var lval=val.length     // find length
			var ldot=val.indexOf(dot) // find index of the dot in the string
			// if we didn't find an @ throw error
			if (val.indexOf(at)==-1){
				if( err_found == 0)
				{
					errors+='- '+nm+' must contain an e-mail address.\n';
					err_found = 1;
				}
			}
			// if we didn't find an at, or it was at position zero or the end of the string
			// throw and error
			if (val.indexOf(at)==-1 || val.indexOf(at)==0 || val.indexOf(at)==lval){
				if( err_found == 0)
				{
					errors+='- '+nm+' must contain an e-mail address.\n';
					err_found = 1;
				}
			}
			// if we can't find a dot or if it is at pos 0 or end, throw error
			if (val.indexOf(dot)==-1 || val.indexOf(dot)==0 || val.indexOf(dot)==lval){
				if( err_found == 0)
				{
					errors+='- '+nm+' must contain an e-mail address.\n';
					err_found = 1;
				}
			}
			// if there is a 2nd at after the first throw an error
			if (val.indexOf(at,(lat+1))!=-1){
				if( err_found == 0)
				{
					errors+='- '+nm+' must contain an e-mail address.\n';
					err_found = 1;
				}
			}
			// Check dot position
			if (val.substring(lat-1,lat)==dot || val.substring(lat+1,lat+2)==dot){
				if( err_found == 0)
				{
					errors+='- '+nm+' must contain an e-mail address.\n';
					err_found = 1;
				}
			}
			// Check dot position
			if (val.indexOf(dot,(lat+2))==-1){
				if( err_found == 0)
				{
					errors+='- '+nm+' must contain an e-mail address.\n';
					err_found = 1;
				}
			}
			// Make sure no spaces
			if (val.indexOf(" ")!=-1){
				if( err_found == 0)
				{
					errors+='- '+nm+' must contain an e-mail address.\n';
					err_found = 1;
				}
			}

      } 
	  else if (test!='R') {
		  num = parseFloat(val);
		  if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
		  if (test.indexOf('inRange') != -1) { 
			  p=test.indexOf(':');
			  min=test.substring(8,p); max=test.substring(p+1);
			  if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
		  }
	  } 
	  } 
	  else if (test.charAt(0) == 'R') errors += '- '+nm1+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue2 = (errors == '');
}



// This function is called when the shop pages load.  It pulls what page you are looking at
// and shows the correct sidebar featured product.  This is used in order to keep 1
// side include instead of 3
function shop_OnLoad()
{
	var url = document.URL; // get URL
	var filename = url.substring(url.lastIndexOf('/') + 1,url.length); //get filename from URL
	var page = filename.substring(0,filename.indexOf('.') ); //get pagename from URL
	if(page != null)
	{
		// show Feature Product table (naming convention is page_fp for id)
		var obj = (dom)? document.getElementById(page + "_fp"): document.all[page + "_fp"];
		obj.style.visibility = 'visible';
		obj.style.display = 'block';
		// show Descriptive text for product (naming is page_desc for id)
		obj = (dom)? document.getElementById(page + "_desc"): document.all[page + "_desc"];
		obj.style.visibility = 'visible';
		obj.style.display = 'block';
	}
}

// indexOnLoad is called when the index.html page is called.  it is needed to fix issues
// with using a common include on the entire site.  It takes the URLs and Image links in the
// page and strips the leading ../ off of them.  This fixes the links and image locations 
// that would otherwise be broken
function indexOnLoad()
{
	for(var count = 1; count < 20; count++)
	{
		// Find all banner images based on their id
		var obj = (dom)? document.getElementById("ban" + count): document.all["ban" + count];
		if(obj != null)
		{
			// if the image was found removed anything before global includes so that the index can find it out of the root directory
			obj.src = obj.src.substring(obj.src.indexOf('global_includes'),obj.src.length);
		}
		// Find links in the banner
		var obj = (dom)? document.getElementById("ban_link" + count): document.all["ban_link" + count];
		if(obj != null)
		{
			// If link was found,  and it is to index, put that as new link, otherwise keep directory and file, remove the rest.
			var temp = new Array();
			temp = obj.href.split('/');
			var length = temp.length;
			if (temp[length - 1 ] != "index.html")
			{
				obj.href = temp[length - 2] + "/" + temp[length -1];
			}
			else
			{
				obj.href="index.html";
			}
		}
		// Same as above for images but in the navigation bar.
		var obj = (dom)? document.getElementById("nav" + count): document.all["nav" + count];
		if(obj != null)
		{
			obj.src = obj.src.substring(obj.src.indexOf('global_includes'),obj.src.length);
		}
		// same as above but for links in the nav bar.
		var obj = (dom)? document.getElementById("nav_link" + count): document.all["nav_link" + count];
		if(obj != null)
		{
			var temp = new Array();
			temp = obj.href.split('/');
			var length = temp.length;
			if (temp[length - 1 ] != "index.html")
			{
				obj.href = temp[length - 2] + "/" + temp[length -1];
			}
			else
			{
				obj.href="index.html";
			}
		}
	}
}

// The following code is used to detect whether or not the user has the Flash Plugin
// initialize global variables for checking
var detectableWithVB = false;
var pluginFound = false;

// Searches for flash by calling detectPlugin or detectActiveXControl
function detectFlash() {
    pluginFound = detectPlugin('Shockwave','Flash'); 
    // if not found, try to detect with VisualBasic (needed for IE on windows)
    if(!pluginFound && detectableWithVB) {
//		pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1');
		pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.6');
}
    // return pluginFound to caller.  True if flash was detected, otherwise false.
    return pluginFound;
}

function help ()
{
open ("http://www.mcgraw-hill.co.uk/help.html", "Help", "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=1,width=460,height=600");
}

function helpusa ()
{
open ("http://www.mcgraw-hill.co.uk/openupusa/help.html", "Help", "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=1,width=460,height=600");
}

function gotomhhe ()
{
open ("http://catalogs.mhhe.com/mhhe/findRep.do", "MHHE", "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=1,width=750,height=600");
}

// Detect Plugin is used for Netscape/Mozilla plugin checking
function detectPlugin() {
    // allow for multiple checks in a single pass
    var thePlugins = detectPlugin.arguments;
    // consider pluginFound to be false until proven true
    var pluginFound = false;
    // if plugins array is there and not fake (IE has a placeholder that is always empty)
    if (navigator.plugins && navigator.plugins.length > 0) {
		var pluginsArrayLength = navigator.plugins.length;
		// for each plugin...
		for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
		    // loop through all desired names and check each against the current plugin name
		    var numFound = 0;
		    for(namesCounter=0; namesCounter < thePlugins.length; namesCounter++) {
				// if desired plugin name is found in either plugin name or description
				if( (navigator.plugins[pluginsArrayCounter].name.indexOf(thePlugins[namesCounter]) >= 0) || 
					(navigator.plugins[pluginsArrayCounter].description.indexOf(thePlugins[namesCounter]) >= 0) ) {
					// this name was found
				    numFound++;
				}   
		    }
		    // if the number we found matches the total number provided then we were successful
			if(numFound == thePlugins.length) {
				pluginFound = true;
				break;
			}
		}
    }
    return pluginFound;
} // detectPlugin

// Here we write out the VBScript block for MSIE for Windows
// this is the only way to detect Flash in IE for windows. DetectPlugin won't work
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
    document.writeln('<script language="VBscript">');

    document.writeln('\'do a one-time test for a version of VBScript that can handle this code');
    document.writeln('detectableWithVB = False');
    document.writeln('If ScriptEngineMajorVersion >= 2 then');
    document.writeln('  detectableWithVB = True');
    document.writeln('End If');

    document.writeln('\'this next function will detect most plugins');
    document.writeln('Function detectActiveXControl(activeXControlName)');
    document.writeln('  on error resume next');
    document.writeln('  detectActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
    document.writeln('  End If');
    document.writeln('End Function');
    document.writeln('</script >');
}

getCookie();
