var url = window.location.href;
var currentPage=0;

var date = new Date();

var day = date.getUTCDate();
var month = date.getUTCMonth();
var year = date.getUTCFullYear();
var hour = date.getUTCHours();
var minutes = date.getUTCMinutes();

date = new Date(year, month, day, hour, minutes);

date.setHours(date.getHours() - 5);

day = date.getDate();
var yesterday = date.getDate()-1;
month = date.getMonth()+1;
year = date.getFullYear();
hour = date.getHours();
minutes = date.getMinutes();
var yesterdaysDate = month +"/"+ yesterday +"/"+ year;

if (month < 10) { month = "0" + month; }
if (day < 10) { day = "0" + day; }

var fullDate = String(year+''+month+''+day); // ex(20110210)
	fullDate = parseInt(fullDate);


/***** jQuery extend functions *****/
// check for attribute existance 
$.fn.hasAttr = function(name) {  
   return this.attr(name) !== undefined && this.attr(name) !== false;
};


/***** This gives greater CSS control when JS is either enabled or disabled *****/
$('html').addClass('js');


/***** global jQuery start *****/
$(document).ready(function() {
	
	// External Website notice pop-up
	$('#VC-siteWideHeaderRight a, a[rel="external"]').leaveNotice();

	// Share class selection
	$('#shareClassSelection').change(function() {
		var toShow = "."+$(this).val();
		var toShowAll = ".shareClassALL";
		var ttlrtnId = "";
		//getting the class letter
		//var classLetter = toShow.substring(toShow.length-1, toShow.length);
		
		if ( $("div[id^='FundtabContent-per_month_end_']:visible").size() > 0 ) {
			ttlrtnId = 'FundtabContent-per_quarter_end_' + toShow.replace(".shareClass", "");
		} else {
			ttlrtnId = 'FundtabContent-per_month_end_' + toShow.replace(".shareClass", "");
		}
		
		
		
		$("div[id^='FundtabContent-']").each(function(index) {
			if ($(this).hasClass(toShow) || $(this).hasClass(toShowAll)) {
				$(this).show();
			} else {
				$(this).hide();
			}
		});
		
		$(".shwHid").each(function(index) {
			if ($(this).hasClass(toShow) || $(this).hasClass(toShowAll)) {
				$(this).show();
			} else {
				$(this).hide();
			}
		});
		
		$("div[id='"+ttlrtnId+"']").hide();
		
		doubleDigitReturns();
		rhsSpaceCorrection();
	}).change();


	// Toggle quarter-end and month-end performance tables
	$('div[id^=FundtabContent-per_month_end] h3').append('<br/><span class="clickable">(View quarter-end)</span>');
	$('div[id^=FundtabContent-per_quarter_end] h3').append('<br/><span class="clickable">(View month-end)</span>').parent().hide(); 

	$("div[id^='FundtabContent-per_month_end'] .clickable").click(function(){
		totalReturnShowHide($(this));
	});
	$("div[id^='FundtabContent-per_quarter_end'] .clickable").click(function(){
		totalReturnShowHide($(this));
	});
	
	initSearchFocus();	
	
	initGlobalSiteNav();
	
	initPresentation();
	
	initPageSubtitles();
		
	initTabs();	
	
	initManagers();
		
	//if fund center = true
	if ($(".VC-tabModule").length){
		hidePieceOfBeta();
		getPortDefinitions();
		getManagerStartDate();
		toggleLipMnsrDisc();	
		getYesterdaysDate();
		tempIntnlBondShowTbls();
		initExcldCash();
		rhsSpaceCorrection();
		//fundCenterOnLoad(); // in progress
	}// end length if	
	
	getSiteWideDefinitions();
	
	initResizeFontTool();
	
	literatureSelection();
	
}); // jQuery close


/***** FUNCTIONS *****/

function tempIntnlBondShowTbls(){
	var intBondFund = $("h1:contains('Delaware International Bond Fund')").text();
	if (intBondFund){
		//$("#FundtabContent-per_quarter_end_I table").replaceWith("<p class='bold' style='text-align:center;'>Not Available</p>");
		//$("#FundtabContent-per_quarter_end_I span:first").hide();
		$("#FundtabContent-per_quarter_end_C table").replaceWith("<p class='bold' style='text-align:center;'>Not Available</p>");
		$("#FundtabContent-per_quarter_end_C span:first").hide();
		$("#FundtabContent-per_quarter_end_R table").replaceWith("<p class='bold' style='text-align:center;'>Not Available</p>");
		$("#FundtabContent-per_quarter_end_R span:first").hide();
		$("#FundtabContent-fund_dist_history_annual_I, #FundtabContent-per_quarterly_returns_nav_I, #FundtabContent-lipper_ranking_R, #FundtabContent-lipper_ranking_I, #FundtabContent-lipper_ranking_C").empty();
		$("#lipperRanking").parent().addClass("shwHid .shareClassA");
	}
} // end of tempIntnlBondShowTbls()


function initExcldCash(){
	var taxFree = $("h1:contains('Tax-Free')").text();
	var muni = $("h1:contains('Municipal')").text();
	var cashReserve = $("h1:contains('Delaware Cash Reserve')").text();
	if(taxFree||muni){
		$('#FundtabContent-fund_top_holdings_ALL h3').append('<sup>*</sup>').parent().after('<p class="disclosure"><sup">*</sup> List excludes cash and cash equivalents.</p>');
		$("#FundtabContent-fund_top_sectors_ALL h3, #FundtabContent-fund_top_countries_ALL h3").append('<sup>*</sup>').parent().after('<p class="disclosure"><sup">*</sup> List excludes cash, accruals on bonds, and cash equivalents</p>');
	}else if(cashReserve){
		
	}else{
		$('#FundtabContent-fund_top_holdings_ALL h3').append('<sup>*</sup>').parent().after('<p class="disclosure"><sup">*</sup> List excludes cash and cash equivalents.</p>');
		$("#FundtabContent-fund_top_sectors_ALL h3, #FundtabContent-fund_top_countries_ALL h3").append('<sup>*</sup>').parent().after('<p class="disclosure"><sup">*</sup> List excludes cash and cash equivalents.</p>');
	}
} // end of initExcldCash()


function initSearchFocus(){
	// Default input text for input textboxes, dissapears on focus on
	$('.VC-sitewideSearch input[type="text"]').each(function(){
	    this.value = $(this).attr('title');
	    $(this).addClass('inputDefaultText');
	    $(this).focus(function(){
	        if(this.value == $(this).attr('title')) {
	            this.value = '';
	            $(this).removeClass('inputDefaultText');
	        }
	    });
	    $(this).blur(function(){
	        if(this.value == '') {
	            this.value = $(this).attr('title');
	            $(this).addClass('inputDefaultText');
	        }
	    });
	});	
} // end of initSearchFocus()


function initGlobalSiteNav(){
	// Clear a background on hover for the global header links
	$('#VC-links li').hover(function(){
		$(this).prev().removeClass('spacer');													
	}, function(){
		$(this).prev().addClass('spacer');	
	});
	
	// Add active state to current L1 page
	$('#VC-navigation a.current').parents('li').addClass('active');
	
	// Remove breadcrumb from home pages
	if ($('#VC-navigation li:first').hasClass('active')) {
		$('#siteBreadcrumb').empty().append('&nbsp;');
	}
	
	// If no L2 dropdowns are present remove the dropdown arrow background from the anchor
	$('#VC-navigation li a:last-child').addClass('single');

	// Adding opacity transition effect to global and main navigation dropdowns
	$('#VC-navigation li ul, #VC-siteWideHeaderRight li ul').css('opacity','0');
    $("#VC-navigation li, #VC-siteWideHeaderRight li div").hover(
      function () {
	  	$(this).children('a').addClass('hover').end().children('ul').css('display','block').stop().animate({opacity: 0.95}, 400);
      }, 
      function () {
	  	$(this).children('a').removeClass('hover').end().children('ul').stop().css({'opacity':'0','display':'none'});
      }
    );
} // end of initMainNav()


function initPresentation(){
	// Round backgrounds for feature content column, still not the final fix, temporary
	$('#VC-featureColumn').prepend('<div class="featureTopRound"></div>').append('<div class="featureBottomRound"></div>');
	
	// Table zebra striping
	$('table.zebra tr:nth-child(even), div.VC-tabModule table tr:nth-child(even), table.holdbody tr:nth-child(even)').addClass('even');
	
	// Clear bottom padding and margin for the last item within each right hand stack
	$('.VC-featureColumn div').children('form:last-child, table:last-child, ul:last-child').addClass('clearBottom');
	$('.featureColumnElement:last, .elementBody .contact:last').addClass('clearBottom');
	
	// Items for hilite class go here
	$('#contactsDelaware table tr').hover(function(){
		$(this).toggleClass('hilite');													 
	});
	
	// Identify popup pages
	$('.VC-popupMain').parents('body').addClass('pagePopup');
	
	if ($(".VC-popupMain").length){
	$('table.holdbody td.hcol7:contains("US-CASH")').siblings(':first').append('<span style="font-size:180%;display:inline;">*</span>').end().parents('.holdframe').after('<p class="disclosure"><span style="font-size:180%;">*</span> Cash balance includes other assets and liabilities.</p>');
	}	
	
	// Temporary fix, look into this later
	$('div.formWrapper').next().addClass('clear');
	
	// Finding reg; mark and wrapping it with sup tags
	var regMarkContained = "<div>&reg;</div>";
	var regMark = $(regMarkContained).text();
	var findRegMark = $('h1:contains('+ regMark +')').text();
	var splitHeading = findRegMark.split(regMark);
	var updatedHeading = splitHeading[0] + '<sup>' + regMark + '</sup> ' + splitHeading[1];
	$('h1:contains('+regMark+')').replaceWith('<h1>'+ updatedHeading +'</h1>');
	
	// Right hand stack navigation identifying current page
	var currentPageTitleText = $('h1').text();
	$('#rightStackNav li a:contains(' + currentPageTitleText + ')').addClass('current bold');
} // end of initPresentation()


function initPageSubtitles(){
	// Formerly and closed to new investor text
	var fundClosedCaveat = '<h2 id="closed" class="subhead">(closed to new investors)</h2>';

	$("h1:contains('The Emerging Markets Portfolio')").not("h1:contains('The Emerging Markets Portfolio II')").after(fundClosedCaveat);
	
	$("h1:contains('Delaware Macquarie Real Estate Portfolio')").after(fundClosedCaveat);

	$("h1:contains('The International Equity Portfolio')").after(fundClosedCaveat);
	
	$("h1:contains('The Global Fixed Income Portfolio')").after(fundClosedCaveat);
	
	$("h1:contains('The International Fixed Income Portfolio')").after(fundClosedCaveat);

	$("h1:contains('Cash Reserve Series')").after(fundClosedCaveat);
	
	$("h1:contains('Cash Reserve Series')").after(fundClosedCaveat);
} // end of initPageSubtitles()


function initTabs(){
	// Tab on change effect
	jQuery('.VC-tabModule ul:first').tabs({ fxFade: true, fxSpeed: 'normal' }); 
	
	// Wrap tab navigation anchors to fix the design layout
	$('.VC-tabModule ul:first a').wrapInner('<span></span>');	
} // end of initTabs()


function hidePieceOfBeta() {
	$(".definition:contains('Beta (relative to FTSE NAREIT All Eqty w Timber)')").replaceWith("<h4 class='definition'>Beta (relative to FTSE NAREIT Equity REITs Index) <span></span></h4>"); 
} // end of hidePieceOfBeta


function getPortDefinitions(){
	// Populate from an xml file and then view and hide term definitions found within the fund center tables
	$.ajax({
		url: '/dafiles/Internet/co/delaware/global-items/portfolio-definitions.xml',
		type: 'GET',
		dataType: 'xml',
		timeout: 10000,
		success: function(data){
			$(data).find('characteristic').each(function(){
				var $char = $(this);
				var $definitionText = $char.find('definition').text();//stores the definition as it appears in the XML file
				var $definitionName = $char.find('name').text();//stores the name as it appears in the XML file
					$('h4.definition:contains(' + $definitionName + ') span:last-child').text($definitionText);
				});
			}
	  });

	$('h4.definition span').hide().before('<span class="expand inline">(view definition)</span><span class="collapse inline">(hide definition)</span>');
	$('h4.definition span.expand').click(function(){
		$(this).hide().next().show().end().siblings(':last').fadeIn();
	});
	$('h4.definition span.collapse').click(function(){
		$(this).hide().next().fadeOut().end().siblings(':first').show();
	});		
} // end of getDefinitions()


function toggleLipMnsrDisc(){
	// View and hide Lipper and Morningstar disclosure
	$('#lipperDisclosure').before('<span class="expand">(View Lipper disclosure)</span><span class="collapse">(Hide Lipper disclosure)</span>');
	
	$('#morningStarDisc').before('<span class="expand">(View Morningstar disclosure)</span><span class="collapse">(Hide Morningstar disclosure)</span>');
	
	$('#lipperRanking span.expand, #morningStarDiscWrap span.expand').click(function(){
		$(this).hide().next().show().end().siblings(':last').fadeIn();
	});
	$('#lipperRanking span.collapse, #morningStarDiscWrap span.collapse').click(function(){
		$(this).hide().next().fadeOut().end().siblings('.expand').show();
	});
	
	
	
	var $currentFund = $('h1:first').text();
	// Populate from an xml file and then view and hide fund specific morningstar disclosures
	// /dafiles/Internet/co/delaware/global-items/morningstar.xml
	$.ajax({
		url: '/dafiles/Internet/co/delaware/global-items/morningstar.xml',
		type: 'GET',
		dataType: 'xml',
		timeout: 10000,
		success: function(data){
			$(data).find('fund').each(function(){
				var $fund = $(this);
				var $fundDiscOne = $fund.find('disclosure-one').text();
				var $fundDiscTwo = $fund.find('disclosure-two').text();
				var $fundName = $fund.find('name').text();
				
				if ($currentFund.indexOf($fundName) >= 0) {
					$('#morningStarDiscWrap').prepend($fundDiscOne);
					$('#morningStarDisc').append($fundDiscTwo);		
				}

				/*if ($fundName === $currentFund){
					$('#morningStarDiscWrap').prepend($fundDiscOne);
					$('#morningStarDisc').append($fundDiscTwo);		
				}*/
			});
		}
	});
} // end of toggleLipMnsrDisc()


function  getSiteWideDefinitions(){
	// View and hide definitions with FadeIn FadeOut
	var benchmarkDefine = $('#benchmarks').children('h4');
	benchmarkDefine.after('<div style="display:none"></div>').each(function(i){
		var defineRel = $(this).attr('rel');
		$(this).next().load('/dafiles/Internet/co/delaware/global-items/definitions.html #' + defineRel);
	});
	
	benchmarkDefine.append('<span class="expand">(view)</span><span class="collapse">(hide)</span>');

	$('#benchmarks h4 span.expand').click(function(){
		$(this).hide().next().show().end().parents('h4').next().fadeIn();
	});
	$('#benchmarks h4 span.collapse').click(function(){
		$(this).hide().prev().show().end().parents('h4').next().fadeOut();
	});
	
	// View and hide definitions with ui dialog
	$('.define').each(function(i){
		var defineRel = $(this).attr('rel');
		$(this).addClass('clickable');
		$('#VC-pageBody').append('<div style="display:none" id="define'+ i +'"></div>');
		$('#define'+i).load('/dafiles/Internet/co/delaware/global-items/definitions.html #' + defineRel);
	});	 
	$('.define').click(function(){
		var defineRel = $(this).attr('rel');
		//var defineName = $(this).text();
		$('#'+defineRel).dialog( { title: 'Definition', width: 560, height: 150, modal: true } );
	});

} // end of getSiteWideDefinitions()


function initManagers(){
	var extendedBio = $('.managerBio p span');
	extendedBio.css('display','none').before(' <span class="expand">(full bio)</span>').after(' <span class="collapse">(hide)</span>');
	
		$('.managerBio span.expand').click(function(){
			$(this).hide().nextAll().fadeIn('slow');
		}); 
		$('.managerBio span.collapse').click(function(){
			$(this).prevAll().andSelf().fadeOut().prev('span.expand').show();
		});
	
	// Remove border and padding on the last manager within the list
	$('div.manager:last').addClass('clearBottom');
	
	// View and hide managers' funds managed list
	/*$('.fundsManaged h4').append(' <span class="expand">(view)</span><span class="collapse">(hide)</span>');
	$('.fundsManaged h4 span.collapse, .fundsManaged ul').hide();

		$('.fundsManaged span.expand').click(function(){
			$(this).hide().next().show().parent().next().fadeIn();
		}); 
		$('.fundsManaged span.collapse').click(function(){
			$(this).hide().prev().show().parent().next().fadeOut();
		});*/	
} // end of initManagers()


function getManagerStartDate(){
	// Add manager fund start date
	$.ajax({
		url: '/dafiles/Internet/co/delaware/global-items/managers-start-date.xml',
		type: 'GET',
		dataType: 'xml',
		timeout: 10000,
		success: function(data){
			$(data).find('manager').each(function(){
				var $manager = $(this);
				var $managerName = $manager.find('name').text();//stores the name as it appears in the XML file
				
				if (url.match("/products/vip")){
					var startDateAssign = $("#"+ $managerName +" .managerBio h3").append('<span class="startDate">Start date on the Series: </span>');		  
				} else if (url.match("/products/dpt")){ 
					var startDateAssign = $("#"+ $managerName +" .managerBio h3").append('<span class="startDate">Start date on the Portfolio: </span>');
				} else {
					var startDateAssign = $("#"+ $managerName +" .managerBio h3").append('<span class="startDate">Start date on the Fund: </span>');
				}

				$manager.find('fund').each(function(){
					var $fund = $(this);
					var $fundNameRaw = $fund.find('fundName').text();
					var $startDate = $fund.find('startDate').text();
					var fundCenterRaw = $("h1").text();
					var $fundName = $fundNameRaw.replace(/ /g,'');
					var fundCenter = fundCenterRaw.replace(/ /g,'');

						if ($fundName == fundCenter){

							startDateAssign.children(':last').append($startDate);
						}
					});
				});
			}
		});		
} // end of getManagerStartDate()


// Select asset classes on literature pages
function literatureSelection(){
	$('#literatureSelection').change(function(){
		if (this.value == 'All') {
			$("#literature").children().show();
		} else {
			$("#lit" + this.value).show().siblings().hide();
		}
		
		var curOpt = $('#' + this.id + ' option:selected').attr('title');
		$(this).prev().text(curOpt);
	}).change();
} // end of literatureSelection()


// Select drop down jump menu
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
} // end of MM_jumpMenu()


// Select between monthly and quarterly total returns under performance on fund centers
function totalReturnShowHide(clicked) {
	var toHide = clicked.parent().parent().attr('id');
	var toShow = toHide;
	if (toHide != '') {
		if (toShow.indexOf('month') >= 0) {
			toShow = toHide.replace('month', 'quarter');
			doubleDigitReturnsQrt();
		} else {
			toShow = toHide.replace('quarter', 'month');
			doubleDigitReturns();
		}
		$("div[id^='"+toHide+"']").hide();
		$("div[id^='"+toShow+"']").show();
	}
} // end of totalReturnShowHide(clicked)


/* IE6 flicker bug fix*/
(function() {
    var m = document.uniqueID && document.compatMode && !window.XMLHttpRequest && document.execCommand;
    try {
        if ( !! m) {
            m("BackgroundImageCache", false, true);
        }
    } catch(oh) {}
})();


// font resize tool
function initResizeFontTool() {
	var defaultFontSize=12.2;
	var smallFontSize=parseFloat(defaultFontSize,10)*0.8;
	var largeFontSize=parseFloat(defaultFontSize,10)*1.2;
	var smallSel = $('#VC-fontResizeTool a.smallFont');
	var defaultSel = $('#VC-fontResizeTool a.defaultFont');
	var largeSel = $('#VC-fontResizeTool a.largeFont');
	
	//$(".VC-fontResizeTool").css("display","block");
	defaultSel.click(function(){
		resizeFontsFunction(defaultFontSize);
		$.cookie("VCFontResizerSelection",""+defaultFontSize,{path:'/co/delaware',expires:7});
		return false;
	});
	largeSel.click(function(){
		resizeFontsFunction(largeFontSize);
		$.cookie("VCFontResizerSelection",""+largeFontSize,{path:'/co/delaware',expires:7});
		return false;
	});
	smallSel.click(function(){
		resizeFontsFunction(smallFontSize);
		$.cookie("VCFontResizerSelection",""+smallFontSize,{path:'/co/delaware',expires:7});
		return false;
	});
	var currentVCFontSize=$.cookie("VCFontResizerSelection");
	if(currentVCFontSize){
		resizeFontsFunction(parseFloat(currentVCFontSize));
	}
	
	function resizeFontsFunction(fontDimension) {
		$('#VC-mainContent').css('font-size',fontDimension);
		var propTar = 'background-position';
		
		if (fontDimension==smallFontSize) {
			smallSel.css(propTar,'0px -23px');
			defaultSel.css(propTar,'-18px 0px');
			largeSel.css(propTar,'-36px 0px');
		}else if (fontDimension==defaultFontSize) {
			smallSel.css(propTar,'0px 0px');
			defaultSel.css(propTar,'-18px -23px');
			largeSel.css(propTar,'-36px 0px');
		}else if (fontDimension==largeFontSize) {
			smallSel.css(propTar,'0px 0px');
			defaultSel.css(propTar,'-18px 0px');
			largeSel.css(propTar,'-36px -23px');
		}
	} // end of resizeFontsFunction(fontDimension) 	
	
} // end of initResizeFontTool()


function getYesterdaysDate() {
	$("#sevDayYield td.bold").replaceWith("<td class='bold'>As of "+ yesterdaysDate +"</td>"); 
} // end of yesterdaysDate() 


function doubleDigitReturns(){
	//hiding the double digit returns disclosure for any percentage that is less then 20%
	$("div[id^='FundtabContent-per_month_end_'] td.center").each( function(){
		
		var ytdValueMonth = $(this).text();
		var ytdValueMonthNumb = ytdValueMonth.substring(0, ytdValueMonth.length-1);
		
		if(ytdValueMonthNumb.indexOf("/") != -1){
			
		}else{
				if(ytdValueMonthNumb < 20){
					$("#highReturns").hide();
				}else{
					$("#highReturns").show();
					return false;
				}
		}
	});
} // end of doubleDigitReturns 


function doubleDigitReturnsQrt(){
	//hiding the double digit returns disclosure for any percentage that is less then 20%
	$("div[id^='FundtabContent-per_quarter_end_'] td.center").each( function(){
		
		var ytdValueQrt = $(this).text();
		var ytdValueQrtNumb = ytdValueQrt.substring(0, ytdValueQrt.length-1);
		
		if(ytdValueQrtNumb.indexOf("/") != -1){
			
		}else{
				if(ytdValueQrtNumb < 20){
					$("#highReturns").hide();
				}else{
					$("#highReturns").show();
					return false;
				}
		}
	});
} // end of doubleDigitReturnsQrt 


function rhsSpaceCorrection(){
	var rhs = $('.featureColumnElement');
	rhs.each(function(){
		var rhsThis = $(this);
		if (rhsThis.children(':visible').length == 0){
			rhsThis.addClass('clearBottom');
		} else {
			rhsThis.removeClass('clearBottom');	
		}
	});
} // end of rhsSpaceCorrection()


function fundCenterOnLoad(){
	var rhs = $('.VC-featureColumn .featureColumnElement');
	rhs.hide();
	$('#assetSelection').after('<div id="loading-fund-center"/>');
	
	// Created by: Simon Willison | http://simon.incutio.com/
	function addLoadEvent(func) {
	  var oldonload = window.onload;
	  if (typeof window.onload != 'function') {
		window.onload = func;
	  } else {
		window.onload = function() {
		  if (oldonload) {
			oldonload();
		  }
		  func();
		}
	  }
	}
	addLoadEvent(function() {		  
		$('#loading-fund-center').fadeOut(1000);				  
		$('.VC-tabModule').fadeIn(1000);
		rhs.fadeIn(1000);
	});
} // end of fundCenterOnLoad


// cookies
jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';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();}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{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]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}return cookieValue;}};

/************************************************************************
Cross-Browser Split 1.0.1
(c) Steven Levithan <stevenlevithan.com>; MIT License
An ECMA-compliant, uniform cross-browser split method
*************************************************************************/

var cbSplit;

// avoid running twice, which would break `cbSplit._nativeSplit`'s reference to the native `split`
if (!cbSplit) {

cbSplit = function (str, separator, limit) {
    // if `separator` is not a regex, use the native `split`
    if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
        return cbSplit._nativeSplit.call(str, separator, limit);
    }

    var output = [],
        lastLastIndex = 0,
        flags = (separator.ignoreCase ? "i" : "") +
                (separator.multiline  ? "m" : "") +
                (separator.sticky     ? "y" : ""),
        separator = RegExp(separator.source, flags + "g"), // make `global` and avoid `lastIndex` issues by working with a copy
        separator2, match, lastIndex, lastLength;

    str = str + ""; // type conversion
    if (!cbSplit._compliantExecNpcg) {
        separator2 = RegExp("^" + separator.source + "$(?!\\s)", flags); // doesn't need /g or /y, but they don't hurt
    }

    /* behavior for `limit`: if it's...
    - `undefined`: no limit.
    - `NaN` or zero: return an empty array.
    - a positive number: use `Math.floor(limit)`.
    - a negative number: no limit.
    - other: type-convert, then use the above rules. */
    if (limit === undefined || +limit < 0) {
        limit = Infinity;
    } else {
        limit = Math.floor(+limit);
        if (!limit) {
            return [];
        }
    }

    while (match = separator.exec(str)) {
        lastIndex = match.index + match[0].length; // `separator.lastIndex` is not reliable cross-browser

        if (lastIndex > lastLastIndex) {
            output.push(str.slice(lastLastIndex, match.index));

            // fix browsers whose `exec` methods don't consistently return `undefined` for nonparticipating capturing groups
            if (!cbSplit._compliantExecNpcg && match.length > 1) {
                match[0].replace(separator2, function () {
                    for (var i = 1; i < arguments.length - 2; i++) {
                        if (arguments[i] === undefined) {
                            match[i] = undefined;
                        }
                    }
                });
            }

            if (match.length > 1 && match.index < str.length) {
                Array.prototype.push.apply(output, match.slice(1));
            }

            lastLength = match[0].length;
            lastLastIndex = lastIndex;

            if (output.length >= limit) {
                break;
            }
        }

        if (separator.lastIndex === match.index) {
            separator.lastIndex++; // avoid an infinite loop
        }
    }

    if (lastLastIndex === str.length) {
        if (lastLength || !separator.test("")) {
            output.push("");
        }
    } else {
        output.push(str.slice(lastLastIndex));
    }

    return output.length > limit ? output.slice(0, limit) : output;
};

cbSplit._compliantExecNpcg = /()??/.exec("")[1] === undefined; // NPCG: nonparticipating capturing group
cbSplit._nativeSplit = String.prototype.split;

} // end `if (!cbSplit)`

// for convenience...
String.prototype.split = function (separator, limit) {
    return cbSplit(this, separator, limit);
};

/************************************************************************
Cross-Browser Split 1.0.1
END
*************************************************************************/



