/*
	Global JS file of utility and helper functions
*/
/*---------------------*/
/*      Breadcrumb     */
/*-------------------- */

function setBreadcrumb(sectionTitle, sectionLink, subsectionTitle){
	
	// if sectionTitle only
	if(typeof(subsectionTitle) == "undefined"){
		$("#breadcrumb #breadsection").html(sectionTitle);

	// if sectionTitle, sectionLink, and subsectionTitle
	}else{
		$("#breadcrumb #breadsection a").html(sectionTitle);
		$("#breadcrumb #breadsection a").attr("href", sectionLink);
		$("#breadcrumb #breadsubsection").html("/ " + subsectionTitle);
	}
	$("#breadcrumb").css("visibility", "visible");
}

function openPopup( pageToLoad, winName, width, height, center, scroll, winXpos, winYpos, resize) {

	xposition = 0;
	xposition = winXpos;
	yposition = 0;
	yposition = winYpos;
	resizable = 0;
	resizable = resize;
	if ((parseInt(navigator.appVersion) >= 4 ) && (center)) {
		xposition = (screen.width - width) / 2;
		yposition = (screen.height - height) / 2;
	}
	args = "width=" + width + ","     + "height=" + height + ","
	+ "location=0," + "menubar=0,"  + "resizable=" + resizable + "," + "scrollbars=" + scroll + ","
	+ "status=0,"   + "titlebar=0," + "toolbar=0," +                   "hotkeys=0,"
	+ "screenx=" + xposition + ","  //NN Only
	+ "screeny=" + yposition + ","  //NN Only
	+ "left=" + xposition + ","     //IE Only
	+ "top=" + yposition;           //IE Only

	return window.open( pageToLoad,winName,args );
}



jQuery.fn.centerVertically = function(options) {
	var pos = {
		sTop : function() {
			return window.pageYOffset || document.documentElement && document.documentElement.scrollTop ||  document.body.scrollTop;
		},
	
		wHeight : function() {
			return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body.clientHeight;
		}
	};

	return this.each(function(index) {

		if (index == 0) {
			var $this = $(this);
			var elHeight = $this.height();
			var elTop = pos.sTop() + (pos.wHeight() / 2) - (elHeight / 2);
	
			$this.css({
				position: 'absolute',
				marginTop: '0',
				top: elTop
			});
		}
	});
};	



function queryString(parameter) { 
  var loc = location.search.substring(1, location.search.length);
  var param_value = false;

  var params = loc.split("&");
  for (i=0; i<params.length;i++) {
      param_name = params[i].substring(0,params[i].indexOf('='));
      if (param_name == parameter) {
          param_value = params[i].substring(params[i].indexOf('=')+1)
      }
  }
  if (param_value) {
      return param_value;
  }
  else {
      return ""; //Here determine return if no parameter is found
  }
}

