
/* ----------------------------------------------
   Javascript Utilities Library
   for MDBriefcase.com
   ---------------------------------------------- */

/* Open a new window */
function openWindow(url, name, width, height, toolbar, location, directories, menubar, status) {
	//debugging
	//alert(url);

	window.open(
				url,
				name,
				"width=" + width +
				",height=" + height +
				",toolbar=" + toolbar +
				",location=" + location +
				",directories=" + directories +
				",menubar=" + menubar +
				",status=" + status +
				",scrollbars=yes,resizable=yes,copyhistory=no"
				);
}

/* when you click a link on a pop-up, this function
   will load the url into the window that created the popup */
function openWindowInParent(url) {
	//debugging
	//alert(url);
	opener.location = url;
	opener.focus();
}

/* image onMouseOver function */
function swapImageOn(imageName) {
    if (document.images) {
        document[imageName].src = eval(imageName + "_over.src");
    }
}

/* image onMouseOut function */
function swapImageOff(imageName) {
    if (document.images) {
        document[imageName].src = eval(imageName + "_off.src");
    }
}



/* answerChecked and validateForm are for form validation */
function answerChecked(form) {
  for (i=0; i<form.answer.length; i++) {
    if (form.answer[i].checked) {
      return true;
    }
  }
  return false;
}

function validateForm(form) {
  if (!answerChecked(form)) {
    alert("Please select an answer.");
    return false;
  } else {
    return true;
  }
}


/* for drop-down dynamic navigation */
function goThere(){
if (document.selecter1.select1.options[document.selecter1.select1.selectedIndex].value != "none") {
location = document.selecter1.select1.options[document.selecter1.select1.selectedIndex].value
		}
}
function refreshOpener()
{
	if(window.opener) window.opener.location = window.opener.location;
}
	
	
function RollOverImage(layer, image, imageElement, color)
{

    var imageLayer, image;
    imageLayer = xGetElementById(layer);
    xInnerHtml(layer, "<IMG src='" + image + "' border=0 />");
    imageElement.border=2;   
    if(color)
    {        
        imageElement.style.borderColor="#FFCA08";
    }
    
}

function addBookmark(title,url) {if (window.sidebar) {window.sidebar.addPanel(title, url,"");} else if(document.all) {window.external.AddFavorite(url, title);} else if( window.opera && window.print) {return true;}}

function ImageRotater(timer,  image_arr)
{					    
    var counter = 0;    
    
    this.tmr = xTimer.set('interval', this, "rotate_image", timer);	
    			   			    
    //Priviliged Method which handles rotating of images			    
    this.rotate_image = function()
    {		
        xHide_display(image_arr[counter]);			        
        if(counter < image_arr.length-1)
        {
            counter = counter + 1;
        }else
        {
            counter = 0;
        }			        
        xShow_display(image_arr[counter]);			        			        
    }
}