var _CatalogNbr = '/639/';

function setCookie(c_name,value,expiredays){
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+
    ((expiredays==null) ? "" : ";path=/;expires="+exdate.toGMTString());
};


function ReadCookie(cookieName) {
       var theCookie = "" + document.cookie;
       var ind = theCookie.indexOf(cookieName);
       if (ind == -1 || cookieName == "") return "";
       var ind1 = theCookie.indexOf(';', ind);
       if (ind1 == -1) ind1 = theCookie.length;
       return unescape(theCookie.substring(ind + cookieName.length + 1, ind1));
};
 
function DeleteCookie(name) {
	document.cookie = name + '=;path=/; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}
 
//function rewriteCatalogLinks()
//{
//    $("a[href*=" + _CatalogNbr + "]").attr('href', function() {
//        return '../catalog/' + splitCatalogPageNbr($(this).attr('href').toLowerCase());
//    }).attr("target", "_self").attr("class", "digital").parents("td").find("#ctl00_ContentMain_imgPDF").remove(); 
//}

function splitCatalogPageNbr(str)
{
	var splitUrl = str.split("/")
	var lastSplit = "";
	var pageNbr = ""

	for(i = 0; i < splitUrl.length; i++){
		if('/' + lastSplit + '/' == _CatalogNbr)
		{
			pageNbr = splitUrl[i].replace('.pdf','');
		}
		lastSplit = splitUrl[i];
	}
	return pageNbr;
}

$(document).ready(function() {
    var pref = ReadCookie('preferDigitalCatalog')
    $(document).pngFix();

//    if (pref == 1) {
//        rewriteCatalogLinks();
//    }
    
});