function getObj(id) {
    return (document.all)? document.all[id] : document.getElementById(id);
}

function IaddEvent(element, event, listenerFn) {
    if(element.addEventListener) {
        element.addEventListener(event, listenerFn, false);
    } else if (element.attachEvent) {
        element.attachEvent("on" + event, listenerFn);
    } else {
        element["on"+event] = listenerFn;
    }
}


function getNewCaptcha(id, url) {
	var imgObj = getObj(id);
	imgObj.src = url+'&'+Math.random();
}

function validateProductForm() { 
	var x = document.orderForm;
	var quantity = x.quantity;
	
	if (parseInt(quantity.value) > 0)
		 x.submit();
	else
		alert('Please enter quantity');
}

/**
* swap image
**/
function swap(id, src) {
	document.images[id].src = src;
}

/**
* toggle object
**/
function toggle(name) {
	var x = getObj(name);
	x.style.display = (x.style.display == 'none' || x.style.display == '')? 'block' : 'none';
}

nocontextmenu = function() {
	alert("If you want this image, please contact Monti");
	return false;
}

norightclick = function() {
	if (document.all) {
		if (event.button==2||event.button==3) {
			nocontextmenu();
		}
	} else if (document.layers) {
		if (e.which == 3) {
			nocontextmenu();
		}
	} else if (document.getElementById){
		//if (event.which==3){
			//nocontextmenu();
		//}
	}
}

function init() {
	var x = document.images;
	for(image in x) {
		x[image].oncontextmenu = nocontextmenu;
		x[image].onmousedown = norightclick;
	}
}

//IaddEvent(window, 'load', init);
