//
// UTILS.js
//

// -----------------------------------------------------------------
// F U N C T I O N S
// -----------------------------------------------------------------

function halfHourWeddingRate()
{
  rate = round( extraTimeRate / 2 );

  document.write( '$' + rate + '' );
}

// .................................................................

function basicFee( id )
{

    var fee = 0;
		
    switch( id )
    {

       case '0':           // Elopment
         fee =  310;
         break;

       case '1':           // Intimate
         fee =  375;
         break;

       case '2':           // Standard
         fee =  810;
         break;

       case '3':           // Traditional
         fee = 1185;
         break;

       default:            // Grand
         fee = 1685;
    }

    fee = round( fee );

    return fee;
}

// .................................................................

function hiResFee( id )
{

    var fee = 0;
		
    switch( id )
    {

       case '0':           // Elopment
         fee =  155;
         break;

       case '1':           // Intimate
         fee =  330;
         break;

       case '2':           // Standard
         fee = 980;
         break;

       case '3':           // Traditional
         fee = 1225;
         break;

       default:            // Grand
         fee = 1430;
    }

    fee = round( fee );

    return fee;
}

// .................................................................

function proofsFee( id )
{

    var fee = 0;
		
    switch( id )
    {

       case '0':           // Elopment
         fee =  37;
         break;

       case '1':           // Intimate
         fee =  75;
         break;

       case '2':           // Standard
         fee = 225;
         break;

       case '3':           // Traditional
         fee = 300;
         break;

       default:            // Grand
         fee = 375;
    }

    fee = round( fee );

    return fee;
}

// .................................................................

function printReadyImages( id, idText )
{

    // --------------------------------------
    // Obtain the number of Print-Ready images
    // --------------------------------------

    var x   = document.getElementById( idText );
    var hrs = 0;  // Really ARTISTIC images
		
    switch( id )
    {

       case '0':           // Elopment
         lo =  20;
         hi =  30;
         hrs = 1;    
         break;

       case '1':           // Intimate
         lo =  40;
         hi =  60;
         hrs = 1;    
         break;

       case '2':           // Standard
         lo = 140;
         hi = 165;
         hrs = 4;
         break;

       case '3':           // Traditional
         lo = 200;
         hi = 225;
         hrs = 6;
         break;

       default:            // Grand
         lo = 250;
         hi = 270;
         hrs = 10;
    }

    lo = round( lo );
    hi = round( hi );

    x.value = lo;
    x.value += " to ";
    x.value += hi;

    return hrs;
}

// .................................................................

function reImages( id, idText )
{

    // ---------------------------------------------------
    // Obtain the number of Real Estate Deliverable images
    // ---------------------------------------------------

    var x   = document.getElementById( idText );
    var hrs = 0;  // Really ARTISTIC images
		
    switch( id )
    {

       case '0':           // under 2600
         lo =  12
         hi =  15;
         hrs = 3;    
         break;

       case '1':           // 2600-4000
         lo =  18;
         hi =  22;
         hrs = 4;    
         break;

       case '2':           // 4000-5500
         lo =  26;
         hi =  30;
         hrs = 5;
        break;

       default:           // over 5500
         lo = 34;
         hi = 40;
         hrs = 7;
         break;

    }

    lo = round( lo );
    hi = round( hi );

    x.value = lo;
    x.value += " to ";
    x.value += hi;

    return hrs;
}

// .................................................................


function numWallets( id, idText )
{

    // --------------------------------------
    // Obtain the number of Print-Ready images
    // --------------------------------------

    var x   = document.getElementById( idText );
		
    switch( id )
    {

       case '0':           // Elopment
         w =  16;
         break;

       case '1':           // Intimate
         w =  32;
         break;

       case '2':           // Quaint
         w =  56;
         break;

       case '3':           // Traditional
         w = 112;
         break;

       default:            // Grand
         w = 168;
    }

    w = round( w );

    x.value = w;

    return w;
}

// .................................................................

function shadowImage( image, iWidth, iHeight, pos )
{

  document.write( '<table border="0" cellpadding="0" cellspacing="0" align=' + pos +'><tr>' );
  document.write( '<td><img src="' + image + '" width=' + iWidth + ' height=' + iHeight + ' border="1"></td>' );

  w = iWidth-16;
  h = iHeight-16;

  document.write('<td valign="top"><img src="images/shadows/whitesquare.gif" width="12" height="6"><br>');
  document.write('<img src="images/shadows/topright.gif" width="12" height="12"><br>');
  document.write('<img src="images/shadows/right.gif" width="12" height="' + h + '"></td>');
  document.write('</tr><tr><td valign="top"><img src="images/shadows/whitesquare.gif" width="6" height="12">');
  document.write('<img src="images/shadows/bottomleft.gif" width="12" height="12">');
  document.write('<img src="images/shadows/bottom.gif" width="' + w + '" height="12"></td>');
  document.write('<td valign="top"><img src="images/shadows/bottomright.gif" width="12" height="12"></td>');

  document.write( '</tr></table>' );
}

// .................................................................

function borderImage( image, iWidth, iHeight, pos )
{

  document.write( '<table border="0" cellpadding="0" cellspacing="0" align=' + pos +'><tr>' );

  if( pos == "right" ) document.write( '<td width=10>&nbsp;</td>' );

  //document.write( '<td id=photo-border>' ); shadowImage( image, iWidth, iHeight, pos ); document.write( '<td>' );
  document.write( '<td id=photo-border><img src="' + image + '" width=' + iWidth + ' height=' + iHeight + ' id="photo"></td>' );

  if( pos == "left" ) document.write( '<td width=10>&nbsp;</td>' );

  document.write( '</tr></table>' );
}

// .................................................................

function openAWindow( pageToLoad, winName, width, height, center) 
{
    xposition=0; yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 ) && (center))
    {
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
    }

    args = "width=" + width + "," 
    + "height=" + height + "," 
    + "location=0," 
    + "menubar=0,"
    + "resizable=1,"
    + "scrollbars=1,"
    + "status=0," 
    + "titlebar=0,"
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only

    window.open( pageToLoad,winName,args );
}

// .................................................................

function MM_preloadImages() 
{ 
   var d=document; 
   if(d.images) 
   { 
      if(!d.MM_p) d.MM_p=new Array(); 
    
      var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
      for(i=0; i<a.length; i++) 
       
      if (a[i].indexOf("#")!=0) 
      { 
         d.MM_p[j]=new Image; 
         d.MM_p[j++].src=a[i]; 
      } 
   } 
}

// .................................................................

function emailAddress( user, site, className )
{    
  document.write('<a class=' + className + ' href=\"mailto:' + user + '@' + site + '\" >');
  document.write(user + '@' + site + '</a>');
}

// .................................................................

function round( number,X )
{
  // rounds number to X decimal places, defaults to 2

  X = (!X ? 2 : X);

  //return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
  return Math.round( number );
}

// .................................................................

function sessionFee( form )
{
   hours = form.HOUR.value;
 
   if( hours == 0 )
     return 0;
   else return round( firstHrRate + ((hours-1)*addHrRate) );
}

// .................................................


function offImage ( imgName, num )
{
  var idx = ((num-1)*2);

  if ( document.images )
    document[imgName].src =document.MM_p[idx].src;
}

// .................................................

function onImage ( imgName, num )
{
  var idx = ((num-1)*2)+1;

  if ( document.images )
    document[imgName].src = document.MM_p[idx].src;
}

// .................................................................

function displayRandomLogo( force )
{
    var logo = new Array(7);
		  
    logo[0]="dhpLogo.jpg";
    logo[1]="dhpLogoRed.jpg";
    logo[2]="dhpLogoBlue.jpg";   
    logo[3]="dhpLogoGreen.jpg";
    logo[4]="dhpLogoPurple.jpg";
    logo[5]="dhpLogoBlack.jpg";
    logo[6]="dhpLogoOrange.jpg";  

    if( force )
	  currentLogo = force;
    else currentLogo = Math.floor( Math.random()*6 );

    document.write( '<img src=\"/images/' + logo[currentLogo] + '\" width=332 height=30 border=0 title=\"HOME // Dave Hoffmann Photography\">' );

}

// .................................................................

function displayStdLogo()
{
    document.write( '<img src=\"/images/dhpLogoGreen.jpg" width=332 height=30 border=0 title=\"HOME // Dave Hoffmann Photography\">' );
}

// .................................................................

function topMenu( fromRoot )
{
  var ch;
  
  if( fromRoot )
    ch = '/';
  else ch = '';
    
    document.write( '<a href="' + ch + 'http://blog.davehoffmannphoto.com" class="menu">blog</a>' );
    document.write( '/ <a href="' + ch + 'portfolio.htm" class="menu">portfolio</a>' );	
    document.write( '/ <a href="' + ch + 'customize.php?hrs=3&pf=0" class="menu">commission</a>' );
    document.write( '/ <a href="' + ch + 'about.htm" class="menu">about</a>' );	
    document.write( '/ <a href="' + ch + 'contact.htm" class="menu">contact</a>' );    
    document.write( '/ <a href="' + ch + 'http://www.davehoffmannphoto.com/galleries/" class="menu">proofing</a>' );	
  
}
	
// .................................................................

function footer()
{
    document.write( '<table align="center" cellpadding="0" cellspacing="0" width="940">' );
    document.write( '<tr class="menu">' );
	document.write( '<td align=left><span class="dark">event<span class="lite">photographer</span></td>' );
    //document.write( '<td align=right style="color:#dadada;"><script>emailAddress( "mail", "davehoffmannphoto.com", "menu" )</script>' );

    document.write( '<td align=right style="color:#dadada;">Copyright &copy; 2010, <a href="http://www.davehoffmannphoto.com" class=menu>Dave Hoffmann Photography</a><br>All Rights Reserved&nbsp; </td>' );	
    document.write( '</td></tr>' );
    document.write( '</table>' );
}

// .................................................................


