/*-------------------------
Global JS
-------------------------*/

var baseUrl = window.location.href.split("/")[0]+"/"+window.location.href.split("/")[1]+"/"+window.location.href.split("/")[2]+"/";

/* Generic Popup function */
	function openPopupCustom( url, windowname, height, width, scroll ) {
	  var popup = window.open( url , windowname, "toolbar=no,status=yes,scrollbars="+scroll+",menubar=no,locationbar=no,top=35,left=20,width="+width+",height="+height+",resizable=yes");
	  popup.focus();
	}
	
	/* Generic Popup function */
	function openPopupPrint( url, windowname ) {
	  var popup = window.open( url , windowname, "toolbar=no,status=yes,scrollbars=yes,menubar=yes,locationbar=no,top=35,left=20,width=640,height=400,resizable=yes");
	  popup.focus();
	}
	/* Open the print version of this window */
	function openPrintPopup()	
	{
	var str;
	var len;
	var use;
			
	str=this.location.href; 
	str=str.replace('http://','');
	len = str.length;
	use = str.slice(str.indexOf('/'),len);
	openPopupPrint(use+'?print=true','ecpPrint');
	}
	
// Grabs a parameter from the URL.  Returns an empty
// string if parameter does not exist.
function getParameter(param) {
        var val = "";
        var qs = window.location.search;
        var start = qs.indexOf(param);

        if (start != -1) {
                start += param.length + 1;
                var end = qs.indexOf("&", start);
                if (end == -1) {
                        end = qs.length
                }
                val = qs.substring(start,end);
        }
        return val;
}
// Call it like this: var contextstrform = getParameter("contextForm");

function printCheck(){
	var printTest = getParameter("print");
	
	if(printTest=='true'){
		document.write('<link href="/css/print.css" rel="stylesheet" type="text/css" media="all">')
	}	
}

function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
    
  document.cookie = cookie_string;

}

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );

  if ( results )
    return ( unescape ( results[1] ) );
  else
    return null;
}
