// JavaScript Document

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function showLarge(imageName, link) {
	document.large_product_image.src = imageName;

	var allLiElements = document.getElementsByTagName('li');

	var liElements = new Array();
	var carouselClassName = 'jcarousel-item';
	var activeClassName = ' active_thumb';
	for (var e = 0; e < allLiElements.length; e++) {
		// clear active class
		if (allLiElements[e].className.match(carouselClassName) == carouselClassName) {
			liElements[liElements.length] = allLiElements[e];
			allLiElements[e].className = allLiElements[e].className.replace(activeClassName,'');
		}
	}
	link.parentNode.className = link.parentNode.className + activeClassName;
}

function showText(textItem, allElements) {
	
	for (var c = 1; c <= allElements; c++) {
		document.getElementById('collection_text'+c).style.display = 'none';
		if( document.getElementById('collection_text'+c).style.display == 'none' && c==textItem ) {
			document.getElementById('collection_text'+c).style.display = 'block';
		}
	}
}

function GotoLocation(link){
 	DispWin = window.open(link,'Pwindow','width=730,height=550,toolbar=no,scrollbars=yes,resizable=yes,status=no,directories=no,location=yes,menubar=no,titlebar=no');
}

function GotoLocation880(link){
 	DispWin = window.open(link,'Pwindow','width=885,height=650,toolbar=no,scrollbars=no,resizable=no,status=no,directories=no,location=no,menubar=no,titlebar=no');
}

//  ------ check form ------
function checkData() {
	var f1 = document.loginform;
	var wm = "Dear visitor,\n please fill in the following data\n\r\n";
	var noerror = 1;

	// --- entered_login ---
	var t1 = f1.entered_login;
	if (t1.value == "" || t1.value == " ") {
		wm += "username is required\r\n";
		noerror = 0;
	}

	// --- entered_password ---
	var t1 = f1.entered_password;
	if (t1.value == "" || t1.value == " ") {
		wm += "password is required\r\n";
		noerror = 0;
	}

	// --- check if errors occurred ---
	if (noerror == 0) {
		alert(wm);
		return false;
	}
	else return true;
}
