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.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];}
}

function swMenu(ndcode)
	{
	node = document.getElementById(ndcode);
	if (node)
		{
		if (node.style.display=="none")
			{ node.style.display="block"; }
		else
			{ node.style.display="none"; }
		}
	}

function popWindow() 
	{
	// new url,winname, width, height
	args=popWindow.arguments;
	//sizestr='width='+args[2];
	w=args[2];
	h=args[3];
	s=args[4];
	r=args[5];
	if (s=='scroll')
		{scrollbar=",scrollbars=yes";}
	else
		{
		scrollbar="";
		if (w>=screen.width)
			{ 
			w=screen.width-100; 
			scrollbar=",scrollbars=yes";
			}
		if (h>=screen.height)
			{ 
			h=screen.height-150; 
			scrollbar=",scrollbars=yes";
			}
		}
	if (r=='resize')
		{scrollbar+=",resizable=yes";}
	sizestr='width='+w;
	sizestr+=',height='+h;
	midx=(screen.width - w) / 2;
	midy=(screen.height - h) / 2;
	sizestr+=',left='+midx;
	sizestr+=',top='+midy;
	sizestr+=scrollbar;
  	popupWin = window.open(args[0], args[1], sizestr)
	}

function ProdEntry(pID,pName,pDescr,pPic,pType,pPrice)
	{
	this.pID=pID;
	this.pName=pName;
	this.pDescr=pDescr;
	this.pPic=pPic;
	this.pType=pType;
	this.pPrice=pPrice;
	}
FeatProducts=new Array();

function Featured()
	{
	m=FeatProducts.length-1;
	// featured 1
	if (m>0)
		{
		id1=Math.round((m*Math.random()));
		if (id1==0) {id1=1};
		t=document.getElementById('bt1');
		d=document.getElementById('bd1');
		p=document.getElementById('bp1');
		fpid=document.getElementById('pid1');
		ml=document.getElementById('bm1');
		bpl=document.getElementById('bpl1');
		switch (FeatProducts[id1].pType)
			{
			case 1:
				t.innerHTML="Προτεινόμενα προϊόντα";
				break;
			case 2:
				t.innerHTML="Προσφορές";
				break;
			case 3:
				t.innerHTML="Νέο προϊόν";
				break;
			}
		p.src=FeatProducts[id1].pPic;
		d.innerHTML="<b>" + FeatProducts[id1].pName + '<\/b><br>' + FeatProducts[id1].pDescr;
		fpid.value=FeatProducts[id1].pID;
		ml.href="productdetails.php?pid=" + FeatProducts[id1].pID;
		bpl.href="productdetails.php?pid=" + FeatProducts[id1].pID;
		}
	// featured 2
	
	if (m>1)
		{
		id2=id1;
		while ((id2==id1) || (id2==0))
			{ id2=Math.round((m*Math.random())); }
		t=document.getElementById('bt2');
		d=document.getElementById('bd2');
		p=document.getElementById('bp2');
		fpid=document.getElementById('pid2');
		ml=document.getElementById('bm2');
		bpl=document.getElementById('bpl2');
		switch (FeatProducts[id2].pType)
			{
			case 1:
				t.innerHTML="Featured Products";
				break;
			case 2:
				t.innerHTML="Offers";
				break;
			case 3:
				t.innerHTML="New Product";
				break;
			}
		p.src=FeatProducts[id2].pPic;
		d.innerHTML="<b>" + FeatProducts[id2].pName + '<\/b><br>' + FeatProducts[id2].pDescr;
		fpid.value=FeatProducts[id2].pID;
		ml.href="productdetails.php?pid=" + FeatProducts[id2].pID;
		bpl.href="productdetails.php?pid=" + FeatProducts[id2].pID;
		}
	if ((FeatProducts.length-1)>2) { setTimeout('Featured()', 10000); }
	}

function SubmitML()
	{
	var agt = navigator.userAgent.toLowerCase();
	
	var chkfields=[
		[document.mlfrm.mlName, (document.mlfrm.mlName.value=="YOUR NAME" ? "" : document.mlfrm.mlName.value) , "^[ a-zA-Z\-]{2,100}$", "Name (in Latin)"],
		[document.mlfrm.mlEmail, (document.mlfrm.mlEmail.value=="YOUR EMAIL ADDRESS" ? "" : document.mlfrm.mlEmail.value) , "^[a-z][a-z\-\_0-9\.]+@[a-z-_0-9\.]+\.[a-z]{2,4}$", "Email"],
		["", (((document.mlfrm.rbML[0].checked=="1") || (document.mlfrm.rbML[1].checked=="1")) ? "1" : "0"), "^[1]$", "Subscribe or unsubscribe"]
	];
	var rexp;

	for (i=0;i<chkfields.length;i++)
		{
		rexp = new RegExp(chkfields[i][2]);
		if (!chkfields[i][1].match(rexp))
			{
			alert("Please fill in correctly the field: " + chkfields[i][3] + ".");
			if (chkfields[i][0]) { chkfields[i][0].focus(); }
			return false;
			}
		}
	}
	
