errorMessage = "That action is not permitted, Artwork Network's site content is copyrighted!";
isIE = document.all;
isN4 = document.layers;
isNN = !document.all && document.getElementById;
   
if (isIE || isNN)
{
   document.oncontextmenu = handleRightClick;
}
else
{
   document.captureEvents(Event.MOUSEDOWN || Event.MOUSEUP);
   document.onmousedown = handleRightClick;
}

function handleRightClick(rightClickEvent)
{
   if (isN4)
   {
      if ((rightClickEvent.which == 2) || (rightClickEvent.which == 3))
      {
         alert(errorMessage);
         return false;
      }
   }
   else
   {
      alert(errorMessage);
      return false;
   }
}

function adjustContentHeight()
{
   if( navigator.appName.indexOf( "Microsoft" ) != -1 )
   {
      // windowWidth = document.documentElement.clientWidth;
      windowHeight = document.documentElement.clientHeight;
   }
   else
   {
      // windowWidth = window.innerWidth;
      windowHeight = window.innerHeight;
   }
   
   windowHeight = ( windowHeight > 611 ) ? windowHeight : 611;
   contentScrollHeight = windowHeight - 208;
   cookieScrollHeight = getCookie( "scrollHeight" );
   contentScrollObj = document.getElementById( 'content-scroll' );
   actualHeight = contentScrollObj.style.height.replace( /px/i, "" );
   
   if( ( cookieScrollHeight != null ) && ( cookieScrollHeight != "" ) )
   {
      if( ( actualHeight != cookieScrollHeight ) || ( contentScrollHeight != cookieScrollHeight ) )
      {
         contentScrollObj.style.height = contentScrollHeight + "px";
         setCookie( 'scrollHeight', contentScrollHeight, 365 );
      }
   }
   else 
   {
      contentScrollObj.style.height = contentScrollHeight + "px";
      setCookie( 'scrollHeight', contentScrollHeight, 365 );
   }
}

function externalLinks()
{
   if (!document.getElementsByTagName) return;
   var anchors = document.getElementsByTagName( "a" );
   for( var i=0; i < anchors.length; i++ )
   {
      var anchor = anchors[ i ];
      if( anchor.getAttribute( "href" ) && anchor.getAttribute( "rel" ) == "blank" )
      {
         anchor.target = "_blank";
      }
   }
}

function getCookie( c_name )
{
   if( document.cookie.length > 0 )
   {
      c_start = document.cookie.indexOf( c_name + "=" );
      if( c_start != -1 )
      { 
         c_start = c_start + c_name.length + 1; 
         c_end = document.cookie.indexOf( ";", c_start );
         if( c_end == -1 ) c_end = document.cookie.length;
         return unescape( document.cookie.substring( c_start, c_end ) );
      } 
   }
   return "";
}

function preload( relativePath )
{
   adjustContentHeight();
   window.onresize = adjustContentHeight;
   externalLinks();
   
   MM_preloadImages( relativePath + 'images/navigation_header/art_f2.gif',
                     relativePath + 'images/navigation_header/artists_f2.gif',
                     relativePath + 'images/navigation_header/businesses_f2.gif',
                     relativePath + 'images/navigation_header/collectors_f2.gif',
                     relativePath + 'images/navigation_header/designers_f2.gif',
                     relativePath + 'images/navigation_header/galleries_f2.gif',
                     relativePath + 'images/navigation_header/services_f2.gif',
                     relativePath + 'images/navigation_footer/aboutus_f2.gif',
                     relativePath + 'images/navigation_footer/calendar_f2.gif',
                     relativePath + 'images/navigation_footer/contactus_f2.gif',
                     relativePath + 'images/navigation_footer/home_f2.gif',
                     relativePath + 'images/navigation_footer/pas_f2.gif',
                     relativePath + 'images/navigation_footer/press_f2.gif',
                     relativePath + 'images/navigation_footer/support_f2.gif',
                     relativePath + 'images/support/artists_f2.gif',
                     relativePath + 'images/support/businesses_f2.gif',
                     relativePath + 'images/support/collectors_f2.gif',
                     relativePath + 'images/support/designers_f2.gif',
                     relativePath + 'images/support/galleries_f2.gif',
                     relativePath + 'images/support/general_f2.gif',
                     relativePath + 'images/services/artistwebsite_f2.gif',
                     relativePath + 'images/services/designers_f2.gif',
                     relativePath + 'images/services/brokerage_f2.gif',
                     relativePath + 'images/services/installation_f2.gif',
                     relativePath + 'images/services/eventhosting_f2.gif',
                     relativePath + 'images/services/artrotation_f2.gif',
                     relativePath + 'images/services/showroom_f2.gif',
                     relativePath + 'images/services/gallerywebsites_f2.gif',
                     relativePath + 'images/services/artleasing_f2.gif',
                     relativePath + 'images/services/more_f2.gif' );
}

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


/*** image manipulation functions ***/
function MM_findObj(n, d) { //v4.01
   var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
   d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
   if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
   for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
   if(!x && d.getElementById) x=d.getElementById(n); return x;
}

/* Functions that swaps images. */
function MM_swapImage() { //v3.0
   var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
   var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

/* Functions that handle preload. */
function MM_preloadImages() { //v3.0
   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];}}
}

/*** validation of forms ***/
function validateNewsletter( theForm )
{
   var theInputs = theForm.elements;
   var count, blankInputs, anyBlankFields;
   
   anyBlankFields = false;
   blankInputs = 'the following fields are required.\n\n';
   
   for( count=0; count<theInputs.length; count++ )
   {
      if( ( ( theInputs[count].name == "email" ) ||
            ( theInputs[count].name == "first_name" ) ||
            ( theInputs[count].name == "last_name" ) ||
            ( theInputs[count].name == "city" ) ||
            ( theInputs[count].name == "state" ) ||
            ( theInputs[count].name == "zip" ) ||
            ( theInputs[count].name == "country" ) ||
            ( theInputs[count].name == "00N700000021eo9" ) ||
            ( theInputs[count].name == "lead_source" ) ) &&
          ( theInputs[count].value == "" ) )
      {
         anyBlankFields = true;
         
         if( theInputs[count].name == "email" ) { blankInputs += "email"; }
         else if( theInputs[count].name == "first_name" ) { blankInputs += "first name"; }
         else if( theInputs[count].name == "last_name" ) { blankInputs += "last name"; }
         else if( theInputs[count].name == "city" ) { blankInputs += "city"; }
         else if( theInputs[count].name == "state" ) { blankInputs += "state/province"; }
         else if( theInputs[count].name == "zip" ) { blankInputs += "zip/postal code"; }
         else if( theInputs[count].name == "country" ) { blankInputs += "country"; }
         else if( theInputs[count].name == "00N700000021eo9" ) { blankInputs += "i am a(n)"; }
         else if( theInputs[count].name == "lead_source" ) { blankInputs += "how did you hear about us?"; }
         
         blankInputs += '\n';
      }
   }
   
   blankInputs += '\nplease enter information into these fields.';
   
   if( anyBlankFields )
   {
      hideMsgShowButton();
      alert( blankInputs );
   }
   else
   {
      if( theForm[ "00N700000022xXA" ].checked )
      {
         sendToVerticalResponse( theForm[ "email" ].value,
                                 theForm[ "first_name" ].value,
                                 theForm[ "last_name" ].value,
                                 theForm[ "state" ].value,
                                 theForm[ "zip" ].value,
                                 theForm[ "00N700000021eo9" ].value );
      }
      else
      {
         document.lead.submit();
      }
   }
   
   return false;
}

function validateRequestInfo( theForm )
{
   var theInputs = theForm.elements;
   var count, blankInputs, anyBlankFields;
   
   anyBlankFields = false;
   blankInputs = 'the following fields are required.\n\n';
   
   for( count=0; count<theInputs.length; count++ )
   {
      if( ( ( theInputs[count].name == "email" ) ||
            ( theInputs[count].name == "phone" ) ||
            ( theInputs[count].name == "first_name" ) ||
            ( theInputs[count].name == "last_name" ) ||
            ( theInputs[count].name == "city" ) ||
            ( theInputs[count].name == "state" ) ||
            ( theInputs[count].name == "zip" ) ||
            ( theInputs[count].name == "country" ) ||
            ( theInputs[count].name == "00N700000021eo9" ) ||
            ( theInputs[count].name == "00N7000000228xG" ) ||
            ( theInputs[count].name == "lead_source" ) ||
            ( theInputs[count].name == "00N700000026ris" ) ) &&
          ( theInputs[count].value == "" ) )
      {
         anyBlankFields = true;
         
         if( theInputs[count].name == "email" ) { blankInputs += "email"; }
         else if( theInputs[count].name == "phone" ) { blankInputs += "phone"; }
         else if( theInputs[count].name == "first_name" ) { blankInputs += "first name"; }
         else if( theInputs[count].name == "last_name" ) { blankInputs += "last name"; }
         else if( theInputs[count].name == "city" ) { blankInputs += "city"; }
         else if( theInputs[count].name == "state" ) { blankInputs += "state/province"; }
         else if( theInputs[count].name == "zip" ) { blankInputs += "zip/postal code"; }
         else if( theInputs[count].name == "country" ) { blankInputs += "country"; }
         else if( theInputs[count].name == "00N700000021eo9" ) { blankInputs += "i am a(n)"; }
         else if( theInputs[count].name == "00N7000000228xG" ) { blankInputs += "i would like to find out about"; }
         else if( theInputs[count].name == "lead_source" ) { blankInputs += "how did you hear about us?"; }
         else if( theInputs[count].name == "00N700000026ris" ) { blankInputs += "message"; }
         
         blankInputs += '\n';
      }
   }
   
   blankInputs += '\nplease enter information into these fields.';
   
   if( anyBlankFields )
   {
      hideMsgShowButton();
      alert( blankInputs );
   }
   else
   {
      if( theForm[ "00N700000022xXA" ].checked )
      {
         sendToVerticalResponse( theForm[ "email" ].value,
                                 theForm[ "first_name" ].value,
                                 theForm[ "last_name" ].value,
                                 theForm[ "state" ].value,
                                 theForm[ "zip" ].value,
                                 theForm[ "00N700000021eo9" ].value );
      }
      else
      {
         document.lead.submit();
      }
   }
   
   return false;
}

function validateSeekArt( theForm )
{
   var theInputs = theForm.elements;
   var count, blankInputs, anyBlankFields;
   
   anyBlankFields = false;
   blankInputs = 'the following fields are required.\n\n';
   
   for( count=0; count<theInputs.length; count++ )
   {
      if( ( ( theInputs[count].name == "first_name" ) ||
            ( theInputs[count].name == "last_name" ) ||
            ( theInputs[count].name == "email" ) ||
            ( theInputs[count].name == "company" ) ||
            ( theInputs[count].name == "city" ) ||
            ( theInputs[count].name == "state" ) ||
            ( theInputs[count].name == "00N700000026ris" ) ) &&
          ( theInputs[count].value == "" ) )
      {
         anyBlankFields = true;
         
         if( theInputs[count].name == "first_name" ) { blankInputs += "first name"; }
         else if( theInputs[count].name == "last_name" ) { blankInputs += "last name"; }
         else if( theInputs[count].name == "email" ) { blankInputs += "email"; }
         else if( theInputs[count].name == "company" ) { blankInputs += "company"; }
         else if( theInputs[count].name == "city" ) { blankInputs += "city"; }
         else if( theInputs[count].name == "state" ) { blankInputs += "state/province"; }
         else if( theInputs[count].name == "00N700000026ris" ) { blankInputs += "message"; }
         
         blankInputs += '\n';
      }
   }
   
   blankInputs += '\nplease enter information into these fields.';
   
   if( anyBlankFields )
   {
      hideMsgShowButton();
      alert( blankInputs );
   }
   else
   {
      document.lead.submit();
   }
   
   return false;
}

function validateSpecifyArt( theForm )
{
   var theInputs = theForm.elements;
   var count, blankInputs, anyBlankFields;
   
   anyBlankFields = false;
   atLeastOneChecked = false;
   blankInputs = 'the following fields are required.\n\n';
   
   for( count=0; count<theInputs.length; count++ )
   {
      if( ( ( theInputs[count].name == "name" ) ||
            ( theInputs[count].name == "company" ) ||
            ( theInputs[count].name == "phone" ) ||
            ( theInputs[count].name == "email" ) ||
            ( theInputs[count].name == "role_in_project" ) ||
            ( theInputs[count].name == "use_of_building" ) ||
            ( theInputs[count].name == "how_many_pieces" ) ) &&
          ( theInputs[count].value == "" ) )
      {
         anyBlankFields = true;
         
         if( theInputs[count].name == "name" ) { blankInputs += "name"; }
         else if( theInputs[count].name == "company" ) { blankInputs += "company"; }
         else if( theInputs[count].name == "phone" ) { blankInputs += "phone"; }
         else if( theInputs[count].name == "email" ) { blankInputs += "email"; }
         else if( theInputs[count].name == "role_in_project" ) { blankInputs += "your role in project"; }
         else if( theInputs[count].name == "use_of_building" ) { blankInputs += "use of the building"; }
         else if( theInputs[count].name == "how_many_pieces" ) { blankInputs += "number of art pieces"; }
         
         blankInputs += '\n';
      }

      if( ( theInputs[count].name == "type_of_art[]" ) && theInputs[count].checked )
      {
         atLeastOneChecked = true;
      }
   }

   if( !atLeastOneChecked )
   {
      anyBlankFields = true;
      blankInputs += "type of art";
      blankInputs += '\n';
   }
   
   blankInputs += '\nplease enter information into these fields.';
   
   if( anyBlankFields )
   {
      hideMsgShowButton();
      alert( blankInputs );
   }
   else
   {
      document.lead.submit();
   }
   
   return false;
}


/*** post to vertical response ***/
function sendToVerticalResponse( email, first, last, state, zip, type )
{
   var xmlHttp = GetXmlHttpObject();
   
   if( xmlHttp == null )
   {
      alert( "Your browser does not support AJAX!" );
      return;
   }
   
   var url = "common/verticalResponse.php?sid=" + Math.random() +
                                        "&email=" + email +
                                        "&first=" + first +
                                        "&last=" + last +
                                        "&state=" + state +
                                        "&zip=" + zip +
                                        "&type=" + type;
   
   xmlHttp.onreadystatechange = function() 
   {
      if( xmlHttp.readyState == 4 )
      {
         document.lead.submit();
      }
   };
   
   xmlHttp.open( "GET", url, true );
   xmlHttp.send( null );
}

function GetXmlHttpObject()
{
   var xmlHttp = null;
   
   try
   {
      // Firefox, Opera 8.0+, Safari
      xmlHttp = new XMLHttpRequest();
   }
   catch( e )
   {
      // Internet Explorer
      try
      {
         xmlHttp = new ActiveXObject( "Msxml2.XMLHTTP" );
      }
      catch( e )
      {
         xmlHttp = new ActiveXObject( "Microsoft.XMLHTTP" );
      }
   }
   
   return xmlHttp;
}

/*** hide button on post ***/
function hideMsgShowButton()
{
   document.getElementById( "the_submit_msg" ).style.display = 'none';
   document.getElementById( "the_submit_button" ).style.display = '';
}

function showMsgHideButton()
{
   document.getElementById( "the_submit_msg" ).style.display = '';
   document.getElementById( "the_submit_button" ).style.display = 'none';
}
