var mTIDLst=new Array();
var likeTinyIDList=new Array();
var cartTinyIDList=new Array();
var iSrc=new Array();
var iWdh=new Array();
var iHgt=new Array();
var iOri=new Array();
var iPhotoId=new Array();
var iHpair=new Array();
var iPad=new Array();
var iAsp=new Array();
var iSTitle=new Array();
var iLoc=new Array();
var iSize=new Array();
var iPSize=new Array();
var iOrderOK=new Array();
var iURL=new Array();
var iTPrefix=new Array();
var iLURL=new Array();
var imageHorizThumbPosition=new Array();
var iIndex = 0;
function localRenderImage (tinyid,divName,contentsDiv) {
var divStyle = 'padding: 1px; ';
var imageSrcFile = localGetImagePath(iSrc[tinyid],"std","");
var imageString = '<img class="border1" style="margin: 0px 0px 0px 4px;" src="'
+ imageSrcFile + '"' 
+ ' width="' + iWdh[tinyid] + '" '
+ ' height="' + iHgt[tinyid] + '" '
+ ' alt="">';
var imageDiv =   '<div class="border1" id="' + divName + '"' + 'style="' + divStyle + '">'
+ imageString
+ '<br>'
+ '</div>'
+ '<p>Photoid: <b>' + iPhotoId[tinyid] + '</b></p>';
document.getElementById(contentsDiv).innerHTML = imageDiv;
}
function localInitImages () {
updateLikeViewBlock();
displayLikelistBlock();
if (!(typeof thumbsBufferTitle == "undefined")) {
localRenderThumbnails("thumbnailsCenterBottomDiv","columndesc",thumbsBufferTitle);
}
var removeX = '<img border=0 src="/photoimagefiles/graphics/redex2a.png">';
var closeThis = '<p class="submenulink" style="font-size: 8pt;"><a href="javascript:localCloseThumbnailsTop();">' + removeX + '</a></p>';
document.getElementById("scrollThumbsClose").innerHTML = closeThis;
localRenderThumbnails('scrollThumbsDiv',"float");
var xPos = 10;
for (var i in mTIDLst) {
var tinyid = mTIDLst[i];
var width = localGetThumbWidth(tinyid);
imageHorizThumbPosition[tinyid] = xPos;
xPos += width + 3;
}
updateLikeIcon (mTIDLst[mainImageIndex]);
}
function displayLikelistBlock () {
document.getElementById("likelistdiv").style.display == "block";
}
function localViewgetImgStyleInfo (minWidth,widthStd,heightStd,orientation) {
var padding = (minWidth - widthStd) / 2;
var marginLeft = 0;
if (orientation.match(/v/)) {
var maxHeight = 480;
if (heightStd > maxHeight) {
widthStd = widthStd * (maxHeight/heightStd);
heightStd = maxHeight;
}
}
if (padding < 0) {padding = 0;}
if (widthStd > minWidth) {
heightStd = heightStd * (minWidth/widthStd);
widthStd = minWidth;
}
return {padding:padding,marginLeft:marginLeft,widthStd:widthStd,heightStd:heightStd};
}
function localSetBrowserWindowSize (globalMaxMainImageWidth) {
var globalConstantMinWidth = 450;
var centerDivWidth = 80 + globalMaxMainImageWidth;
var thumbnails2DivWidth = centerDivWidth - 50;
var centerDivContainerWidth = centerDivWidth + 20;
var descriptionDivWidth = centerDivWidth  + 190 + 185;
var underMenuPadding = (globalMaxMainImageWidth - 432)/2;
var underMenudivWidth = centerDivWidth - 75;
document.getElementById("underMenuDiv").style.width = underMenudivWidth + "px";
document.getElementById("underPhotoInfoDiv").style.width = underMenudivWidth + "px";
document.getElementById("descriptionDiv").style.width = descriptionDivWidth + "px";
document.getElementById("table1Center").style.width =  centerDivContainerWidth + "px";
document.getElementById("mainphotoDiv").style.width = centerDivWidth + "px";
document.getElementById("thumbsdiv2").style.width = thumbnails2DivWidth + "px";
document.getElementById("AuxInfoDiv").style.width = globalMaxMainImageWidth + "px";
var underPhotoHalfDivWidth = globalMaxMainImageWidth / 2;
}
function localRenderMainImage (tinyid,contentsDiv,descriptionDiv,underMenuDiv,color) {
document.getElementById("photoAuxImageDiv").style.display = "none";
var imageSrcFile = localGetImagePath(iSrc[tinyid],"std",color);
var windowWidth = getWindowWidth();
document.getElementById("mainDescription").style.fontSize = '18' + "px";
if (windowWidth < 1100) {
globalMaxMainImageWidth = 450;
if (iSTitle[tinyid].length > 60) {
document.getElementById("mainDescription").style.fontSize = '14' + "px";
}
if (iSTitle[tinyid].length > 70) {
document.getElementById("mainDescription").style.fontSize = '12' + "px";
}
}
localSetBrowserWindowSize(globalMaxMainImageWidth);
var imgStyle = localViewgetImgStyleInfo(globalMaxMainImageWidth,iWdh[tinyid],iHgt[tinyid],iOri[tinyid]);
document.getElementById(contentsDiv).style.marginLeft = imgStyle.marginLeft;
var thisImageWidth = imgStyle.widthStd;
var thisImageHeight = imgStyle.heightStd;
var thisImagePadding = imgStyle.padding;
var imageString = '<img style="margin: 0px 0px 0px 0px;" src="'
+ imageSrcFile + '"' 
+ ' width="' + thisImageWidth + '" '
+ ' height="' + thisImageHeight + '" '
+ ' alt="' + iSTitle[tinyid] + '">';
document.getElementById(contentsDiv).innerHTML = imageString;
var desc = iSTitle[tinyid];
if (desc == '') {desc = '&nbsp;';}
document.getElementById(descriptionDiv).innerHTML = desc;
var paddingtb = thisImagePadding;
var paddinglr = thisImagePadding;
if ((iOri[tinyid] == 'v') && (paddingtb > 10)) {paddingtb = 10;}
document.getElementById(contentsDiv).style.padding = paddingtb + "px " + paddinglr + "px " + paddingtb + "px " + paddinglr + "px ";
localShowUndermenu(tinyid,underMenuDiv);
localShowSummaryDetails(tinyid,'summarydetailsdiv');
localShowUnderPhotoInfo(tinyid,'PhotoIDDiv');
var isRandom = document.getElementById("countcontrolform");
if ((! LegacyBrowser)&& (isRandom == null)) {
localUpdateShareLink(tinyid);
}
updateLikeIcon (tinyid);
localCloseAuxInfoDiv();
startThumbsMinimized = 0;
}
function localUpdateShareLink (tinyid) {
var pageurl;
if (iURL[tinyid] != '') {
pageurl = "/" + localGetPageUrl(tinyid);
}
ADDTHISURL = pageurl;
ADDTHISTITLE = iTPrefix[tinyid] + iSTitle[tinyid] + " (Photo, RobsProPhoto.com)";
document.getElementById('myaddthistop').onmouseover = function(){return addthis_open(this, '',ADDTHISURL, ADDTHISTITLE);}
document.getElementById('myaddthistop').href = "http://www.addthis.com/bookmark.php?v=250&amp;pub=portlandbridges&url=" + ADDTHISURL + "&title=" + ADDTHISTITLE;
document.getElementById('myaddthistop').onclick = function() { return true; };
document.getElementById('myaddthistop').target = '_BLANK';
document.getElementById('myaddthisfb').href = "http://www.addthis.com/bookmark.php?v=250&s=facebook&amp;pub=portlandbridges&url=" + ADDTHISURL + "&title=" + ADDTHISTITLE;
document.getElementById('myaddthisfb').onclick = function() { return true; };
document.getElementById('myaddthisfb').target = '_BLANK';
document.getElementById('myaddthisgo').href = "http://www.addthis.com/bookmark.php?v=250&s=google&amp;pub=portlandbridges&url=" + ADDTHISURL + "&title=" + ADDTHISTITLE;
document.getElementById('myaddthisgo').onclick = function() { return true; };
document.getElementById('myaddthisgo').target = '_BLANK';
document.getElementById('myaddthistw').href = "http://www.addthis.com/bookmark.php?v=250&s=twitter&amp;pub=portlandbridges&url=" + ADDTHISURL + "&title=" + ADDTHISTITLE;
document.getElementById('myaddthistw').onclick = function() { return true; };
document.getElementById('myaddthistw').target = '_BLANK';
}
function localGetPageUrl(tinyid) {
var pageurl = iURL[tinyid];
if (!(iURL[tinyid].match(/.html$/))) {
pageurl = "00" + "," + iPhotoId[tinyid] + "," + iURL[tinyid] + ".html";
}
return(pageurl);
}
function localShowUnderPhotoInfo (tinyid,targetdiv) {
var underphotoinfo  =  "PhotoID: <b>_PHOTOID_</b> ";
underphotoinfo = underphotoinfo.replace(/_PHOTOID_/g,iPhotoId[tinyid]);
document.getElementById(targetdiv).innerHTML = underphotoinfo;
}
function localShowSummaryDetails (tinyid,targetdiv) {
var summarydetails  =  "<p style=\"margin-bottom: 0; font-size: 12pt; font-weight: bold;\">More information about this image:</p> <table width=\"100%\" style=\"font-size: 10px; border: solid;\" cellpadding=5> <tr><td align=\"right\"><b>PhotoID</b></td><td style=\"color: #E00000; font-weight: bold;\">_PHOTOID_</td></tr> <tr><td align=\"right\"><b>Location:</b></td><td>_LOCATION_</td></tr> <tr><td align=\"right\"><b>High Resolution File Size:</b></td><td>_IMAGESIZE_</td></tr> <tr><td align=\"right\"><b>Available Print Sizes:</b></td><td>_PRINTSIZES_</td></tr> </table> ";
var printSizes = allPrintSizesXref[iAsp[tinyid]];
summarydetails = summarydetails.replace(/_PHOTOID_/g,iPhotoId[tinyid]);
summarydetails = summarydetails.replace(/_LOCATION_/g,iLoc[tinyid]);
summarydetails = summarydetails.replace(/_IMAGESIZE_/g,iSize[tinyid]);
summarydetails = summarydetails.replace(/_PRINTSIZES_/g,printSizes);
document.getElementById(targetdiv).innerHTML = summarydetails;
}
function localRotateMainImage(delta) {
mainImageIndex = mainImageIndex + delta;
var browseupdown = "forward";
if (delta < 0) {browseupdown = "back";}
if (mainImageIndex >= iIndex) {mainImageIndex = 0;}
if (mainImageIndex < 0) {mainImageIndex = iIndex - 1;}
localRenderMainImage(mTIDLst[mainImageIndex],"mainImageDiv","mainDescription","underMenuDiv",mainColorView);
updatePingFrame("browse:" + browseupdown,iPhotoId[mTIDLst[mainImageIndex]],"");
localPauseRandomPhoto();
}
function UMI (index) {
localUpdateMainImage(index,mainColorView,'');
}
function UMIt (index) {
localUpdateMainImage(index,mainColorView,'newimagetop');
}
function UMIns (index) {
localUpdateMainImage(index,mainColorView,'noscroll');
}
function localUpdateImageColor (color) {
mainColorView = color;
localUpdateMainImage(mainImageIndex,mainColorView,'');
var tinyid = mTIDLst[mainImageIndex];
localShowUndermenu(tinyid,"underMenuDiv");
updateLikeIcon(tinyid);
localShowColorLink("colorlink");
}
function localUpdateMainImage(index,color,options) {
mainImageIndex = index;
localRenderMainImage(mTIDLst[mainImageIndex],"mainImageDiv","mainDescription","underMenuDiv",color);
if (!(options.match(/noscroll/))) {scroll(0,0);}
var pingtext = "newimage";
if (options.match(/newimagetop/)) {
var pingtext = "newimagetop";
}
updatePingFrame("browse:" + pingtext,iPhotoId[mTIDLst[mainImageIndex]],"");
localPauseRandomPhoto();
}
function localPauseRandomPhoto () {
var isRandom = document.getElementById("countcontrolform");
if (isRandom != null){
document.countcontrol.pause.checked = true;
}
}
function localGetThumbWidth (tinyid) {
var width = 120;
if (iOri[tinyid] == "v") {
width = 0; //temp
if (iAsp[tinyid] == "2.0") {
width = 41;
}
if (iAsp[tinyid] == "3.0") {
width = 27;
}
if (width == 0) {
width = 53;
}
}
return(width);
}
function localRenderThumbHTML (i,options) {
var tinyid = mTIDLst[i];
var UMIFunctionCall = "UMI";
var styleopt = 'float: left;';
var scaleSize = '';
if (options == 'float') {
UMIFunctionCall = "UMIt";
if (iOri[tinyid] == "v") {
var width = localGetThumbWidth(tinyid);
scaleSize = ' height="80" width="' + width + '" ';
var widthpp = width + 10;
styleopt += 'width: ' + widthpp + 'px;';
}
else {
styleopt += "width: 130px;";
if (iAsp[tinyid] == "2.0") {
styleopt += "margin-top: 10px;";
}
if (iAsp[tinyid] == "3.0") {
styleopt += "margin-top: 20px;";
}
if ((iAsp[tinyid] == "1.3")||(iAsp[tinyid] == "1.4")) {
scaleSize = ' height="80" width="120" ';
}
}
}
if (styleopt != '') {
styleopt = ' style="' + styleopt + '" ';
}
var imageThm = localGetImagePath(iSrc[tinyid],"thm","");
var thumbString = '<img class="border1" style="margin: 0px 0px 0px 4px;"' + scaleSize + ' src="'
+ imageThm 
+ '" alt="">';
var url = 'javascript:' + UMIFunctionCall + '(' + i + ');';
var thumbImgUrl = '<a href="' + url + '">' + thumbString + '</a>';
if (options == 'columndesc') {
var thumbclass = "thumbnailh";
if (iOri[tinyid] == "v") {thumbclass = "thumbnailv";}
thumbImgUrl = "<div class='" + thumbclass + "'>" + thumbImgUrl + 
"<p><a href='" + url + "'>" + iSTitle[tinyid] + "</a></p></div><br>";
}
if (options == 'float') {
thumbImgUrl = "<div " + styleopt + ">" + thumbImgUrl + 
"</div>";
}
return(thumbImgUrl);
}
function localRenderThumbHTMLWide (i,options) {
var tinyid = mTIDLst[i];
var imageThm = localGetImagePath(iSrc[tinyid],"thm","");
var thumbString = '<img class="border1" style="margin: 0px 0px 0px 4px;" src="'
+ imageThm 
+ '" alt="">';
var url = 'javascript:UMI(' + i + ');';
var thumbImgUrl = '<a href="' + url + '">' + thumbString + '</a>';
if (options == 'columndesc') {
var thumbclass = "thumbnailh";
if (iOri[tinyid] == "v") {thumbclass = "thumbnailv";}
thumbImgUrl = "<tr>" +
"<td style='text-align: right;'>" + thumbImgUrl + "</td>" +
"<td class='nounderline' style='text-align: left; vertical-align: middle; font-size: 12pt; font-family: sans-serif;'><a href='" + url + "'>" + iSTitle[tinyid] + "</a></td>" +
"</tr>";
}
return(thumbImgUrl);
}
function localRenderThumbnails (targetDiv,options,title) {
if (title == undefined) {title = '';}
var thumbsbuffer = "";
if (options == 'columndesc') {
var i = 0;
var breakindex = mainImageIndex;
for (i=(breakindex - 1) ; i < mTIDLst.length; i++) {
if ( (i >= 0) && (i != breakindex)) {
var thumbImgUrl = localRenderThumbHTMLWide(i,options);    
thumbsbuffer += thumbImgUrl;
}
}
for (i=0; i< (breakindex -1); i++) {
if (i != breakindex) {
var thumbImgUrl = localRenderThumbHTMLWide(i,options);    
thumbsbuffer += thumbImgUrl;
}
}
var thumbImgUrl = localRenderThumbHTMLWide(breakindex,options);    
thumbsbuffer += thumbImgUrl;
thumbsbuffer = "<table>" + thumbsbuffer + "</table>";
} else {
for (var i in mTIDLst) {
var thumbImgUrl = localRenderThumbHTML(i,options);    
thumbsbuffer += thumbImgUrl;
}
}
document.getElementById(targetDiv).innerHTML = title + thumbsbuffer;
}


var allPrintSizesXref = new Array();
allPrintSizesXref['3.0'] = '4x12 8x24 12x36';
allPrintSizesXref['1.5'] = '8x12 12x18 11x17 16x24 20x30 24x36';


var mainImageIndex = 0; 
var mainColorView = 'color';
var lastAuxInfoContents = "none";
var disableThumbnailAutoToggle = 0;
var startThumbsMinimized = 1;

//this may be overridden during server execution
//if a legacy browser is detected.
var LegacyBrowser = 0;

var ADDTHISURL = "http://www.portlandbridges.com/";
var ADDTHISTITLE = "Add This Title Here";



function localShowPrintPrices () {

  var infobuffer = "";

  infobuffer  +=  "<p style=\"font-size: 12pt; font-weight: bold; color: #e00;\"><u>Print Prices - as of  ";
infobuffer  +=  "11/20/2010</u> <span style=\"font-size: 10pt;\"><i>(prices subject to change)</i></span></p> ";
infobuffer  +=  "<p style=\"font-size: 11pt;\"><i> ";
infobuffer  +=  "Note: Prints must be ordered from lab for each order but most are ";
infobuffer  +=  "shipped in about a week.  Very large prints take a few days longer. ";
infobuffer  +=  "Prints can be \"rush\" processed within a few business days - extra fees ";
infobuffer  +=  "may apply.  Delivery in the Portland area within 1-2 business days is ";
infobuffer  +=  "usually possible. ";
infobuffer  +=  "</i></p> ";
infobuffer  +=  "<table style=\"\"> ";
infobuffer  +=  "<tr> ";
infobuffer  +=  "<td style=\"font-weight: bold;  border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">Print Size (inches)</td> ";
infobuffer  +=  "<td style=\"font-weight: bold; text-align: right;  border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">Price (USD)</td> ";
infobuffer  +=  "<td style=\"font-weight: bold;  border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">Info</td> ";
infobuffer  +=  "</tr> ";
infobuffer  +=  "<tr> ";
infobuffer  +=  "<td style=\" border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">8x12</td> ";
infobuffer  +=  "<td style=\"text-align: right;  border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">$20.00</td> ";
infobuffer  +=  "<td style=\" border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt; ; font-size: 11pt;\"> Unframed, print only.</td> ";
infobuffer  +=  "</tr> ";
infobuffer  +=  "<tr> ";
infobuffer  +=  "<td style=\" border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">12x18</td> ";
infobuffer  +=  "<td style=\"text-align: right;  border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">$45.00</td> ";
infobuffer  +=  "<td style=\" border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt; ; font-size: 11pt;\"> Unframed, print only.</td> ";
infobuffer  +=  "</tr> ";
infobuffer  +=  "<tr> ";
infobuffer  +=  "<td style=\" border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">11x17</td> ";
infobuffer  +=  "<td style=\"text-align: right;  border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">$50.00</td> ";
infobuffer  +=  "<td style=\" border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt; ; font-size: 11pt;\"> Unframed, print only.</td> ";
infobuffer  +=  "</tr> ";
infobuffer  +=  "<tr> ";
infobuffer  +=  "<td style=\" border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">16x24</td> ";
infobuffer  +=  "<td style=\"text-align: right;  border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">$75.00</td> ";
infobuffer  +=  "<td style=\" border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt; ; font-size: 11pt;\"> Unframed, print only.</td> ";
infobuffer  +=  "</tr> ";
infobuffer  +=  "<tr> ";
infobuffer  +=  "<td style=\" border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">20x30</td> ";
infobuffer  +=  "<td style=\"text-align: right;  border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">$75.00</td> ";
infobuffer  +=  "<td style=\" border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt; ; font-size: 11pt;\"> Unframed, print only.</td> ";
infobuffer  +=  "</tr> ";
infobuffer  +=  "<tr> ";
infobuffer  +=  "<td style=\" border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">24x36</td> ";
infobuffer  +=  "<td style=\"text-align: right;  border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">$120.00</td> ";
infobuffer  +=  "<td style=\" border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt; ; font-size: 11pt;\"> Unframed, print only.</td> ";
infobuffer  +=  "</tr> ";
infobuffer  +=  "<tr> ";
infobuffer  +=  "<td style=\" border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">4x12</td> ";
infobuffer  +=  "<td style=\"text-align: right;  border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">$20.00</td> ";
infobuffer  +=  "<td style=\" border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt; ; font-size: 11pt;\"> Unframed, print only.</td> ";
infobuffer  +=  "</tr> ";
infobuffer  +=  "<tr> ";
infobuffer  +=  "<td style=\" border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">8x24</td> ";
infobuffer  +=  "<td style=\"text-align: right;  border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">$45.00</td> ";
infobuffer  +=  "<td style=\" border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt; ; font-size: 11pt;\"> Unframed, print only.</td> ";
infobuffer  +=  "</tr> ";
infobuffer  +=  "<tr> ";
infobuffer  +=  "<td style=\" border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">12x36</td> ";
infobuffer  +=  "<td style=\"text-align: right;  border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt;\">$55.00</td> ";
infobuffer  +=  "<td style=\" border-collapse: collapse; border: 1px black solid; ";
infobuffer  +=  "  padding: 5px; font-size: 12pt; ; font-size: 11pt;\"> Unframed, print only.</td> ";
infobuffer  +=  "</tr> ";
infobuffer  +=  " ";
infobuffer  +=  "</table> ";
infobuffer  +=  "<p style=\"font-size: 10pt; color: #e00;\">* Discounts are available on ";
infobuffer  +=  "framed pictures if you order more than one.  Framing takes time and ";
infobuffer  +=  "usually adds another 7-10 business days to the delivery time.</p> ";


  localSetAuxInfo(infobuffer,"","showBottomCloseThis");
  updatePingFrame("ShowPrintPrices","","");

}


function localCloseThumbnailsTop() {
  localToggleThumbnailsLink('off',"ThumbnailsClose");
  disableThumbnailAutoToggle=1;
}

function localToggleThumbnailsLink(cmd,pingMSG) {

  //june2010: horiz scroll, redo

  disableThumbnailAutoToggle = 0;

  if (pingMSG != '') {
    updatePingFrame(pingMSG + ":" + cmd,"","");
  }

  var mydiv = document.getElementById("scrollThumbsDivOuter");
  if (cmd == "off") {
    //toggle off only
    if ( mydiv.style.display == "none" ) {return(1);}
  }

  if (cmd == "on") {
    //toggle on only
    if ( mydiv.style.display != "none" ) {return(1);}
  }

  if(localToggleVisibleDivTest('scrollThumbsDivOuter')) {
    //nov2010 localSetArrow('thumbsdiv2aux','right',9,12)
    document.getElementById("thumbsdiv2aux").innerHTML = "+";
    localToggleVisibleDivTest('topHeaderDivRight');
    document.getElementById("scrollThumbsClose").style.display = "none";
  } 
  else {
    if (cmd == 'stop') {scroll(0,0);}
    //nov2010 localSetArrow('thumbsdiv2aux','down',12,9);
    document.getElementById("thumbsdiv2aux").innerHTML = "-";
    localToggleVisibleDivTest('topHeaderDivRight');
    document.getElementById("scrollThumbsClose").style.display = "block";
  }
  
}

function localSetArrow(object,arrow,height,width) {
  var arrowHTML = "<img src='/photoimagefiles/graphics/" + arrow + "MenuArrowBlue2.gif' border=0 height=" +
  height + " width=" + width + ">";
  document.getElementById(object).innerHTML = arrowHTML;
  
}
var imagePopupWindow = null;
function openImagePopupWindow(url) {

  if ( !imagePopupWindow || imagePopupWindow.closed ) {
    imagePopupWindow = window.open("#","ViewPhoto","scrollbars=yes,resizable=yes,width=600,height=500");
  }
  imagePopupWindow.document.location = url;
  imagePopupWindow.focus();

}

function viewSelectMenuJump(Form) {
  var FormIndex   = Form.inde.selectedIndex;

  if (!(Form.inde.options[FormIndex].value == "item0")) {
    location.href = Form.inde.options[FormIndex].value;
  }
}

function ReadCookie(cookieName) {
 var theCookie = "" + document.cookie;
 var index =theCookie.indexOf(cookieName);
 if (index==-1 || cookieName=="") return ""; 
 var index1=theCookie.indexOf(';',index);
 if (index1==-1) index1=theCookie.length; 
 var cookieValue = unescape(theCookie.substring(index+cookieName.length+1,index1));
 if (cookieValue == ";") {cookieValue = '';}
 return (cookieValue);
}

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

function getUpdatedCartHTML () {

  var mypictures = ReadCookie("mypictures");
  var tinyids = new Array();
  if (mypictures.length > 0) {
    tinyids=mypictures.split(",");
  }

  var count = tinyids.length;

  var suffix = "s";
  if (count == 1) {suffix = "";}
  var html = '<a href="javascript:openImagePopupWindow(\'/cgi-bin/photodb/viewphotos.cgi?action=viewmypictures&def=robsprophoto\')"><img src="/photoimagefiles/graphics/cart20.gif" height=20 width=20 border=0> Cart (' + count + ' photo' + suffix + ')</a>';

  return(html);
}

function getUpdatedHistoryHTML () {

  var historylist = ReadCookie("tinyidhistorylist");
  var tinyids = new Array();
  if (historylist.length > 0) {
    tinyids=historylist.split(",");
  }

  var count = tinyids.length;

  var suffix = "s";
  if (count == 1) {suffix = "";}
  var html = '<a href="javascript:openImagePopupWindow(\'/cgi-bin/photodb/viewphotos.cgi?action=viewhistory&def=robsprophoto\')">View Last ' + count + ' Picture' + suffix + '</a>';

  return(html);
}

function updateLikeViewBlock () {

  var likephotoscount = getLikePhotosCount();
  var likecounthtml = ': ' + likephotoscount;
  var likeblockctrldivdisplay = "none";

  document.getElementById("likephotoscount").innerHTML = likecounthtml;
  
  var divhtml = '';
  if (mainPageView == 'viewphotosall') {
    var buyoneurl = "javascript:localOrderTinyIDLikePrints('','');";
    var useoneurl = "javascript:localUseCartPhotos('','');";
    var rightArrow = "<img border=0 src='/photoimagefiles/graphics/rightMenuArrowBlue.gif' alt=''>";
    divhtml += '<p class="submenulink2" style="margin-left: 10px;"><a href="' + buyoneurl + '">Buy A Print ' + rightArrow + '</a></p>';
    divhtml += '<p class="submenulink2" style="margin-left: 10px;"><a href="' + useoneurl + '">Use/License Image ' + rightArrow + '</a></p>';
  }

  if (!(likephotoscount == 0)) {
    divhtml = localGetDropdownThumbs("tinyidlikelist");
    likeblockctrldivdisplay = "block";
  }

  // display: none; height: 440; width: 630; overflow: auto;

  var tinyidlist = ReadCookie("tinyidlikelist");
  var tinyids = new Array();
  tinyids=tinyidlist.split(",");
  if (tinyids.length > 4) {
    document.getElementById("likelistdiv").style.overflow = 'auto';
    document.getElementById("likelistdiv").style.height = '300px';
  } else {
    document.getElementById("likelistdiv").style.overflow = '';
    document.getElementById("likelistdiv").style.height = '';
  }
  

  document.getElementById("likelistdiv").style.width = '170px';

  document.getElementById("likelistdiv").innerHTML = divhtml;
  document.getElementById("likelistctrldiv").style.display = likeblockctrldivdisplay;

}

function localEmptyCart () {
  if (confirm('Empty your Cart?')) {
    // set cookie to empty
    setCookie("tinyidlikelist",'',90);
    var tinyid = mTIDLst[mainImageIndex];
    updateLikeIcon(tinyid);

    document.getElementById("likelistdiv").style.overflow = '';
    document.getElementById("likelistdiv").style.height = '';
    //nov2010 if (document.getElementById("likelistdiv").style.display != "none") {localToggleDivLink("likelistdiv");}

    updateLikeViewBlock();
  }
}

function localCloseAuxInfoDiv() {
  document.getElementById("AuxInfoDiv").style.display = "none";
}

function localDisplayAuxInfoMsg(infoDiv,msg) {

//    var buffer = '<div class="nolinkdec" style="float: left; width: 150px; font-size: 7pt; font-family: sans-serif; background-color: #ccc; color: #c00; font-weight: bold;">' + msg + '</div>';
      var buffer = '<p>' + msg + '</p>';

//    var removeX = '<img border=0 src="/photoimagefiles/graphics/redex2a.png">';

//    var closeThis = '<div style="float: right; width: 70px; position: relative; right: -15px;"><p class="submenulink" style="font-size: 8pt;"><a href="javascript:localToggleVisibleDiv('' + infoDiv + '');">' + removeX + ' Close</a></p></div><br clear="all">';
//    buffer += closeThis;
    document.getElementById(infoDiv).innerHTML = buffer;
    document.getElementById(infoDiv).style.display = "block";

}

function localSetAuxInfo(buffer,contentsname,optCloseThis) {

  //contentsname is a way to avoid clobbering the content of a
  //"contact" window if accidentially clicks the "Contact" link again
  //after compsing a message - don't to erase it!  So if
  //"contentsname" is the same as last one set in AuxInfo, don't set
  //it again!


  if ((lastAuxInfoContents != contentsname)|| (contentsname == '')) {
    var removeX = '<img border=0 src="/photoimagefiles/graphics/redex2a.png">';

    var closeThis = '<div style="float: right; width: 70px; position: relative; right: -15px;"><p class="submenulink" style="font-size: 8pt;"><a href="javascript:localToggleVisibleDiv(\'AuxInfoDiv\');">' + removeX + ' Close</a></p></div><br clear="all">';
    var newbuffer = '';
    newbuffer += closeThis;
    newbuffer += buffer ;
    if (optCloseThis != '') {
      newbuffer += closeThis;
    }
    document.getElementById("AuxInfoDiv").innerHTML = newbuffer;
    lastAuxInfoContents = contentsname;
  }

  document.getElementById("AuxInfoDiv").style.display = 'block';
  
}

function localGetLikeShareLink () {

  var cookieIDList = ReadCookie("tinyidlikelist");
  var tinyids = new Array();
  if (cookieIDList.length > 0) {
    tinyids=cookieIDList.split(",");
  }

  var likepairlist = tinyids.join("_");
  var sharelink = "";
  sharelink += "/" + "03," + likepairlist + ".html";
  return(sharelink);

}

function localShareCartPhotos () {

  var sharelink = localGetLikeShareLink();
  var infobuffer = "";
  infobuffer = '<p style="font-size: 12pt; color: #00c;"><b>Share Your Cart</b></p>'
             + '<p>You can share your cart photos with someone else by emailing or posting the link below. Copy the entire link and paste it into the email or posting window:</p>'
             + '<form name="htmlcode"><textarea style="margin: 4px;" cols="50" rows="3"  id="sharelinkbox" wrap="virtual">'
             + sharelink + '</textarea></form>';

  localSetAuxInfo(infobuffer,"","");
  document.getElementById("sharelinkbox").focus();
  document.getElementById("sharelinkbox").select();
  
  scroll(0,0);
  updatePingFrame("ShareLink","","");

}

function localShowLinkToPage() {

  var tinyid = mTIDLst[mainImageIndex];
  var url = "/" + localGetPageUrl(tinyid);
  var imgurl = "" + localGetImagePath(iSrc[tinyid],"thm","");

  var htmlcodenoimage = '<a href="' + url + '" target="_blank">' + iSTitle[tinyid] + '</a>';
  var htmlcodeimage =  '<div style="text-align: center;">'
                     + '<a href="' + url + '" target="_blank"><img src="' + imgurl + '" border=0 ' 
//                     + 'height="' + iHgt[tinyid] + '" width="' + iWdh[tinyid] + '" alt="'
                     + ' alt="'
                     + iSTitle[tinyid] + '"></a><br>' + htmlcodenoimage + '</div>';


  var infobuffer = '<p style="font-size: 12pt; color: #00c;"><b>Link to This Photo</b></p>'
             + '<p>'
             + 'The URL to link to the page showing this photo is'
             + '<p style="padding: 5px; font-size: 9pt;"><b><a href="' + url + '">' + url + '</a></b></p>'
             + '<p>If you wish, you can copy the HTML code below and insert it directly '
             + 'into your web page.  You may change this code however you like.</p>'
             + '<form name="htmlcode">'
             + '<textarea cols="50" rows="4" name="code" id="linktocode" wrap="virtual">'
             + htmlcodeimage
             + '</textarea>'
             + '<hr>'
             + '<p>Here is the HTML code without the image:</p>'
             + '<p>'
             + '<form name="htmlcodeni">'
             + '<textarea cols="50" rows="4" name="code" id="linktocodeimg" wrap="virtual">'
             + htmlcodenoimage
             + '</textarea>'
             + '</form>';

  localSetAuxInfo(infobuffer,"","");
  document.getElementById("linktocode").focus();
  document.getElementById("linktocode").select();

  scroll(0,0);
  updatePingFrame("LinkToPhoto","","");

}

function localShowLinkToFrontPage() {

  var url = "/";
  var htmlcodenoimage = '<a href="' + url + '" target="_blank">' + url + '</a>';

  var infobuffer = '<p style="font-size: 12pt; color: #00c;"><b>Link to This Site</b></p>'
             + '<p>'
             + 'The URL to link to this website is'
             + '<p style="padding: 5px; font-size: 9pt;"><b><a href="' + url + '">' + url + '</a></b></p>'
             + '<p>If you wish, you can copy the HTML code below and insert it directly '
             + 'into your web page.  You may change this code however you like.</p>'
             + '<form name="htmlcode">'
             + '<textarea cols="50" rows="4" name="code" id="linktocode" wrap="virtual">'
             + htmlcodenoimage
             + '</textarea>';

  localSetAuxInfo(infobuffer,"","");
  document.getElementById("linktocode").focus();
  document.getElementById("linktocode").select();

  scroll(0,0);
  updatePingFrame("LinkToFrontPage","","");

}

function localShowAboutPage () {

  var infobuffer = "";

  infobuffer = "<p>This website is a showcase for Andrew Hall\'s " 
  + "scenic photography that features Portland, Oregon and its bridges as well "
  + "as images of the Oregon Coast, the natural beauty of Oregon and "
  + "beyond, including select photography from Europe.</p>"
  + "<p>You can purchase prints and license images directly from this website.  Use the 'Add to Cart' button under each image to add them to the cart and order them or request license pricing.</p>";
  localSetAuxInfo(infobuffer,"aboutpage","");
  scroll(0,0);
  updatePingFrame("AboutSiteLink","","");

}

function localShowContactPage () {

  var xvar0 = '';
  var xvar1 = 'phot' + xvar0 + 'oquote' + '@p' + xvar0 + 'ortlandbridges.com';
  var xvar2 = 'pho' + xvar0 + 'toquote' + '@po' + xvar0 + 'rtlandbridges.com';


  var infobuffer = "";
  infobuffer = '<form name="contactform" action="/cgi-bin/photodb/viewphotos.cgi" target="pingFrameName" method="post"><p style="font-size: 12pt; color: #00c;"><b>Contact Photographer</b></p>'
             + '<input type="hidden" name="action" value="viewsubmitemail">'
             + '<input type="hidden" name="auxaux" value="">'
             + '<input type="hidden" name="slink" value="">'
             + '<p>Please include a brief message below.  If you are interested in a photo or set of photos from this website, please '
             + 'Add it to your Cart first - your Cart photos will be sent along to the Photographer with your message here. </p>'
//             + '<div style="float: left; font-size: 10pt; width: 150px; text-align: right; margin-right: 10px;"><p><b>Your Email Address:</b></p></div>'
//             + '<div style="float: left; width: 120px; font-size: 10pt;"><p><input type="text" name="email" value=""></p></div><br clear="all">'
             + '<p style="font-size: 9pt;"><b>Your Email Address:</b> &nbsp;'
             + '<input type="text" name="email" value=""></p>'
             + '<p style="font-size: 8pt;"><i>This form is preferred, but you may also contact the photographer directly via email at: '
             + '<b><a href="mai' + xvar0 + 'lto:' + xvar1 + '">' + xvar2 + '</a></b>'
//             + ' or <b><a href="callto://portlandbridges">Skype: portlandbridges</a></b>'
             + '</i></p>'

             + '<p style="font-size: 10pt; color: #00c; margin-bottom: 0;"><b>Your Message:</b></p>'
             + '<textarea style="margin: 4px;" cols="50" rows="10" name="comments" wrap="virtual">'
             + '</textarea>' + '<br>' 
             + '<input type="button" name="submitmsg" value="Send Message" onclick="localShowContactPageConfirm(this.form);">'
             + '</form>'
             + '<p>Or to call me, type in your phone number below and Google will call you and connect us.</p>'
             + '<object type="application/x-shockwave-flash" data="https://clients4.google.com/voice/embed/webCallButton" width="230" height="85"><param name="movie" value="https://clients4.google.com/voice/embed/webCallButton" /><param name="wmode" value="transparent" /><param name="FlashVars" value="id=73b722e1c37df64883e1cc786060d8ef61a916db&style=0" /></object>'
             + '';

  localSetAuxInfo(infobuffer,"contactform","");
  scroll(0,0);
  updatePingFrame("ContactLink","","");

}

function localShowContactConfirm () {

  var infobuffer = "";
  infobuffer = '<p style="font-size: 12pt; color: #00c;"><b>Your message has been sent.</b></p>'
             + '<p>Thank you!</p>';

  localSetAuxInfo(infobuffer,"","");
}

function localShowContactPageConfirm (Form) {
  if (Form.email.value == '') {
    alert("Please enter a valid email address to send a message.");
  } else {
    if (confirm('Ready to send your message? Hit OK to send')) {
      Form.auxaux.value = "r2";
      Form.auxaux.value += "d2";
      Form.slink.value = localGetLikeShareLink();
      Form.submit();
      localShowContactConfirm();
    }
  }
}


function localUseCartPhotos (tinyid,auxopts) {

  if (tinyid == '') {
    tinyid = mTIDLst[mainImageIndex];
  }

  localCopyLikeToMyPictures(tinyid,'');

  var url =
  "/cgi-bin/photodb/viewphotos.cgi?action=viewrequestquote&noback=1&def=robsprophoto" + auxopts;
  openImagePopupWindow(url);

}

function localOrderCartPrints (options) {

  var maxphotos = localCopyLikeToMyPictures("",options);

  //2. popup shoppingcart

  // /cgi-bin/photodb/viewphotos.cgi?def=portlandbridges&action=viewshoppingcart&cartaction=viewcart&maxphotos=21
  openImagePopupWindow('/cgi-bin/photodb/viewphotos.cgi?action=viewshoppingcart&cartaction=viewcart&outmsg=ordercartprints&maxphotos=' + maxphotos);
}

function localOrderTinyIDLikePrints (options,tinyid) {

  if (tinyid == '') {
    tinyid = mTIDLst[mainImageIndex];
  }
  var photoid = iPhotoId[tinyid];


  var maxphotos = localCopyLikeToMyPictures(tinyid,options);

  //2. popup shoppingcart

  // /cgi-bin/photodb/viewphotos.cgi?def=portlandbridges&action=viewshoppingcart&cartaction=viewcart&maxphotos=21
  openImagePopupWindow('/cgi-bin/photodb/viewphotos.cgi?action=viewshoppingcart&cartaction=viewcart&maxphotos=' + maxphotos + '&photoid=' + photoid);
}

function localCopyLikeToMyPictures (tinyid,options) {

  var carttinyids = new Array();
//  if (tinyid == '') {
    if (! options.match(/usesingletinyid/)) {
    //1. copy like to mypictures/cart
    var cookiePairList = ReadCookie("tinyidlikelist");
    var tinyidpairs = new Array();
    if (cookiePairList.length > 0) {
      tinyidpairs=cookiePairList.split(",");
    }
    for (var i in tinyidpairs) {
      var thistinyid = tinyidpairs[i].substring(3,6);
      carttinyids.push(thistinyid);
    }
  } else {
    //case of just a single ID being added, not from Like.
    // carttinyids.push(tinyid);
  }

    if (! (tinyid == '')) {
      carttinyids.push(tinyid);
    }

//  if (options == 'noclearmypics') {
  if (options.match(/noclearmypics/)) {
    //Keep any existing pics in mypictures
    //In case we are using "Back" in the shoppingcart
    //when origin was to buy a single print and that
    //one was in the cart first...
    var cookieIDListpre = ReadCookie("mypictures");
    if (cookieIDListpre != '') {
      var tinyidspre = new Array();
      tinyidspre=cookieIDListpre.split(",");
      for (var i in tinyidspre) {
        carttinyids.push(tinyidspre[i]);
      }
    }
  }

  //reassemble just tinyids
  var cookieIDList = "";
  if (carttinyids.length > 0) {
    cookieIDList = carttinyids.join(",");
  }
  var maxphotos = carttinyids.length;
  if (maxphotos == 1) {
    cookieIDList = carttinyids[0];
  }
    
  //save the cookie 
  setCookie("mypictures",cookieIDList,90);

  return(maxphotos);
}

function localGetImagePath(imageFile,view,color) {

  var suffix = "s";
  if (view == "thm") {
    suffix = "t";
  }

  var prefix = "/photoimagefiles/";
  //default: color image
  if (color == "bw") {
    prefix = "/bwphotoimagefiles/";
  }
  return(prefix + "" + imageFile + "-" + suffix + ".jpg");
}


function localGetDropdownThumbs (cookie) {
  var cookieIDList = ReadCookie(cookie);
//  alert("cookie is " + cookieIDList);
  var tinyids = new Array();
  if (cookieIDList.length > 0) {
    tinyids=cookieIDList.split(",");
  }
  //get thumb,link for each.
  var buffer = '';
  for (var i in tinyids) {
    var tinyid = tinyids[i].substring(3,6);
    var imageThm = localGetImagePath(iSrc[tinyid],"thm","");
    if (!(typeof imageThm == "undefined")) {
      var thumbString = '<img class="border1" style="margin: 0px 0px 0px 4px;" src="'
        + imageThm 
        + '" alt="">';
      var url = iLURL[tinyid];
      url = url.replace(/javascript\:UMI/g,"javascript:UMIns");

      if (url == '') {
        url = "/" + localGetPageUrl(tinyid);
      }
      var thumbImgUrl = '<a href="' + url + '">' + thumbString + '</a>';

      var removeX = '<img border=0 src="/photoimagefiles/graphics/redex2a.png">';
      var removeURL = '<a href="javascript:unLikePicture(\'' + tinyid + '\');">' + removeX + '</a>';
      var rmHeight = 60;
      var rmMarginTop = 25;
      //use image aspect ratio too here to adjust more if need be.
      if (iAsp[tinyid] == '3.0') {
        var rmHeight = 30;
        var rmMarginTop = 9;
      }
      if (iAsp[tinyid] == '2.0') {
        var rmHeight = 45;
        var rmMarginTop = 18;
      }
      if (iOri[tinyid] == 'v') {
        var rmHeight = 90;
        var rmMarginTop = 45;
      }

      buffer +=  '<div style="clear: both;"><div style="height:' + rmHeight + 'px; margin-top:' + rmMarginTop + 'px; padding-top: 10px; float: left; width: 16px;">' + removeURL + '</div>' +
                 '<div style="float: left; width: 130px;">' +  thumbImgUrl + '</div></div>';
    }
  }
  buffer += '<br clear="all"><hr style="margin-bottom: 0; margin-right: 20px;">';

  return(buffer);
}

function getLikePhotosCount () {

  var tinyidlist = ReadCookie("tinyidlikelist");
  var tinyids = new Array();
  if (tinyidlist.length > 0) {
    tinyids=tinyidlist.split(",");
  }

  var count = tinyids.length;

//nov2010  var countstr = '';
//nov2010  if (count > 0) {countstr = ': ' + count;}

//nov2010  return(countstr);
  return(count);

}

function openPopupWindowClearDiv(object,url) {
  
  var mydiv = document.getElementById(object);
  mydiv.style.display = 'none';

  openImagePopupWindow(url);
}

function addSidebarThumbsToMyPictures(Form,maxCount,object) {

  var msg = addToMyPictures('',Form,maxCount);
  updateMyPicturesTopMsg(msg,"orderprintok");
//  updateMyPicturesMsg("");

//Dec2009  document.getElementById("viewcartblock").innerHTML = getUpdatedCartHTML();

}

function addUpdateMyPictures(index) {

  var orderprintok = 'orderprintok';
  var tinyid = mTIDLst[index];
  if (iOrderOK[tinyid] == '0') {
    orderprintok = 'orderprintnotok';
  }
  
  var msg = addToMyPictures(newtinyid,"",0);

  updateMyPicturesTopMsg(msg,orderprintok);
//  updateMyPicturesMsg("");
  
//Dec2009  document.getElementById("viewcartblock").innerHTML = getUpdatedCartHTML();

}

function updateMyPicturesTopMsg (msg,ctrl) {

  document.getElementById('topstatus').innerHTML = msg;
  if (ctrl == 'orderprintok') {setTimeout("updateMyPicturesTopMsg('View cart to buy prints, license images.','msg2');",3000);}
  if (ctrl == 'orderprintnotok') {setTimeout("updateMyPicturesTopMsg('Note: print cannot be ordered.','msg2');",3000);}
  if (ctrl == 'msg2') {setTimeout("updateMyPicturesTopMsg('&nbsp;','clear');",3000);}
}

function updateMyPicturesMsg(msg) {

  var br = "<br>&nbsp;<br>";
  var defaultmsg = "&nbsp;&nbsp;<a href=\"javascript:openImagePopupWindow('/cgi-bin/photodb/viewphotos.cgi?action=viewmypictures&def=portlandbridges')\">View your Cart.</a>" + br + "To purchase prints from your Cart, you can <a href=\"javascript:openImagePopupWindow('/cgi-bin/photodb/viewphotos.cgi?action=viewshoppingcart')\">checkout now</a>." + br + "Or <a href=\"javascript:openImagePopupWindow('/cgi-bin/photodb/viewphotos.cgi?action=viewrequestquote&def=robsprophoto')\">Request a Licensing Quote for images in your Cart.</a>";
  var mydiv = document.getElementById("understatus");
  mydiv.style.display = 'block';
  mydiv.innerHTML  = "<p class='submenulink' style='margin-left: 20px; font-size: 10pt;'>" + msg + "" +  defaultmsg + "</p>";


}

function addToMyPictures(newtinyid,Form,maxCount) { 

  // Add tinyid to MyPics
  // Form and newtinyid are mutually exclusive, one always null...

  var newtinyids = new Array();
  if (newtinyid != '') {
    newtinyids.push(newtinyid);
  }
  else {
    //get tinyids from Form

    var jscmd;
    for (var i=0;i<maxCount;i++) {
      jscmd = "Form.p" + i + ".checked";
      var checked = eval(jscmd);
      if (checked) {
        jscmd = "Form.p" + i + ".value";
        var tinyid = eval(jscmd);
        newtinyids.push(tinyid);
      }
    }
    
  }

  // read Mypics from cookie
  var mypictures = ReadCookie("mypictures");
  var tinyids = new Array();
  if (mypictures.length > 0) {
    tinyids=mypictures.split(",");
  }

  //figure out which tinyids already in MyPics
  var newflags = new Array();
  for (var j  in newtinyids) {
    newflags[j] = "new";
    for (var i in tinyids) {
      if (tinyids[i] == newtinyids[j]) {
        newflags[j] = "already";
      }
    }
  }


  //now add only ones not already in mypics to end
  var newcount = 0;
  for (var j in newtinyids) {
    if (newflags[j] == "new") {
      tinyids.push(newtinyids[j]);
      newcount++;
    }
  }

  //reassemble
  mypictures = "";
  if (tinyids.length > 0) {
    mypictures = tinyids.join(",");
  }
  if (tinyids.length == 1) {
    mypictures = tinyids[0];
  }

  //save the cookie 
  setCookie("mypictures",mypictures,90);

  var msg;
  var ping;
  if (newtinyid == '') {
    //multiple add - form
    ping = "" + newtinyids.join(",");
    if (newcount > 0) {
      msg = "<b>" + newcount + " Image(s) added to your Cart.</b>";
    }
    else {
      msg = "<i>Image(s) already in your cart.</i>";
    }
  }
  else {
    //single add
    ping = "" + newtinyid;
    if (newcount > 0) {
      msg = "<b>Added to your Cart.</b>";
    }
    else {
      msg = "<i>Image already in your Cart.</i>";
    }
  }

  var url = "http://www.portlandbridges.com/cgi-bin/photodb/viewphotos.cgi?action=viewaddcartstatus&def=robsprophoto&q=addtocart:" + ping;
//  document.all.pingFrame.src = url;
  var w = document.getElementById("pingFrame")
  w.contentWindow.location.replace(url)

  return(msg);
}

function addToHistory(tinyid) {

  addTinyIDToCookie(iHpair[tinyid],"",0,"tinyidhistorylist",20);
  document.getElementById("viewhistoryblock").innerHTML = getUpdatedHistoryHTML();

}

function getTinyIdPairInCookie (checktinyid,cookie) {

  var cookieIDList = ReadCookie(cookie);
  var tinyidpairs = new Array();
  var tinyidpairfound = '';
  if (cookieIDList.length > 0) {
    tinyidpairs=cookieIDList.split(",");
    for (var i in tinyidpairs) {
      var tinyid = tinyidpairs[i].substring(3,6);
      if (tinyid == checktinyid) {
        tinyidpairfound = tinyidpairs[i];
      }
    }
  }
  return(tinyidpairfound);
}

function tinyIDInCookie (tinyid,cookie) {
  var cookieIDList = ReadCookie(cookie);
//  var tinyids = new Array();
//  var incookie = false;
//  if (cookieIDList.length > 0) {
//    tinyids=cookieIDList.split(",");
//    for (var i in tinyids) {
//      if (tinyids[i] == tinyid) {
//        incookie = true;
//      }
//  }

  var tinyIDregexp = new RegExp(tinyid);
  return (cookieIDList.match(tinyIDregexp));
}

function getWindowWidth() {
/* courtesy of  Mark "Tarquin" Wilton-Jones - www.howtocreate.co.uk */
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && (
  document.documentElement.clientWidth ||
  document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth ||
  document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
// window.alert( 'Width = ' + myWidth );
//  window.alert( 'Height = ' + myHeight );
  return(myWidth);
}

function updatePingFrame(action,photoid,msg) {
  if (photoid != '') {
    msg += "Color:" + mainColorView + ":Photoid=" + photoid;
  }

  var var1 = '';
  var var2 = var1;

  var windowWidth = getWindowWidth();
  msg += ":wwidth=" + windowWidth;

//  var url = "http://www.portlandbridges.com/cgi-bin/photodb/viewphotos.cgi?action=viewpingframe&def=robsprophoto&ping="
  var url = "http://www.portlandbridges.com/cgi-bin/photodb/view" + var1 + "ping.c" + var2 + "gi?action=viewpingframe&def=robsprophoto&ping="
            + action + "&q=" + msg;
  var w = document.getElementById("pingFrame")
  w.contentWindow.location.replace(url)
}

function unLikePicture (tinyid) {
  //actually, what I want is to return the pair here right?
  //so I don't have to go look it up again...
  var tinyidpair = getTinyIdPairInCookie(tinyid,"tinyidlikelist");
//  alert("tinyidpair is " + tinyidpair);
  if (tinyidpair != '') {
      removeTinyIDFromCookie(tinyidpair,"tinyidlikelist");
      updatePingFrame("unlikeimage", iPhotoId[tinyid],"");
  }
  if (mTIDLst[mainImageIndex] == tinyid) {
    updateLikeIcon(tinyid);
  }  
  updateLikeViewBlock();
  document.getElementById("AuxInfoDiv").style.display = "none";
}

function addToCart(index,tinyid,photoAuxImageDiv) {

  if (tinyid == '') {
    tinyid = mTIDLst[index];
  }

  var buylink = " <a href=\"javascript:localOrderCartPrints('');\">Order Prints</a>";
  var uselink = "&nbsp;&nbsp;<a href=\"javascript:localUseCartPhotos('','');\">Use Images</a>";
  var viewlink = "&nbsp;&nbsp;<a href=\"javascript:scroll(0,0);\">View Cart</a>";
  if (mainPageView == 'viewphotosall') {viewlink = '';}

  if (tinyIDInCookie(iHpair[tinyid],"tinyidlikelist")) {
//      removeTinyIDFromCookie(iHpair[tinyid],"tinyidlikelist");
//      updatePingFrame("unlikeimage", iPhotoId[tinyid],"");
    localDisplayAuxInfoMsg(photoAuxImageDiv,"Image is already in your Cart." + buylink + uselink + viewlink);
  }
  else {
    addTinyIDToCookie(iHpair[tinyid],"",0,"tinyidlikelist",100);
    updatePingFrame("likeimage", iPhotoId[tinyid],"");
    localDisplayAuxInfoMsg(photoAuxImageDiv,"Image added to Cart." + buylink + uselink + viewlink);
  }
  updateLikeIcon(tinyid);
  updateLikeViewBlock();
  displayLikelistBlock();
  document.getElementById("AuxInfoDiv").style.display = "none";

}


function updateLikeIcon (tinyid) {

  var myobj = document.getElementById("likeiconlegacytext");

  if (! (myobj == null)) {
    if (tinyIDInCookie(iHpair[tinyid],"tinyidlikelist")) {
      myobj.innerHTML = "<img src='/photoimagefiles/graphics/likeshowlike1g.gif' border=0 alt='In List'>(REMOVE)";
    }
    else {
      myobj.innerHTML = "+ SAVE TO LIST";
    }
  }
}

function updateLikeTopMsg (msg,ctrl) {

  document.getElementById('topstatus').innerHTML = msg;
  if (ctrl == 'msg1') {setTimeout("updateLikeTopMsg('&nbsp;','clear');",3000);}
}

function addTinyIDToCookie(newtinyid,Form,maxCount,cookie,MaxIDs) { 

  // Add tinyid to MyPics
  // Form and newtinyid are mutually exclusive, one always null...

  var newtinyids = new Array();
  if (newtinyid != '') {
//    newtinyids.push(newtinyid);
    newtinyids.unshift(newtinyid);
  }
  else {
    //get tinyids from Form

    var jscmd;
    for (var i=0;i<maxCount;i++) {
      jscmd = "Form.p" + i + ".checked";
      var checked = eval(jscmd);
      if (checked) {
        jscmd = "Form.p" + i + ".value";
        var tinyid = eval(jscmd);
        newtinyids.push(tinyid);
      }
    }
    
  }

  // read TinyIDS from cookie
  var cookieIDList = ReadCookie(cookie);
  var tinyids = new Array();
  if (cookieIDList.length > 0) {
    tinyids=cookieIDList.split(",");
  }

  //remove ids already in array from front - put new ones at end later
  var tinyids2 = new Array();
  for (var j  in newtinyids) {
    for (var i in tinyids) {
      if (tinyids[i] != newtinyids[j]) {
          tinyids2.push(tinyids[i]);
      }
    }
  }


  //now add only ones not already in array to beginning
  var newcount = 0;
  for (var j in newtinyids) {
//      tinyids2.push(newtinyids[j]);
      tinyids2.unshift(newtinyids[j]);
      newcount++;
  }

  //strip off least recent ids, keep only MaxIDs
  var clipLeastRecentIndex = tinyids2.length - MaxIDs;
  if (clipLeastRecentIndex < 0) {clipLeastRecentIndex = 0;}
  var tinyids = new Array();
  for (var i in tinyids2) {
    if (!(i < clipLeastRecentIndex)) {
      tinyids.push(tinyids2[i]);
    }
  }

  //reassemble
  cookieIDList = "";
  if (tinyids.length > 0) {
    cookieIDList = tinyids.join(",");
  }
  if (tinyids.length == 1) {
    cookieIDList = tinyids[0];
  }

  //save the cookie 
//  alert("add Cookie is " + cookieIDList);
  setCookie(cookie,cookieIDList,90);
}

function removeTinyIDFromCookie(tinyid,cookie) { 

  // read TinyIDS from cookie
  var cookieIDList = ReadCookie(cookie);
  var tinyids = new Array();
  if (cookieIDList.length > 0) {
    tinyids=cookieIDList.split(",");
  }

  //remove ids already in array 
  var tinyids2 = new Array();
  for (var i in tinyids) {
    if (tinyids[i] != tinyid) {
        tinyids2.push(tinyids[i]);
    }
  }

  //reassemble
  cookieIDList = "";
  if (tinyids2.length > 0) {
    cookieIDList = tinyids2.join(",");
  }
  if (tinyids2.length == 1) {
    cookieIDList = tinyids2[0];
  }

  //save the cookie 
  setCookie(cookie,cookieIDList,90);
//  alert("rm Cookie is " + cookieIDList);

}

function localToggleVisibleDiv (object) {
	 var mydiv = document.getElementById(object);
	 if ( mydiv.style.display != "none" ) {
	    mydiv.style.display = 'none';
	    }
	    else {
		 mydiv.style.display = '';
		 }
}
function localToggleVisibleDivTest (object) {
	  var mydiv = document.getElementById(object);
           var retval = false;
	   if ( mydiv.style.display != "none" ) {
	       mydiv.style.display = 'none';
               retval = true;
	           }
		       else {
			     mydiv.style.display = '';
						  }
  return(retval);
}

function localToggleDivLink (divname) {

  var auxdivname = divname + "aux";
  if(localToggleVisibleDivTest(divname)) {localSetArrow(auxdivname,'right',9,9)} else {localSetArrow(auxdivname,'down',9,9)};
}


function printSText (stexta,stextb,mt) {

   var stext = stextb + stexta;
   if (!stext) return '';

   var i;
   var outstr='';
   for (i = stext.length-1; i>=0; i--)
       outstr+=stext.charAt(i)
   //return outstr;

   if (mt == "mt") {
     outstr = '<a href="mailto:' + outstr + '">' + outstr + "</a>";
   }
   document.writeln(outstr);
}

function FormSubmit (Form,Action)
{
 
  //add some checking here eventually...
  // alert('Please Enter Search Words In The Search Box before hitting "GO".');
  if (Action != "") {
    Form.action.value = Action;
  }

  if (Action = "addphotos3") {
    modifiedFlag = false; //don't bug us for submit of this form.
  }

  Form.submit();
}

function localJumpPage (Action) {

  var loc = "?action=" + Action + "&def=robsprophoto";
  
  location.href = loc;
}


function localAddCat (Form,count) {
  var jscmd = "Form.pcselect" + count + ".selectedIndex";
  var index = eval(jscmd);
  jscmd = "Form.pcselect" + count + ".options[" + index + "].value";
  var valuetoadd = eval(jscmd);

  jscmd = "Form.pc" + count + ".value";
  var valuenow = eval(jscmd);
  jscmd = "Form.pc" + count + ".value = '" + 
          valuenow + "' + ' ' + '" + valuetoadd + "';";
  eval(jscmd);
}

function localShowColorLink (colorLinkDiv) {

  var bwlink = '<a class="submenulink2" href="javascript:localUpdateImageColor(\'bw\');">View B&amp;W</a>';
  var colorlink = '<a class="submenulink2" href="javascript:localUpdateImageColor(\'color\');">View Color</a>';
  var switchtocolorlink = bwlink;
  //display opposite
  if (mainColorView == 'bw') {
    switchtocolorlink = colorlink;
  }
  document.getElementById(colorLinkDiv).innerHTML = switchtocolorlink;
}


