﻿/* =========================================================================

JavaScript Source File -- Created with SAPIEN Technologies PrimalScript 3.1

NAME: 

AUTHOR: William M Stoffel , www.noellestoffel.com
DATE  : 12/24/2004

COMMENT: 

============================================================================ */
// convert all characters to lowercase to simplify testing
var agt=navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();
var is_mac = (agt.indexOf("mac")!=-1);
var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
//var is_aol   = (agt.indexOf("aol") != -1);
var message='The content on this page is copyrighted\n and may not be copied.';
var pNum = 0;
var smallPrintPrice = '75.00';
var popUpWinParms = 'toolbar=0,location=0,directories=0,status=yes,menubar=0,scrollbars=1,resizable=1,width=500,height=600';
var popupHTML = '<html>';
popupHTML += '<head>';
popupHTML += '<script language=\"javaScript\" type=\"text/JavaScript\">';
popupHTML += 'var message=\"The content on this page is copyrighted and may not be copied.\";';
popupHTML += 'document.title=window.name.toUpperCase()+\" - ALL RIGHTS RESERVED NOELLE STOFFEL\";';
popupHTML += 'function trapIE4(){if(event.button==2){alert(message);return false;}}';
popupHTML += 'function trapNS4(e){if(document.getElementById&&!document.all||document.layers){if(e.which==2||e.which==3){alert(message);return false;}}}';
popupHTML += 'if (document.layers){';
popupHTML += '  document.captureEvents(Event.MOUSEDOWN);';
popupHTML += '  document.onmousedown=trapNS4;';
popupHTML += '}';
popupHTML += 'else if (document.all&&!document.getElementById){';
popupHTML += '  document.onmousedown=trapIE4;';
popupHTML += '}';
popupHTML += 'document.oncontextmenu=new Function(\"alert(message);return false\")';
popupHTML += '</script>';
popupHTML += '</head>';
popupHTML += '<body style=\"background-color:#100;color:#FDEFC3;font-size:10pt;\" onload=\"window.focus();alert(document.title);\" >';
popupHTML += '<div id=\"div1\"><div width=\"100%\" height=\"100%\" border=\"0\" align=\"center\" valign=\"middle\">';
popupHTML += '<a href=\"javascript:self.close();\" border=\"0\" style=\"color:#FFF;font-family:Courier New;font-size:9pt;text-decoration:underline\">';
popupHTMLEnd = '<br>click to close window</a>\n</div>\n</body>\n</html>\n';
var giclee = '<br><a href="purchase.html" class="whiteLink">giclée prints available</a>';
var scrollText='';

function init() {
	var span='</span><br><span style="height:22px">';
	var navMenu='<span style="height:22px">';
	if (document.title == 'Home')
		navMenu+='<span class="whiteNav">Home</span>';
	else
		navMenu+='<a href="index.shtml">Home</a>';
	navMenu+=span;
	if (document.title == 'Exhibitions')
		navMenu+='<span class="whiteNav">Shows/Exhibitions</span>';
	else
		navMenu+='<a href="exhibitions.html">Shows/Exhibitions</a>';
	navMenu+=span;
	if (document.title == 'Gallery')
		navMenu+='<span class="whiteNav">Gallery</span>';
	else
		navMenu+='<a href="gallery.html">Gallery</a>';
	navMenu+=span;
	if (document.title == 'New Works')
		navMenu+='<span class="whiteNav">New Works</span>';
	else
		navMenu+='<a href="newWorks.html">New Works</a>';
	navMenu+=span;
	if (document.title == 'Purchase')
		navMenu+='<span class="whiteNav">Purchase Prints</span>';
	else
		navMenu+='<a href="purchase.html">Purchase Prints</a>';
	navMenu+=span;
	if (document.title == 'About Noelle')
		navMenu+='<span class="whiteNav">Biography</span>';
	else
		navMenu+='<a href="bio.html">About Noelle</a>';
	navMenu+=span;
	if (document.title == 'Links')
		navMenu+='<span class="whiteNav">Links</span>';
	else
		navMenu+='<a href="links.html">Links</a>';
	navMenu+=span;
	if (document.title == 'Commissions')
		navMenu+='<span class="whiteNav">Commissions</span>';
	else
		navMenu+='<a href="commissions.html">Commissions</a>';
	navMenu+=span;
	if (document.title == 'Contact')
		navMenu+='<span class="whiteNav">Contact</span>';
	else
		navMenu+='<a href="contact.html">Contact</a>';
//	navMenu+=span;
//	if (document.title == 'Newsletter')
//		navMenu+='Newsletter';
//	else
//		navMenu+='<a href="newsletter.html">Newsletter</a>';
	navMenu+='</span><br>';
	if(is_mac&&!is_safari) navMenu+='<br><br><span class="smallBold">Best viewed with Safari browser.</span><br>';
//	navMenu+='<div style="padding-top:200px"><img src="/tinc?key=wRBwWggy">';
//	navMenu+='<!--#include virtual="/cgi-bin/hitcounter.cgi?counter=software&display=true"-->';
//	navMenu+='<script type="text/javascript">document.cookie="software=0";</script>';
//	navMenu+='&nbsp;<span style="font-size:9px;vertical-align:middle">visitors</span></div>';
	navElement = document.getElementById("navDiv");
	navElement.innerHTML = navMenu;
	if (document.title=='Galleryold') {
		var theNames = new Array('Deliberation', 'Carnivale', 'Strada', 'Heartfelt', 'Escalating', 'RevealingTheVoid',
		'FadingAway', 'Emergence', 'Longing', 'Pomegranite', 'Devotion', 'Golden', 'Escape', 'IndelibleFate',
		'ForceOfCircumstance');
		_preloadGallery(theNames);
	}
	if (document.title=='Gallery') {
		var theNames = new Array('Nove', 'Carnivale', 'TransientVessel', 'PassionsWarrior', 'Deliberation',
		'ForceOfCircumstance', 'EphemeralJoy', 'FugaciousNature', 'Rapturous',
		'LovesEssence', 'Exultance', 'Brioso', 'Ravish', 'Momentum', 'Heartfelt', 'Escape', 'Emergence', 'Purpose', 'Redivivus',
		'InfiniteSpirit', 'Strada', 'Escalating', 'Elation', 'Insurrection', 'Echo', 'RevealingTheVoid', 'FadingAway', 'Golden' 
		);
		_preloadGallery(theNames);
		pNum=999;
		next();
	}
	if (document.title=='Purchase')	{
		var thePNames = new Array(
		'Encompassing Escape(+','Entrance(+','Homage(+','Lives(+','Prophet(+','Whispering Soul(+',
		'Serendipity(+','Imagine(+','Revelation(+','Wading(S(+','Departure(+',
		'Strada(S(+','Mercy(+', 'Infinite Spirit(+','Atlantis(L(+','Carnivale(+', 'Transient Vessel(+', 
		'Passions Warrior(+', 'Longing(+','Deliberation','Devotion', 'Indelible Fate', 'Force of Circumstance',
		'Fading Away(+',  'Ephemeral Joy', 'Fugacious Nature', 'Distant Realm(+','Evanescent Dream(+', 
		'Loves Essence(+', 'Heartfelt(+', 'Escape', 'Emergence', 'Purpose', 'Pomegranite', 
		'Escalating(+', 'Revealing the Void(+','Golden(S(+' 
		);
		_preloadPurchase(thePNames);
	}
	var col1 = document.getElementById('left');
	var col2 = document.getElementById('center');
	var col3 = document.getElementById('right');
// 	var number1 = col1.clientHeight;
// 	var number2 = col2.clientHeight;
// 	col1.style.height = Math.max(number1, number2);
// 	col2.style.height = Math.max(number1, number2);
	if(document.getElementById && !document.all)
   		aHeight = innerHeight;
	if(document.all)
   		aHeight = document.documentElement.offsetHeight;
	col1.style.height = aHeight;
	col2.style.height = aHeight;
	if (typeof (col3) == 'number') col3.style.height = aHeight;
}

function trapIE4(){
	if (event.button==2){
		alert(message);
		return false;
	}
}

function trapNS4(e){
	if (document.getElementById&&!document.all||document.layers){
		if (e.which==2||e.which==3){
			alert(message);
			return false;
		}
	}
}

function next() {
	if(document._pics)
		pNum++;
		if(pNum>document._pics.length-1) pNum=0;
	   	picElement = document.getElementById('mainImg');
   		picElement.src = document._pics[pNum];
		_swapText();
}

function prev() {
	if(document._pics)
		pNum--;
		if(pNum<0) pNum=document._pics.length-1;
	   	picElement = document.getElementById('mainImg');
   		picElement.src = document._pics[pNum];
		_swapText();
}

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;
}

function _preloadImages() {
  var d=document;
  if(!d._pics){ 
  	d._pics=new Array();
    var i,j=d._pics.length,a=_preloadImages.arguments,r,re; 
    for(i=0; i<a.length; i++)
    	d._pics[j++]=a[i];
  }
}
function _preloadGallery(names) {
  var d=document;
  if(!d._pics){ 
  	d._pics=new Array();
  	d._txt=new Array();
    var i,j=d._pics.length,thumbName,re; 
    for(i=0; i<names.length; i++) {
    	var fullName='images/abstracts/'+names[i].toLowerCase()+'.jpg';
    	d._pics[j]=fullName;
		re = /abstracts/i;
		thumbName = fullName.replace(re, "thumbs");
	   	scrollText+='<div class="thumbs">\n';
		scrollText+='\t<a href=\"javascript:pNum='+i+';_swapImage(\'main\',\''+fullName+'\');_swapText()\" >\n';
		scrollText+='\t<img alt=\"'+names[i]+' - Copyright Noelle Stoffel\" height=\"100\" border=\"0\" src=\"'+thumbName+'\" style=\"margin-top:10px\">\n';
		scrollText+='\t</a>\n';
		scrollText+='\t</div>\n';
    	d._txt[j++]=names[i].toLowerCase()+'.htm';
    }
	d.getElementById('thumbscroll').innerHTML = scrollText;
  }
}

function _preloadPurchase(names) {
  var d=document,small,large;
  var re = new RegExp(' ',['g']);
  if(!d._ppics){ 
  	d._ppics=new Array();
    var imagesDiv='',i,j=d._ppics.length; 
    for(i=0; i<names.length; i++) {
    	var title = names[i];
    	small='19" by 13"';
    	large='30" by 22"';
    	var largePrints = title.indexOf('(+');
    	if (largePrints>-1)
    		title = title.substring(0,largePrints);
    	var square = title.indexOf('(S');
    	if (square>-1) {
    		title = title.substring(0,square);
    		small='13" by 13"';
    		large='24" by 24"';
    		}
    	var landscape = title.indexOf('(L');
    	if (landscape>-1) {
    		title = title.substring(0,landscape);
		    small='13" by 19"';
		    large='24" by 35"';
    		}
    	var internalName=title.toLowerCase().replace(re,'');
    	d._ppics[j]=internalName;
		imagesDiv+='<div align="center" style="float:left; width:33%">';
		imagesDiv+='<a href="javascript:big(\'images/abstracts/'+internalName+'.jpg\',\''+internalName+'\')">';
		imagesDiv+='<img alt="click to see a larger image" height="100" border="0" src="images/thumbs/'+internalName+'.jpg" style="margin-top:10px; border:solid #FDEFC3 1px">';
		imagesDiv+='</a><br><span class="whiteCourier">'+title+'</span>';
		imagesDiv+='<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
		imagesDiv+='<div class="creamSmall"><input type="hidden" name="on0" value="print size">print size&nbsp;';
		imagesDiv+='<select name="os0" onchange="changeSize(this)"><option value="small">'+small;
    	if (largePrints>-1)
			imagesDiv+='<option value="large">'+large;
		imagesDiv+='</select>';
		imagesDiv+='</div><input type="image" src="gifs/addToCart.gif" border="0" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!">';
		imagesDiv+='<input type="hidden" name="add" value="1">';
		imagesDiv+='<input type="hidden" name="cmd" value="_cart">';
		imagesDiv+='<input type="hidden" name="business" value="noelle@noellestoffel.com">';
		imagesDiv+='<input type="hidden" name="item_name" value="'+title+' giclée print">';
		imagesDiv+='<input type="hidden" name="amount" value="75.00">';
		imagesDiv+='<input type="hidden" name="no_shipping" value="2">';
		imagesDiv+='<input type="hidden" name="return" value="http://www.noellestoffel.com/thankYou.html">';
		imagesDiv+='<input type="hidden" name="cancel_return" value="http://www.noellestoffel.com/cancel.html">';
		imagesDiv+='<input type="hidden" name="currency_code" value="USD">';
		imagesDiv+='</form>';
		imagesDiv+='</div>';
		}
		d.getElementById('imagesDiv').innerHTML = imagesDiv;
	}
}

function _swapImage() {
  var i,j=0,x,a=_swapImage.arguments;
  picElement = document.getElementsByName(a[0]);
  picElement[0].src = a[1];  
}

function _swapText() {
   textElement = document.getElementById('textContent');
   textElement.src = document._txt[pNum];
}

function centerWindow(mypage,myname,w,h,scroll) {
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =
	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable';
	win = window.open(mypage,myname,settings)
	win.focus();
	}

//=============================================================================================
	function open_popup(htm) {
/**********************************************************************************************
 *	Display the giclee information in a new popup window
 **********************************************************************************************/
	centerWindow(htm, "popupWin", 460, 365, "no");
	}


