// JavaScript Document
function inProgress(section) {
	alert(section + ' is currently in progress and will be completed in the near future.');
}

//auto select a painting
function viewPainting(PaintingsSelectForm){
	var URL = document.PaintingsSelectForm.site.options[document.PaintingsSelectForm.site.selectedIndex].value;
	window.location.href = URL;
}

//auto refresh preview postcard
function processPostcard(action){
	document.SendPaintingForm.a.value = action;
	document.SendPaintingForm.submit();
}

//clear a form completely given a form name
function clearForm(formName) {
	var theForm = eval("document." + formName);
	for (i = 0; i < theForm.length; i++) {
		if(theForm.elements[i].type != 'submit' 
			&& theForm.elements[i].type != 'reset'
			&& theForm.elements[i].type != 'button') {
			theForm.elements[i].value = "";
		}
	}
	return;
}

//actions for shopping cart items
function itemAction(action, itemId) {
	var theForm = document.CartForm;
	var theQuantity = eval("document.CartForm.quantity_"+itemId+".value");
	if(theQuantity == null 
		|| theQuantity == "" 
		|| theQuantity < 1 ) {
		alert("Quantity is in valid! ");
	}
	else {
		if(action == 'delete') {
			if(confirm("Are you sure you want to delete this item?")) {
				theForm.submitAction.value = action;
				theForm.itemId.value = itemId;
				theForm.quantity.value = theQuantity;
				theForm.submit();
			}
		}
		else {
			theForm.submitAction.value = action;
			theForm.itemId.value = itemId;
			theForm.quantity.value = theQuantity;
			theForm.submit();
		}
	}
}	

var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height) {
  
  if(popUpWin) {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this header
isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;

function ddInit(e){
  topDog=isIE ? "BODY" : "HTML";
  whichDog=isIE ? document.all.theLayer : document.getElementById("theLayer");  
  hotDog=isIE ? event.srcElement : e.target;  
  while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }  
  if (hotDog.id=="titleBar"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
  }
}

function dd(e){
  if (!ddEnabled) return;
  whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;  
}

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

function hideMe(){
  if (isIE||isNN) whichDog.style.visibility="hidden";
  else if (isN4) document.theLayer.visibility="hide";
}

function showMe(){
  if (isIE||isNN) whichDog.style.visibility="visible";
  else if (isN4) document.theLayer.visibility="show";
}

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");

function i18nIncomplete(){
	alert("Thanks for trying out this feature. Please contact me if you'd like to help with translations. Thanks!");
}