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_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_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 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];}
}
var collection;
if (document.all) {
	collection = document.all;
} else {
	collection = document.getElementsByTagName('*');
}

function CloseCollectionMenu() {
	for (var i=0 ; i<collection.length ; i++) {
		if (collection[i].id.indexOf('menuDiv1') >= 0) {
			var div = collection[i];
			if (div.style.display == "block") {
				div.style.display = "none";
				var img = document.getElementById('menuImg1'+div.id.substring(8));
				img.src='imgs/ar-right.gif';
			}
		}
	}
	return true;
}
function ShowMenu(id) {
	if (id.indexOf('_') >= 0) {
		for (i=0 ; i<collection.length ; i++) {
			if (collection[i].id.indexOf('menuDiv1_') >= 0) {
				div = collection[i];
				if (div.style.display == "block") {
					if (div.id != 'menuDiv1_'+id) {
						div.style.display = "none";
						img = document.getElementById('menuImg1_'+div.id.substring(div.id.indexOf('_')+1));
						img.src='imgs/ar-right.gif';
					}
				}
			}
		}
	}
	var div = document.getElementById('menuDiv'+id);
	var img = document.getElementById('menuImg'+id);
	if (div.style.display == "block") {
		img.src='imgs/ar-right.gif';
		div.style.display = "none";
	} else {
		img.src='imgs/ar-down.gif';
		div.style.display = "block";
	}
}
function ShowSpecMenu(id) {
	for (i=0 ; i<collection.length ; i++) {
		if (collection[i].id.indexOf('spec_') >= 0) {
			div = collection[i];
			if (div.style.display == "block") {
				if (div.id != 'spec_'+id) {
					div.style.display = "none";
				}
			}
		}
	}
	var div = document.getElementById('spec_'+id);
	if (div.style.display == "block") {
//		div.style.display = "none";
	} else {
		div.style.display = "block";
	}
}
function ShowAboutItems(id, pic, pic_x, pic_y) {
	for (i=0 ; i<collection.length ; i++) {
		if (collection[i].id.indexOf('divabout_') >= 0) {
			div = collection[i];
			if (div.style.display == "block") {
				if (div.id != 'divabout_'+id) {
					div.style.display = "none";
				}
			}
		}
	}
	div = document.getElementById('divabout_'+id);
	if (div.style.display == "none") {
		div.style.display = "block";
		img_div = document.getElementById('about-img');
		var img_html = "";
		if (pic == 1) {
			img_html = "<img src=\"files/about/"+id+".jpg\" width=\""+pic_x+"\" height=\""+pic_y+"\">";
		}
		img_div.innerHTML = img_html;
	}
}

function openPrivacyWindow(url) {
	window.open(url,'privacy','menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,width=400,height=500,left=0,right=0');
}
function openImeiWindow(url) {
	window.open(url,'privacy','menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,width=300,height=260,left=0,right=0');
}

function changeQuantitySum(quantity, cost, delivery, currency) {
	var total_due = (parseFloat(cost)+parseFloat(delivery))*parseInt(quantity)*100/100;
	document.getElementById('total_due_div').innerHTML = currency+''+total_due;
}

function bindReady(){
	if (  bindReady.readyBound ) return;
	bindReady.readyBound = true;

	// Mozilla, Opera and webkit nightlies currently support this event
	if ( document.addEventListener ) {
		// Use the handy event callback
		document.addEventListener( "DOMContentLoaded", function(){
			document.removeEventListener( "DOMContentLoaded", arguments.callee, false );
			bindReady.ready();
		}, false );

	// If IE event model is used
	} else if ( document.attachEvent ) {
		// ensure firing before onload,
		// maybe late but safe also for iframes
		document.attachEvent("onreadystatechange", function(){
			if ( document.readyState === "complete" ) {
				document.detachEvent( "onreadystatechange", arguments.callee );
				bindReady.ready();
			}
		});

		// If IE and not an iframe
		// continually check to see if the document is ready
		if ( document.documentElement.doScroll && window == window.top ) (function(){
			if ( bindReady.isReady ) return;

			try {
				// If IE is used, use the trick by Diego Perini
				// http://javascript.nwbox.com/IEContentLoaded/
				document.documentElement.doScroll("left");
			} catch( error ) {
				setTimeout( arguments.callee, 0 );
				return;
			}

			// and execute any waiting functions
			bindReady.ready();
		})();
	}

}
bindReady.readyBound = false;
bindReady.isReady = false;
bindReady.ready = function(){
	bindReady.isReady = true;
	var i;
	for (i=0;i<bindReady.queue.length;i++){
	  var f = bindReady.queue[i];
	  f();
	}
}
bindReady.queue = [];
bindReady.add = function(f){
  if (bindReady.isReady) {
    f();
  }
  else {
  	bindReady.queue.push(f);
  }
}

