// JavaScript Document
// Replace the normal jQuery getScript function with one that supports
// debugging and which references the script files as external resources
// rather than inline.
// CR - Added 10/21/09 to overcome Opera 9.64 jQuery getScript problem and improve site speed
$.extend({
	getScript: function(url, callback) {
		var head = document.getElementsByTagName("head")[0];
		var script = document.createElement("script");
		script.src = url;

		// Handle Script loading
		var done = false;

		// Attach handlers for all browsers
		script.onload = script.onreadystatechange = function(){
			if ( !done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") ) {
					done = true;
					if (callback) {callback();}

					// Handle memory leak in IE
					script.onload = script.onreadystatechange = null;
			}
		};
		
		head.appendChild(script);

		// We handle everything using the script element injection
		return undefined;
	}
});

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//FUNCTIONS CALLED BELOW
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//SAME PAGE ANCHORS
//Selects samepage anchors( ^='#' means 'starting with'), changes the background to yellow, and fades to white in two seconds, then removes backgroundColor style for the element leaving the class background style if one exists.  Self creating and removing. 
	function fade(e){
		end_fade = (e=="#global")?"#eee":"#fff";
		$(e).css( 'backgroundColor', '#ff9').animate( { backgroundColor: end_fade }, 2000, function(){$(e).css( 'backgroundColor', '');});}

//TOP OF PAGE NAVIGATION
//Once the logo is hidden the left navigation becomes fixed and pagetop link is added to the nav. Self creating and removing.
	function handlescroll(){
		if ($(window).scrollTop()>164 && $(window).scrollLeft()===0 && $("#nav ul:first").height()+40-(40*$(".pagetop").length)<$(window).height()&& $("#nav").height()<$("#pagebody").height()){
			$("#nav").css({"top":-165+"px", "left":0, "position":"fixed"});
			if($(".pagetop").length===0) {
				$("#nav ul:first").append("<li class='pagetop'><a>Top of page</a></li>"); 
				$(".pagetop a").fadeIn(500).click(function(){$(window).scrollTop(0);});
			}
		} 
		else { 
			$("#nav").css({"top":"0px", "position":"static"});
			$(".pagetop").slideUp(200, function() {$(".pagetop").remove();}); 
		}
	}

//HANDLE PDF 
//Adds PDF icon to the right of each PDF link and ensures that the document opens at 75% in a new window (or tab).
//Update 2/2/10 to accomdate <a> tags wrapping images and spans
	function handlePDF(e){
		$(e).attr({href: $(e).attr("href")+"#zoom=75", target:"_blank"}).css({background:"url(/cgi-bin/images/pdf.gif) center right no-repeat", margin: "0", padding: "2px 16px 2px 0", textIndent:"0px"}).addClass("pdf");
		if (($.browser.msie && ($.browser.version.substr(0,3) == "7.0")) && $(e).parents("#print").size() < 1) {
			//override icon placement to overcome inline block display error
			$(e).css({background:"none", padding: "2px 0"});
			if ($(e).children('img').length<=0 && $(e).children('span').length<=0){
				$(e).append("&nbsp;<img src='/cgi-bin/images/pdf.gif' height='16' width='16' style='border:none; float:none; position:relative; top:3px;'/>");
			}
		}
		//Remove icon if element contains an img or span node
		if ($(e).children('img').length>0){$(e).css({background:"none",padding:"0"});}
		if ($(e).children('span').length>0){$(e).css({padding:"0"});}
		if ($(e).parents("#nav").length>0){$(e).css({display:"block", marginRight:"4px", padding: "5px 16px 5px 0px"});}}

//HANDLE EXTERNAL 
//Adds EXT icon to the right of each link and ensures that the document opens in a new window (or tab).
	function handleEXT(e){
		if ($(e).attr("href").indexOf("pct.edu") <0 && $(e).attr("class")!="request" && $(e).children("img").length<1){
			$(e).attr({target:"_blank"}).css({background:"url(/cgi-bin/images/external_link.gif) center right no-repeat ", padding: "2px 13px 2px 0"}).addClass("external");
			if (($.browser.msie && ($.browser.version.substr(0,3) == "7.0"))) { 
				$(e).css({background:"none", padding: "2px 0"});
				$(e).append("&nbsp;<img src='/cgi-bin/images/external_link.gif' height='10' width='10' style='border:none; float:none;'/>");}
			if ($(e).parents("#nav").length>0){$(e).css({display:"block", marginRight:"5px", padding: "5px 14px 5px 0px"});}
		}}
	
//BOX
//Lightbox for anything
	var box_follow=0;
	function initbox(e){
		//alert($(e).text()+" ready to AJAX");
		//if (box_follow>0){alert(box_follow);}
			if($(e).attr("href").indexOf(".jpg")>0 || $(e).attr("href").indexOf(".gif")>0 || $(e).attr("href").indexOf(".png")>0 || $(e).attr("href").indexOf(".JPG")>0 || $(e).attr("href").indexOf(".GIF")>0 || $(e).attr("href").indexOf(".PNG")>0){
				$(e).attr("title",($(e).attr("title")>"")?$(e).attr("title"):$("img",e).attr("alt"));
				$(e).attr("caption",($(e).attr("title")>"" && $("img",e).attr("alt")>"")?$("img",e).attr("alt"):"");
				$(e).attr({ajax:"image", target:$(e).attr("href")}).addClass("ajaximg");}
				
			else if($(e).attr("href").indexOf("/videos/")>=0 && $(e).attr("href").indexOf("?")>=0){
				qs = $(e).attr("href").split("i=")[1];
				vars = "file=/videos/FLV/"+qs.split("&")[0]+".flv&captions.file=/videos/XML/"+ qs.split("&")[0]+".xml&i="+qs.split("#")[0];
				$(e).attr({ajax:"video", target:vars }).addClass("ajaxvideo"); 
			}
			else if($(e).attr("href").indexOf("#")>=0){
				$(e).attr({ajax:"html", target:$(e).attr("href").replace(/#/," #")}).addClass("ajaxhtml");}
			else {
				$(e).attr({ajax:"html", target:$(e).attr("href")+" #content"}).addClass("ajaxhtml");}
			$(e).click(function (){enterbox(this); return false;});//binds clicks
	}
	function enterbox(e) {//box entered
		$("object").css({visibility:"hidden"});
		x=$(".obg").length;
		box_title = (e.title>"")?e.title:e.innerHTML;
		$("#content").append("<div class='obg' id='obg"+x+"' title='Click to close "+box_title+"'></div>");
		
		$("#obg"+x).hide().fadeIn(300).click(function(){exitbox();});//shows background
		if($.browser.msie){
			if($.browser.version<7){$("#obg"+x).css({filter:"alpha(opacity=60)", position: "absolute"});}
			$("#obg"+x).animate({opacity: '.6'}, 200);}
		$("#content").append("<div class='boxwrapper' id='box"+x+"'><div class='boxhead'><img src='/cgi-bin/images/boxclose.png' alt='Close "+box_title+"'><p>"+box_title+"</p></div><div class='boxbody'></div></div>");
		$("#box"+x).hide();
		if ($(e).siblings("a").length>0){
			p = $(e).prevAll("a"); n = $(e).nextAll("a");
			$("#box"+x+" .boxhead p").append("<span>"+(p.length+1)+" of "+($(e).siblings("a").length+1)+"</span>");	
			if(p.length>0){ 
				$("#box"+x).append("<a href='"+$(p).eq(0).attr('href')+"' id='gallery_prev' title='"+$(p).eq(0).attr("title")+"'><img src='/cgi-bin/images/prev_gray.png'></a>"); 
				$("#gallery_prev").css({position:"absolute", right:"100%", top:"45%", padding:"10px"});
				$("#gallery_prev").click(function (){
					$("#content").append("<div id='obgremove'></div>");
					$("#box"+x+",#obg"+x).remove();							
					$(p).eq(0).click(); 
					return false;
				});
			}
			if(n.length>0){ 
				$("#box"+x).append("<a href='"+$(n).eq(0).attr('href')+"' id='gallery_next' title='"+$(n).eq(0).attr("title")+"'><img src='/cgi-bin/images/next_gray.png'></a>");
				$("#gallery_next").css({position:"absolute", left:"100%", top:"45%", padding:"10px"});
				$("#gallery_next").click(function (){																																					
					$("#content").append("<div id='obgremove'></div>");
					$("#box"+x+",#obg"+x).remove();							
					$(n).eq(0).click(); 
					return false;
					}); 
				}
		}
		if($(e).attr("ajax")=="image"){
			var img = new Image();
			$(img).load(function (){ $("#box"+x+" .boxbody").append(img).addClass("img").css({minWidth:0});
									 $(".boxwrapper").css({minWidth:0}); 
									 if ($(e).attr("caption")!= ""){
										 $("#box"+x+" .boxbody").append("<p class='caption'>"+ $(e).attr("caption") +"</p>");
										 $("#box"+x+" .boxbody .caption").fadeTo(200, 0.3);
										 $("#box"+x+" .boxbody").hover(function(){$("#box"+x+" .boxbody .caption").fadeTo(200,0.8);}, function(){$("#box"+x+" .boxbody .caption").fadeTo(200,0.3);});
									 }
									 sizebox();}).attr('src', e.href);
		} else if($(e).attr("ajax")=="video"){
			w=480; fntsz=11;
			if($(e).attr("target").indexOf("width")>0){w=$(e).attr("target").split("width=")[1];w=w.split("&")[0];}
			w = (w==640)?690:w; fntsz = (w==690)?8:fntsz;
			
			$("#box"+x+" .boxbody").css({height:"360px",width:w+"px", overflow:"visible"});
			$("#box"+x+" .boxhead").css({width:w-20+"px"});
			$("#box"+x+" .boxbody").css({background:"url(/cgi-bin/images/loading.gif) no-repeat center #fff"});
			text='<embed  id="video'+x+'" name="video'+x+'" src="/videos/flvplayer.swf" allowfullscreen="true" allowscriptaccess="always" flashvars="';				
			text+= $(e).attr('target');
			if($(e).attr("href").indexOf("cc=false")<0){
				text +="&plugins=captions&captions.state=false&captions.fontsize="+ fntsz + "&captions.back=false";
			}
			text+= '&config=/videos/config.xml"' ;
			text+='wmode="opaque" style="width:'+ w +'px; height:360px; z-index:9000"></embed>';
			if ($.browser.mozilla && $.browser.version.substr(0,3)=="1.8"){text=text.replace(/opaque/g,"window");}
			//$("#box"+x+" .boxbody").load('/videos/flvplayer.swf', function(){  $(this).html(text); sizebox()});
			$("#box"+x+" .boxbody").html(text).css({background:"none"}); 
			sizebox();
		} else {
			$("#box"+x+" .boxbody").load($(e).attr("target"), function(){sizebox();});
		}
	}
	
	function sizebox(){
		$("#obgremove").fadeOut(500, function(){$("#obgremove").remove();});
		if ($(".boxbody #gallery").length>0 && $("#gallery_nav").length<1){
			//alert($("#gallery_nav").length);
			$.getScript("/cgi-bin/scripts/gallery.js");
			$("#gallery, #gallery div").css({ paddingBottom:"60px"});
			}
		$("#obg"+x).css({'background-image':'none'});
		$("#box"+x+" #globalnav, #box"+x+" .interactive").remove();// for old pages
		var oHeight = $("#obg"+x).outerHeight() - $("#box"+x).outerHeight();
		//alert(oHeight);
		if ((oHeight/2)>0){
			$("#box"+x).css('top',$(window).scrollTop()+(oHeight)/2+'px');}
		else {
			$("#box"+x).css('bottom','auto');$("#box"+x).css('top',($(window).scrollTop()+50)+"px");}		
		if ($.browser.msie && parseInt($.browser.version, 10)<7){
			$("#obg"+x).css({"height":document.body.offsetHeight, "position":"absolute", "top":0, "width":document.body.offsetWidth});
			$("#box"+x).css('bottom','auto');$("#box"+x).css('top',($(window).scrollTop()+($(window).outerHeight()-$("#box"+x).outerHeight())/2)+"px");

		}

		$("#box"+x).css('left',($("#obg"+x).outerWidth() - $("#box"+x).outerWidth())/2+'px');
		if($("#box"+x+" form").length>0){
			var form = $("#box"+x+" form");
			$.getScript("/cgi-bin/scripts/jquery.validate.min.js", function(){
				setTimeout(function(){
					//Carlos... check this stuff
					$(form).validate({
						success: function(label) { label.addClass("valid").text("OK");},
						submitHandler: function() { 
							$("#box"+x).fadeOut(500, function(){
								$.post($(form).attr("action"), form.serialize(), function(xml) {
									$("#box"+x+" .boxbody").html(xml);
									$("#box"+x+" .boxbody #nav, #box"+x+" .boxbody #global_wrapper, #box"+x+" .boxbody .foot").remove();
									$("#box"+x+" .boxbody input").click(function(){exitbox();});
									sizebox();
								});	
							});
						}
					});
				}, 351);
			});
		}
		
		
		$("#box"+x).fadeIn(500).show(function(){$(".remove").remove();});
		if ($("#box"+x+" .boxbody").hasClass("img")){
			$("#box"+x+" .boxhead").width($("#box"+x+" .boxbody img").width()-20);
		}
		$("#box"+x).css('left',($("#obg"+x).outerWidth() - $("#box"+x).outerWidth())/2+'px');
		//alert($("#box"+x+" .boxbody").width()+"px");
		$("#box"+x+" .boxhead img").click(function(){exitbox();});
		$("#box"+x+" .boxbody a[rel^='box']").each( function (){initbox(this);});
		if (x<box_follow){$("#box"+x+" .boxbody a").each( function (){initbox(this);});}
	}
	
	function exitbox() {
		i=$(".obg").length-1; $("#obg"+i).fadeOut(500, function(){$("#obg"+i).remove();}); $("#box"+i).fadeOut(500, function(){$("#box"+i).remove();$("object").css({visibility:"visible"});});
	}
//Load spinner to indicate working browser
	function showSpinner(){
		$("body").append('<div class="obg"></div>');
	}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//END FUNCTIONS
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


$(function(){
//TOP OF PAGE NAVIGATION
	$(window).scroll( function(){ handlescroll();}); 
//SAME PAGE ANCHORS
	$("a[href^='#']").click(function(){fade($(this).attr("href").substring($(this).attr("href").indexOf("#"))); });
//PDF links
	$("a[href*='.pdf']").each( function(){ handlePDF(this);});
//EXTERNAL links
	$("a[href^='http']").each( function(){ handleEXT(this);});
//AS400 REDIRECT links
	$("a[href$='https://as400sec.pct.edu/Apply/']").each( function(){ $(this).attr("href","/cgi-bin/as400redirect/apply.htm");});
	$("a[href='https://emt.askadmissions.net/pct/emtinterestpage.aspx?ip=freshman']").each( function(){ $(this).attr("href","/cgi-bin/as400redirect/requestInfo.htm");});
//IMAGE & OPTION title tooltips
	$("#content img:not([title])").each(function(){$(this).attr("title",$(this).attr("alt"));});
	$("option").each(function(){$(this).attr("title",$(this).text());});
//SEARCH Spinner
	//$("input[type='image']").click(function(){showSpinner();});
//NAV Collapse
	$("ul#nav a.hide, ul#nav a.show").each( function(i){
		id =(location.href.split("/")[3])+"_nav_ul_"+i; 
		$(this).attr("id",id);//name the anchor
		if($.cookie(id)=="hide"){$(this).addClass("hide").removeClass("show");} 
		else if($.cookie(id)=="show"){$(this).addClass("show").removeClass("hide");} 
		$.cookie(id,this.className,{path:"/"});
	});
	$("ul#nav a.hide").each(function(i){$(this).siblings("ul").hide();});
	$("ul#nav a.show").each(function(i){$(this).siblings("ul").show();});
	$("ul#nav a.hide, ul#nav a.show").click(function(){$(this).siblings("ul").slideToggle(500); $(this).toggleClass("hide").toggleClass("show"); $.cookie(this.id, this.className,{path:"/"});});
// STAFF PAGE HEADING -pwarner 10MAR09
// looks for div.bio in #content and if it finds one it builds a 'pagenav' ul at the top of the document. If there is more than 20 staff members, the list splits into two columns. NOTE: The fade animation is an anonymous function here, it should be a defined function.
	if($('#content div').hasClass('bio')){
		
		if ($('.bio').length>19){
			$(".bio:first").before("<div class='f50'><ul id='pagenav' class='plain'></ul></div><div class='f50'><ul id='pagenav2' class='plain'></ul></div>");
		}else{
			$(".bio:first").before("<ul id='pagenav' class='plain'></ul>");
		}
		$(".bio").each(function(i){
			$(this).attr("id","bio"+i);
			var s = Math.round($('.bio').length/2)-1;
			if (s>=9){
				if(i<=s){
				$("#pagenav").append("<li><a href='#bio"+i+"'>"+$('h3',this).html()+"</a><br /><span class='smaller'>"+$('h5',this).html()+"</span></li>");}
				else if (i>s){
				$("#pagenav2").append("<li><a href='#bio"+i+"'>"+$('h3',this).html()+"</a><br /><span class='smaller'>"+$('h5',this).html()+"</span></li>");}
			}
			else{
				$("#pagenav").append("<li><a href='#bio"+i+"'>"+$('h3',this).html()+"</a><br /><span class='smaller'>"+$('h5',this).html()+"</span></li>");
			}
		});
		
		$("#pagenav a,#pagenav2 a").click(function(){fade($(this).attr("href").substring($(this).attr("href").indexOf("#")));});
		//alert(location.href.indexOf('#bio'));
		//if (location.href.indexOf('#bio')>0){ alert(location.href.substring(location.href.indexOf('#bio')));
									          // $(location.href.substring(location.href.indexOf('#bio'))).click();}
	}
// FAQ PAGE HEADING -pwarner 25FEB09
// Looks for div.q in #content and if it finds it it builds a faq heading. Basically the same as STAFF PAGE HEADING but with an ol and only one line.
	if($('#content div').hasClass('q')){
		$(".q:first").before("<div id='pagenav'><ol></ol></div>");
		var hasH4 = false;
		$(".q").each(function(i){
			if($(this).text()){
				$(this).attr("id","q"+i);
				if ($("h4",this).length > 0) {
					hasH4 = true;
					$("#pagenav").append("<h5>" + $("h4",this).text() + "</h5><ol></ol>");
				}
				$("#pagenav ol:last").append("<li value='" + parseInt(i+1, 10) + "'><a href='#q"+i+"'>"+$('h5',this).html()+"</a></li>");
			}
		});
		$("#pagenav ol:empty").remove();
		if (hasH4) {
			$(".q h5").css({"padding-left":45+"px"});
			$(".q p").css({paddingLeft:65+"px"});
			$(".q ul").css({paddingLeft:80+"px"});
			$("#pagenav ol").css({"padding-bottom":0.5+"em"});
			$("#pagenav ol:last").css({"padding-bottom":1.8+"em"});
		}
		$("#pagenav a").click(function(){fade($(this).attr("href").substring($(this).attr("href").indexOf("#")));});
	}
//URL FADE
	fade(location.href.substring(location.href.indexOf('#')));
// GOOGLE ANALYTICS
// loads ga script from ga.js
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	$.getScript(gaJsHost + 'google-analytics.com/ga.js',function(){
		try{
			var pageTracker = _gat._getTracker("UA-3515060-1");
			pageTracker._setDomainName(".pct.edu");
			pageTracker._trackPageview();
		} catch(err) {}
	});
//FIXES IE FADES
	jQuery.fn.fadeIn = function(speed, callback) { 
		return this.animate({opacity: 'show'}, speed, function() { 
			if (jQuery.browser.msie) {this.style.removeAttribute('filter');}  
			if (jQuery.isFunction(callback)) {callback();}  
		}); 
	}; 
	 
	jQuery.fn.fadeOut = function(speed, callback) { 
		return this.animate({opacity: 'hide'}, speed, function() { 
			if (jQuery.browser.msie) {this.style.removeAttribute('filter');}  
			if (jQuery.isFunction(callback)) {callback();}  
		}); 
	}; 
	 
	jQuery.fn.fadeTo = function(speed,to,callback) { 
		return this.animate({opacity: to}, speed, function() { 
			if (to == 1 && jQuery.browser.msie) {this.style.removeAttribute('filter');}  
			if (jQuery.isFunction(callback)) {callback();}
		}); 
	}; 

// LOADS VALIDATION SCRIPT
	if($("#content form").length>0){// do not validate PCToday search
		$.getScript("/cgi-bin/scripts/jquery.validate.min.js", function(){
			setTimeout(function(){
				//Custom validation for phone number
				$.validator.addMethod("phoneUS", function(phone_number, element) {
					phone_number = phone_number.replace(/\s+/g, ""); 
					return this.optional(element) || phone_number.length > 9 &&	phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
					}, "Please specify a valid phone number.");
				//Custom Validation for the dining/cookiedough form to ensure ordering an even dozen
				$.validator.addMethod("evendozen", function(value, element) {
					return this.optional(element) || ((parseFloat(value)/12) % 1 === 0);
					}, "Amount must total an even dozen.");
				//Custom validation to compare for inequality
				$.validator.addMethod("notequalTo", function(value, element, param) {
					return $(param).val() == "" || value != $(param).val();
					}, "Please specify different value.");
			},351);
		});
	}
	
// ALTERNATE TABLE ROW BACKGROUND FOR SPECIFIED TABLES 
	$("table:not([class*=sortable]).zebra tbody tr:odd").addClass('alt');

// LOADS TABLE SORTER SCRIPT
	if ($("table.sortable").length>0) {$.getScript("/cgi-bin/scripts/jquery.tablesorter.min.js", function(){
		setTimeout(function(){$(".sortable").tablesorter({widgets: ['zebra']});},351);
	});}

// ADD THIS - disabled for IE7 users on 10/20/09 due to problem with automatic reload of each page in IE7 with a hash added to URL
// also disabled for Firefox 2.0 and Safari 3 on 10/30/09
// fix from AddThis expected 11/3/09
	if(!(($.browser.msie && $.browser.version <= 7) || ($.browser.mozilla && $.browser.version < "1.9") || ($.browser.safari && $.browser.version < "528"))) {
		var addThisLoc = "http://s7.addthis.com/js/250/addthis_widget.js?pub=pctwebdev";
		if (window.location.href.indexOf("https://")>=0) {addThisLoc = "https://secure.addthis.com/js/250/addthis_widget.js?pub=pctwebdev";}
		$.getScript(addThisLoc, function(){
			$(".foot").append('<p><a id="addthis" class="addthis">Share</a></p>');
			addthis.button("#addthis",{services_compact:"email,facebook,favorites,digg,google,delicious,more",data_track_linkbacks:"true"});
		});
	}
// LOADS WEBTRENDS SDC SCRIPT
	$.getScript("/cgi-bin/scripts/WT.js");

//BOX
//Binds element(s) to click event(s)
	$("a[rel^='box'], .boxgallery a").each( function (){initbox(this);});
//Resizes box when window resized
	$(window).resize(function(){if ($(".boxwrapper").length>0){sizebox();}});
});

// COOKIES from Plugins/Cookie
// Author Klaus Hartl/klaus.hartl@stilbuero.de
/*  $.cookie('the_cookie', 'the_value'); Set the value of a cookie.
 *  $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true }); Create a cookie with all available options.
 *  $.cookie('the_cookie'); Gets the value of a cookie.*/	
jQuery.cookie = function(name, value, options) {

	if (typeof value != 'undefined') { // name and value given, set cookie
		options = options || {};
		if (value === null) {
			value = '';
			options = $.extend({}, options); // clone object since it's unexpected behavior if the expired property were changed
			options.expires = -1;
		}
		var expires = '';
		if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
			var date;
			if (typeof options.expires == 'number') {
				date = new Date();
				date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
			} else {
				date = options.expires;
			}
			expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
			}
			// NOTE Needed to parenthesize options.path and options.domain
			// in the following expressions, otherwise they evaluate to undefined
			// in the packed version for some reason...
			var path = options.path ? '; path=' + (options.path) : '';
			var domain = options.domain ? '; domain=' + (options.domain) : '';
			var secure = options.secure ? '; secure' : '';
			document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
		} else { // only name given, get cookie
			var cookieValue = null;
			if (document.cookie && document.cookie != '') {
			var cookies = document.cookie.split(';');
			for (var i = 0; i < cookies.length; i++) {
				var cookie = jQuery.trim(cookies[i]);
				// Does this cookie string begin with the name we want?
				if (cookie.substring(0, name.length + 1) == (name + '=')) {
					cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
					break;
				}
			}
		}
		return cookieValue;
	}
};
