function newWind(url){

	window.open(url,"","width=510,height=550,status=1");
	return false;
}

function maxImage(img,LangId){
	if(LangId=="34")	LangId="lt";
	if(LangId=="5")		LangId="en";

	var Close=new Array()
		Close["lt"]="Uždaryti";
		Close["en"]="Close";

	var title = document.title;
	var dir = "http://www.kosmada.lt/EasyAdmin/sys/photos/originals/";

	var html="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
	html+="<html>\n";
	html+="<head>\n";
	html+="<title>" + title + "</title>\n";
	html+="<meta http-equiv='imagetoolbar' content='no'>\n";
//	html+="<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>\n";
	html+="</head>\n";
	html+="<body bgcolor='#ffffff' topmargin=15 leftmargin=15 marginheight=15 marginwidth=15>";
	html+="<table width='100%' height='100%' border='0' cellspacing='0' cellpadding='0'><tr><td align='center'>";
	html+="<a onClick='window.close()'><img src='"+dir+img+"' border='0' alt='"+Close[LangId]+"'></a>";
	html+="</td></tr></table>";
	html+="</body>\n";
	html+="</html>\n";

	var Window2=open("","",",scrollbars=yes, resizable=yes, location=no, menubar=no, status=no,");
	Window2.document.open();
	Window2.document.write(html);
	Window2.document.close();
}


function DoAlert(msg){
	var title = document.title;

	var html="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
	html+="<html>\n";
	html+="<head>\n";
	html+="<title>" + title + "</title>\n";
	html+="<meta http-equiv='imagetoolbar' content='no'>\n";
//	html+="<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>\n";
	html+="</head>\n";
	html+="<body bgcolor='#eff6fe' topmargin=15 leftmargin=15 marginheight=15 marginwidth=15>";
	html+="<table width='100%' height='100%' border='0' cellspacing='0' cellpadding='0'><tr><td align='center'>";
	html+="<a onClick='window.close()'>" + msg + "</a>";
	html+="</td></tr></table>";
	html+="</body>\n";
	html+="</html>\n";

	var Window2=open("","","height=300,width=300,left=300,top=300,scrollbars=yes, resizable=yes, location=no, menubar=no, status=no,");
	Window2.document.open();
	Window2.document.write(html);
	Window2.document.close();
}

function changeImages() {
	if (document.images) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = eval(changeImages.arguments[i+1] + ".src");
		}
	}
} 

	function NextPicture() {
		web_dir="http://www.kosmada.lt/image.php?Image=";

		if((currentPicture+3)<=(PictureArray.length)) {
			for(var i=1; i<4; i++) {
				var nr=currentPicture+i-1;
				document.getElementById("GalleryPict"+i).src=LoadedPictureArray[nr].src;
			}
		}
		for(var i=1; i<4; i++) {
			if(document.getElementById("GalleryPict"+i)) {
				document.getElementById("GalleryPict"+i).className="listImg";
			}
		}

		currentPicture=currentPicture+1;
		document.getElementById("mainCatalogPict").src=LoadedPictureArray[currentPicture].src;
		document.getElementById("mainCatalogPict").onclick=new Function ("ShowFullGallery('"+currentPicture+"', '"+BranchId+"')");
		
		if(currentPicture==PictureArray.length-1) {
			document.getElementById("nextLabel").style.display="none";
			document.getElementById("GalleryPict3").className="listImgA";
			selectedPicture=3;
		}
		else {
			document.getElementById("GalleryPict2").className="listImgA";
			selectedPicture=2;
		}
		if(currentPicture>1) {
			document.getElementById("prevLabel").style.display="block";
		}
		if((currentPicture+3)<=(PictureArray.length-1)) {
			LoadedPictureArray[currentPicture+3]= new Image();
			LoadedPictureArray[currentPicture+3].src=web_dir+PictureArray[currentPicture+3];
		}
	}

	function PrevPicture() {
		web_dir="http://www.kosmada.lt/image.php?Image=";
		if((currentPicture-2)>=1) {
			for(var i=1; i<4; i++) {
				var nr=currentPicture+i-3;
				document.getElementById("GalleryPict"+i).src=LoadedPictureArray[nr].src;
			}
		}
		for(var i=1; i<4; i++) {
			if(document.getElementById("GalleryPict"+i)) {
				document.getElementById("GalleryPict"+i).className="listImg";
			}
		}

		currentPicture=currentPicture-1;
		document.getElementById("mainCatalogPict").src=LoadedPictureArray[currentPicture].src;
		document.getElementById("mainCatalogPict").onclick=new Function ("ShowFullGallery('"+currentPicture+"', '"+BranchId+"')");
		if(currentPicture==1) {
			document.getElementById("prevLabel").style.display="none";
			document.getElementById("GalleryPict1").className="listImgA";
			selectedPicture=1;
		}
		else {
			document.getElementById("GalleryPict2").className="listImgA";
			selectedPicture=2;
		}
		if(currentPicture!=PictureArray.length) {
			document.getElementById("nextLabel").style.display="block";
		}
		if((currentPicture-3)>=1) {
			LoadedPictureArray[currentPicture-3]= new Image();
			LoadedPictureArray[currentPicture-3].src=web_dir+PictureArray[currentPicture-3];
		}
		
	}

	function ShowFullGallery(current, branch) {
		window.open("http://www.kosmada.lt/index.php?ItemId=36399&CurrentImg="+current+"&BranchId="+branch,"","width=910,height=950,status=1");
		return false;
	}

	function ChangeCurrent(imgObj) {
		var objId=imgObj.id;
		var a = objId.substring(11,12);
		if(a<selectedPicture) {
			var cycle = selectedPicture-a;
			PrevPicture();		
			if(cycle==2)
				PrevPicture();
		}
		else if(a>selectedPicture) {
			for(var i=0; i<(a-selectedPicture); i++) {
				var cycle = a-selectedPicture;
				NextPicture();		
				if(cycle==2)
					NextPicture();
			}
		}
		selectedPicture=a;
	}
