
function writeLink(strClass, strTitle, strLinkText, strHref, strIdxURL, strNewWindow, strViewMode, strEmail) {
	// requires replaceString function
	
	var strURL		= ""
	var strDisplay	= ""
	var strTarget	= ""
	var strQuery	= ""

	// Query
	strQuery = ((strViewMode != "" && strIdxURL == ""))  ? "?ViewMode=" + strViewMode : "";
	// URL
	strURL = (strIdxURL != "") ? strIdxURL : strHref;
	strURL = replaceString(strURL,'/eprise/main/ABWslr','');	//eliminate eprise inconsitent mapping
	// New Window
	strTarget = (strNewWindow == "Yes") ? "_blank" : "";
	// Display
	if (strLinkText != "") { strDisplay = strLinkText; }
	else { strDisplay = (strTitle != "") ? strTitle : "New Page"; }
	// Output
	if (strEmail != "") {document.write("<a href=\"mailto:" + strEmail + "?subject=I have a comment about your website!\" class=\"" + strClass + "\">" + strDisplay + "</a>");	}
	else { document.write("<a href=\"" + strURL + strQuery + "\" class=\"" + strClass + "\" target=\"" + strTarget + "\">" + strDisplay + "</a>");	}
}

function openAdminWin(strPath,strName){
    
	var oldWindow, newWindow

	// find browser capabilities
	var ns = (document.layers) ? 1:0;
	var ie = (document.all) ? 1:0;
	
	if(ie){
		newWindow=window.open(strName,strPath,'width=1024,height=768,left=0,top=0,status=yes,menu=no,location=no,toolbar=no,resizable=yes,scrollbars=no');
	}
	if(ns){
		newWindow=window.open(strName,strPath,'width=1024,height=768,left=0,top=0,status=yes,menu=no,location=no,toolbar=no,resizable=yes,scrollbars=no');
	}
	if (newWindow.opener==null) newWindow.opener = top;
	newWindow.focus();
	return false;
}

function replaceString(string,text,by) {

	// if string or text is blank, return string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

	// if text not found in string, return string
    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

	// Recursively replace text with by in string
    var newstr = string.substring(0,i) + by;
    if ((i+txtLength) < strLength) {
        newstr += replaceString(string.substring(i+txtLength,strLength),text,by);
	}
    return newstr;
}

function winopen(targeturl,intwidth,intheight){
                newwin=window.open(targeturl,"","width=" + intwidth + ",height=" + intheight + 'resizable=yes,scrollbars=no');
}


// write page header 
function writePageHeader(strTitle){
	writePageHeaderByImage(strTitle, "")
	return;
}

// write page header based on category
function writePageHeaderByCategory(strTitle, strCategory) {
	var strImg = ""
	var strImgFolder = "/images/content/"
	
	// select image based on category
	switch (strCategory) { 
	   case "Events and Promotions" : 
	      strImg = strImgFolder + "pageHeaderEventsPromotions.jpg"; 
	      break; 
	   case "Products" : 
	      strImg = strImgFolder + "pageHeaderProducts.jpg"; 
	      break; 
	   case "Consumer Services" : 
	      strImg = strImgFolder + "pageHeaderConsumerServices.jpg"; 
	      break; 
	   case "About Us" : 
	      strImg = strImgFolder + "pageHeaderAboutUs.jpg"; 
	      break; 
	   case "Retailer Services" : 
	      strImg = strImgFolder + "pageHeaderRetailerServices.jpg"; 
	      break; 
	   case "Feedback" : 
	      strImg = strImgFolder + "pageHeaderFeedback.jpg"; 
	      break; 
	   default : 
	      strImg = ""; 
	} 
	
	// write header
	writePageHeaderByImage(strTitle, strImg);
	return;
}

// write page header using title and image
function writePageHeaderByImage(strTitle, strImage){

	strImage = new String(strImage);
	
	if (strImage.length == 0)
		strImage = "/images/content/pageHeaderDefault.jpg";
	
	document.write(
		'<table border="0" cellpadding="0" cellspacing="0" width="100%" id="pageheader">' +
		'<tr>' +
		'	<td class="title">' + strTitle + '&nbsp;</td>' +
		'	<td rowspan="2" width="292"><img src="' + strImage + '" width="292" height="60"></td>' +
		'</tr>' +
		'<tr><td height="36"><img src="/images/spacer.gif" width="1" height="36"></td></tr>' +
		'</table>'
	);
}