//	Duffy site scripts
//	7/15/03

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];}}
}
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;
}
function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}
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 blank() { window.status=''; }

function getMainImg() {
	var rdm = Math.round(Math.random())+1;
	document.writeln('<img src="/images/paint/main_painting' + rdm + '.jpg" width="321" height="368" border="0" alt="">');
}

//	Netscape Resize fix ..............................................
if(!window.saveInnerWidth) {
  window.onresize = resizeIt;
  window.saveInnerWidth = window.innerWidth;
  window.saveInnerHeight = window.innerHeight;
}

function resizeIt() {
    if (saveInnerWidth < window.innerWidth || 
        saveInnerWidth > window.innerWidth || 
        saveInnerHeight > window.innerHeight || 
        saveInnerHeight < window.innerHeight ) 
    {
        window.history.go(0);
    }
}

//	Browser object ....................................................
function lib_bwcheck(){ 
  this.ver=navigator.appVersion
  this.agent=navigator.userAgent
  this.dom=document.getElementById?1:0
  this.opera5=this.agent.indexOf("Opera 5")>-1
  this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
  this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
  this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
  this.ie=this.ie4||this.ie5||this.ie6
  this.mac=this.agent.indexOf("Mac")>-1
  this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
  this.ns4=(document.layers && !this.dom)?1:0;
  this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5)
  return this
}
bw=new lib_bwcheck() //Browsercheck object
/*
var whichCss = (bw.ns4)?"_nn":"";
alert(whichCss);
document.write('<link href="/css/duffy'+whichCss+'.css" rel="stylesheet" type="text/css">');
*/

newWin = false;
function openPop() {
	//	this function can be used with a variable number of arguments
	//	arguments must be in this order
	//	empty arguments need to be included as 0/false values:  value,value,0,value
	//	url is the only required value
	// args: url, width, height, scrollbars, resizable
	//	example call:  new window with width, height, no scrollbars, resizable
	//			openWin('http://somewhere.com',520,500,0,1);
	//args = openWin.arguments;
	//var len = args.length;
	
	//if(newWin){newWin.focus();}
	var url,w,h,s,r,win,winName,params;
	url = 'pop.html'	//args[0];
	w = 570	//	len>1&&args[1]?args[1]:570;
	h = 385	//	len>2&&args[2]?args[2]:385;
	s =	0	//	len>3&&args[3]?args[3]:0;
	r = 0	//	len>4&&args[4]?args[4]:0;
	winName = "popup";
	params = 'width='+w+',height='+h+',scrollbars='+s+',resizable='+r;
	newWin = window.open(url,winName,params);
	newWin.focus();
}
function showStatus(msg) {
	window.status = msg?msg:'';
	return true;
}

//	alert flag
	var boolAlertMsg = true;
//	specifically for PayPal Form
function submitForm(formObj,togglePrice) {
	//	update the "amount" field with either the framed or unframed price before submitting
	if(togglePrice) {
		formObj.amount.value=formObj.framed.value
	} else {
		formObj.amount.value=formObj.unframed.value
	}
	
	if(boolAlertMsg) {
		alert('You are now leaving Daniel Mark Duffy’s Site to go to Pay Pal, a trusted partner');
		boolAlertMsg = false;
	}
	formObj.submit();
}