//*********************************************************//
// POPUP SCRIPT
//*********************************************************//

function ShowPic(img_dir,portfolio,img_filename,img_w,img_h,bgcolor)
{
//correct short image numbers
var img_num = img_filename;
if ( img_filename.length == 1 ) { img_filename = "0"+img_filename; }
//add portofolio name
//img_filename = portfolio + "_" + img_filename;

//set defaults
var pad_w = 50;
if ( img_w < img_h ) { pad_w = 80; } // skinny images have wider margins to fit title width
var pad_h = 85;//was 60, now compensate for title
var pos_w = 0;
var pos_h = 40;
var pos_s = document.body.scrollTop;
var description = eval("pics")[img_num]; //create object
var dSpacer = "<span class='spacer'>|</span>";
var dTitle = "<i>" + description[0] + "</i>&nbsp;";
var dDetail = dSpacer + description[1];
var dDate = "";
if ( description[2].length > 0 )
{
    dDate = dSpacer + description[2];
}
var dOrder = "";
if ( description[3].length > 0 ) 
{ 
    //old order print link:
    //dOrder = dSpacer + "<a href='http://www.deviantart.com/print/" + description[3] + "/' target='_blank' style='margin:0;'>Order Print</a>";
    dOrder = dSpacer + "<span>Print ID " + description[3] + "</span>";
}

//debug
//alert('img_dir: ' + img_dir + '\nportfolio: ' + portfolio  + '\nimg_filename: ' + 
//'' + img_filename + '\nimg_w: ' + img_w + '\nimg_h: ' + img_h + '\nbgcolor: ' + bgcolor +
//'' + '\n\nARRAY:\n' + description);

//grab image div position data:
  if ( self.innerWidth ) //div position width
  {
	pos_w = ( ( self.innerWidth-(img_w+pad_w) )/2 );
	pos_w = pos_w - (pad_w/3.5);//FF padding correction
  } else if ( document.body.clientWidth ) {
	pos_w = (document.body.clientWidth-(img_w+pad_w))/2;
  } else { 
    Return;
  }
  	if ( pos_s > pos_h ) //div position height
	{
	  pos_h = pos_s;
	} 
//set div position
document.getElementById("FullView").style.top = pos_h + "px";
document.getElementById("FullView").style.left = pos_w + "px";
//get image
document.getElementById("FullView").style.width = img_w + pad_w + "px";
document.getElementById("FullView").style.height = img_h + pad_h + "px";
img_dir = "p" + img_dir + "/";
document.getElementById("FullViewPic").style.width = img_w; //force size prior to load
document.getElementById("FullViewPic").style.height = img_h;//force size prior to load
document.getElementById("FullViewPic").src = img_dir + img_filename + "f.jpg";
//set Shield
document.getElementById("FullViewPicS").style.top = document.getElementById("FullViewPic").style.top;
document.getElementById("FullViewPicS").style.left = document.getElementById("FullViewPic").style.left;
document.getElementById("FullViewPicS").style.width = img_w + (pad_w -5) + "px";
document.getElementById("FullViewPicS").style.height = img_h + (pad_h -60) + "px";//shorten shield for print link
//display
document.getElementById("FullView").style.backgroundColor = "#" + bgcolor;
document.getElementById("FullView").style.display = "block";
document.getElementById("img_title").innerHTML = dTitle + dDetail + dDate + dOrder;
document.getElementById("img_title").style.display = "block"; //not sure why this is blinking
}

//*********************************************************//
// HIDE POPUP SCRIPT
//*********************************************************//

function HidePic()
{
document.getElementById("img_title").style.display = "none";
document.getElementById("FullViewPic").src = "p/spacer500.gif";
document.getElementById("FullView").style.display = "none";
}

//*********************************************************//
// PORTFOLIO PAGE HEADER
//*********************************************************//

function createPortfolioWrapper(portfolioName, spotLightImg, spotLightText, thumbsPerRow)
{
  //error check
  if ( !portfolioName ) { alert('portfolioName on this page is empty.'); }
  if ( !spotLightImg ) { alert('spotLightImg on this page is empty. Did you mean to set it to "none"?'); }
  if ( !spotLightText ) { alert('spotLightText on this page is empty. Did you mean to set it to "none"?'); }
  if ( !thumbsPerRow || thumbsPerRow != "One" && thumbsPerRow != "Two" && thumbsPerRow != "Three" && thumbsPerRow != "Four" && thumbsPerRow != "Five" && thumbsPerRow != "Six" ) { alert('thumbsPerRow on this page is incorrect. Make sure it is One, Two, Three, Four, Five or Six'); }

portfolioCondensed = portfolioName.replace(/\s+/g, "");
document.title = document.title + " " + portfolioName;
document.write('<div id="header">');
document.write('<img id="headerTitle" src="p/portfolio_' + portfolioCondensed.toLowerCase() + '_titleBG.gif" ');
document.write('alt="Becca Cusworth Photography - Portfolio ' +portfolioName+ '" ');
document.write('title="Portfolio ' + portfolioName + '"><br />');
  if ( spotLightImg != "none" )
  {
document.write('<img id="headerSpotlight" src="p/' + portfolioCondensed.toLowerCase() + '_rebeccacusworth.com.jpg" ');
document.write('alt="Becca Cusworth Photography" title=" ' + pics[spotLightImg][0] + ' / ' + pics[spotLightImg][1] + ' / Print ID ' + pics[spotLightImg][3] + '">');
  }
  if ( spotLightText != "none" )
  {
document.write('<p>' + spotLightText + '</p>');
  }
document.write('</div>');
document.write('<div id="portfolioContent" class="' + thumbsPerRow + 'Thumbs_wide">');
}

//*********************************************************//
// PORTFOLIO PAGE THUMBNAIL ROW DISPLAY
//*********************************************************//

function createPortfolioRow(imgA,imgB,imgC,imgD,imgE,imgF)
{
var showImg = new Array();
showImg[0] = imgA;
showImg[1] = imgB;
showImg[2] = imgC;
showImg[3] = imgD;
showImg[4] = imgE;
showImg[5] = imgF;
//alert(showImg.length)
//error check 
//alert('Missing image number in createPortfolioRow on this page. There must be six numbers per row, separated by commas(,). Use a zero(0) to indicate empty slot.');

//alert('createPortfolioRow\n\nportfolio: ' + portfolio + '\nstart image: ' + start_img + '\nend image: ' + end_img);
var titleHover = "";
var img_filename = "";
//alert('titleHover: ' + titleHover);

document.write('<div id="portfolioRow">');
  for ( var loop = 0; loop <= 5; loop++ )
  {
    if ( showImg[loop] && showImg[loop] > 0 )
	{
	  //do not show empty cells
      if ( showImg[loop] < 10 ) { img_filename = "0" + showImg[loop]; } else { img_filename = showImg[loop]; }
	  //alert("tNum: " + tNum + "\nimg_filename: " + img_filename);
	  titleHover = eval("pics")[showImg[loop]]; //create object
	     //error check
		 if ( !titleHover ) { alert('pics_array entry missing for image# ' + showImg[loop]); }
	  document.write('<div id="portfolioThumb">');
	  document.write('<a href="javascript:ShowPic(\'\',\'\',\'' + showImg[loop] + '\','+ titleHover[4] + ','+ titleHover[5] + ',\''+ titleHover[6] + '\')">');
	  document.write('<img src="p/' + img_filename + 't.jpg" ');
	  document.write('alt="Becca Cusworth Photography" ');
	  document.write('title="' + titleHover[0] );
	  if ( titleHover[1].length > 0 )
	  {
	    //alert('titleHover[1] ' + titleHover[1]);
	    document.write(' / ' + titleHover[1] );
	  }
	  if ( titleHover[2].length > 0 )
	  {
	    //alert('titleHover[2] ' + titleHover[2]);
	    document.write(' / ' + titleHover[2] );
	  }
	  document.write('"></a></div>');
    }
  }
document.write('</div>');
}

//*********************************************************//
// POPUP HOLDER
//*********************************************************//

//write FullView DIV and FulViewPic IMG
document.write('<div id="FullView">');
document.write('<p><a href="javascript:HidePic();">');
document.write('<img id="FullViewPicS" src="p/fullsize.gif" border="0">');
document.write('<img id="FullViewPic" src="" border="0"></a></p>');
document.write('<p id="img_title"></p>');
document.write('<p><a href="javascript:HidePic();">[close image]</a></p></div>');




