gal_img_dir='http://www.petra-voss.de/diddlsworld/php';
gal_name='Diddl-ZIP-Box';
gal_text='Diddl-ZIP-Box';
gal_yes_gif='box_yes.gif';
gal_no_gif='box_no.gif';
gal_blank_gif='box_blank.gif';
gal_view_gif='box_view.gif';
cookiename='diddlsworld_zipbox';
usetextlinks='0';
//////////////////////////////////////////////////////////////////////////

var today = new Date();
var expiry = new Date(today.getTime() + 90 * 24 * 60 * 60 * 1000);
var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion); 
var is_ie   = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3  = (is_ie && (is_major < 4));
var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5")==-1) && (agt.indexOf("msie 6") == -1)); 
var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4); 
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav6up = (is_nav && (is_major >= 5));

if (document.images) {
        img1 = new Image(); img1.src = gal_img_dir+'/'+gal_no_gif;
        img2 = new Image(); img2.src = gal_img_dir+'/'+gal_yes_gif;
    }

index = document.cookie.indexOf(cookiename);
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1) {countend = document.cookie.length;}
fulllist = document.cookie.substring(countbegin, countend);
realitems1=fulllist.split(']');
realitems2=realitems1[0].split(cookiename);
if (!realitems2[1]) {document.cookie=""+cookiename+"="+cookiename+".; path=/";}

function showItems() {
		index = document.cookie.indexOf(cookiename);
		countbegin = (document.cookie.indexOf("=", index) + 1);
        	countend = document.cookie.indexOf(";", index);
        	if (countend == -1) {
            		countend = document.cookie.length;                        
        	}
		fulllist = document.cookie.substring(countbegin, countend);
              
        okay=0;
		itemlist = 0;
		for (var i = 0; i <= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				itemstart = i+1;
				thisitem = 1;
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				thequantity = fulllist.substring(itemstart, itemend);
                    		itemlist=itemlist+1;
                                
                            
{                        compare=path + imageid + extension;
                         compareto=thePath + theImageid + theExtension;
                         if (compare==compareto) { 
                            okay=1;
                            which=itemlist;}
}
			} else if (fulllist.substring(i,i+1) == '|') {
				if (thisitem==1) theImageid = fulllist.substring(itemstart, i);
                                if (thisitem==2) thePath = fulllist.substring(itemstart, i);
                                if (thisitem==3) theExtension = fulllist.substring(itemstart, i);
                                thisitem++;
				itemstart=i+1;
			}
		}

div='div';
layerdiv=div+path+imageid+extension;


if (usetextlinks==1){
	if (okay==1){
		if (is_ie5up || is_nav6up){ document.writeln('<div id="'+layerdiv+'"><A HREF="javascript:removeItem(\''+imageid+'\',\''+path+'\',\''+extension+'\')" onMouseOver="Status(\'Remove from '+gal_name+'\');return true" onMouseOut="Status(\'\');return true"><nobr><'+font_remove_link+'>Remove from '+gal_name+'</font></nobr></a></div>');}
		else { document.writeln('<a href="javascript:removeItem(\''+imageid+'\',\''+path+'\',\''+extension+'\')" onMouseOver="Status(\'Remove from '+gal_name+'\');return true" onMouseOut="Status(\'\');return true"><nobr><'+font_remove_link+'>Remove from '+gal_name+'</font></nobr></a>');}
	}
	else {
		if (is_ie5up || is_nav6up){ document.writeln('<div id="'+layerdiv+'"><A HREF="javascript:addtolightbox(\''+imageid+'\',\''+path+'\',\''+extension+'\')" onMouseOver="Status(\'Add to '+gal_name+'\');return true" onMouseOut="Status(\'\');return true"><nobr><'+font_add_link+'>Add to '+gal_name+'</font></nobr></a></div>');}
		else { document.writeln('<a href="javascript:addtolightbox(\''+imageid+'\',\''+path+'\',\''+extension+'\')" onMouseOver="Status(\'Add to '+gal_name+'\');return true" onMouseOut="Status(\'\');return true"><nobr><'+font_add_link+'>Add to '+gal_name+'</font></nobr></A>');}
	}
}
else {
	if (okay==1){
		if (is_ie5up || is_nav6up){ document.writeln('<div id="'+layerdiv+'"><A HREF="javascript:removeItem(\''+imageid+'\',\''+path+'\',\''+extension+'\')" onMouseOver="Status(\'Remove from '+gal_name+'\');return true" onMouseOut="Status(\'\');return true"><img src="'+gal_img_dir+'/'+gal_yes_gif+'" border=0 alt="Remove from '+gal_name+'"></a></div>');}
		else { document.writeln('<a href="javascript:removeItem(\''+imageid+'\',\''+path+'\',\''+extension+'\')" onMouseOver="Status(\'Remove from '+gal_name+'\');return true" onMouseOut="Status(\'\');return true"><img src="'+gal_img_dir+'/'+gal_yes_gif+'" border=0 alt="Remove from '+gal_name+'"></a>');}
	}
	else {
		if (is_ie5up || is_nav6up){ document.writeln('<div id="'+layerdiv+'"><A HREF="javascript:addtolightbox(\''+imageid+'\',\''+path+'\',\''+extension+'\')" onMouseOver="Status(\'Add to '+gal_name+'\');return true" onMouseOut="Status(\'\');return true"><img src="'+gal_img_dir+'/'+gal_no_gif+'" border=0 alt="Add to '+gal_name+'"></a></div>');}
		else { document.writeln('<a href="javascript:addtolightbox(\''+imageid+'\',\''+path+'\',\''+extension+'\')" onMouseOver="Status(\'Add to '+gal_name+'\');return true" onMouseOut="Status(\'\');return true"><img src="'+gal_img_dir+'/'+gal_no_gif+'" border=0 alt="Add to '+gal_name+'"></A>');}
	}
}
		
	
	}

	function removeItem(newImageid, newPath, newExtension) {
                newlocation = location.href;
                newlocationarray=newlocation.split("&lightbox");
                newstr=location.search.substring(1);
                newarray=newstr.split("=");
                if (newarray[0]=='action'){ 
                lightbox = '&lightbox=1';
                newtogo=newlocationarray[0]+lightbox;}
                else {newtogo=location.href;}
                index = document.cookie.indexOf(cookiename);
		countbegin = (document.cookie.indexOf("=", index) + 1);
        	countend = document.cookie.indexOf(";", index);
        	if (countend == -1) {
            		countend = document.cookie.length;
                        
        	}
		fulllist = document.cookie.substring(countbegin, countend);
                newItemList = cookiename;
		itemlist = 0;
                
		for (var i = 0; i <= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				itemstart = i+1;
                                thisitem = 1;
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				theitem = fulllist.substring(itemstart, itemend);
				itemlist=itemlist+1;
                                compare=newPath + newImageid + newExtension;
                                compareto=thePath + theImageid + theExtension;
                                if (compare!=compareto) {
					newItemList = newItemList+'['+theImageid+'|'+thePath+'|'+theExtension+'|]';
				}

			}else if (fulllist.substring(i,i+1) == '|') {
				if (thisitem==1) theImageid = fulllist.substring(itemstart, i);
                                if (thisitem==2) thePath = fulllist.substring(itemstart, i);
                                if (thisitem==3) theExtension = fulllist.substring(itemstart, i);
                                thisitem++;
				itemstart=i+1;
			}
		}


		index = document.cookie.indexOf(cookiename);
		document.cookie=""+cookiename+"="+newItemList+"; expires="+expiry.toGMTString()+"; path=/";

newstr=location.search.substring(1);
if (newstr=='lightbox=view'){location.href = location.href;}
else if (is_ie5up || is_nav6up){
	div='div';
	layerdiv=div+newPath+newImageid+newExtension;
	if (usetextlinks==1){
		if (is_ie5up){ document.all[layerdiv].innerHTML = '<A HREF="javascript:addtolightbox(\''+newImageid+'\',\''+newPath+'\',\''+newExtension+'\')" onMouseOver="Status(\'Add to '+gal_name+'\');return true" onMouseOut="Status(\'\');return true"><nobr><'+font_add_link+'>Add to '+gal_name+'</font></nobr></a>';}
		else { document.getElementById(layerdiv).innerHTML = '<A HREF="javascript:addtolightbox(\''+newImageid+'\',\''+newPath+'\',\''+newExtension+'\')" onMouseOver="Status(\'Add to '+gal_name+'\');return true" onMouseOut="Status(\'\');return true"><nobr><'+font_add_link+'>Add to '+gal_name+'</font></nobr></a>';}
	}
	else{
		if (is_ie5up){ document.all[layerdiv].innerHTML = '<A HREF="javascript:addtolightbox(\''+newImageid+'\',\''+newPath+'\',\''+newExtension+'\')" onMouseOver="Status(\'Add to '+gal_name+'\');return true" onMouseOut="Status(\'\');return true"><img src="'+gal_img_dir+'/'+gal_no_gif+'" border=0 alt="Add to '+gal_name+'"></a>';}
		else { document.getElementById(layerdiv).innerHTML = '<A HREF="javascript:addtolightbox(\''+newImageid+'\',\''+newPath+'\',\''+newExtension+'\')" onMouseOver="Status(\'Add to '+gal_name+'\');return true" onMouseOut="Status(\'\');return true"><img src="'+gal_img_dir+'/'+gal_no_gif+'" border=0 alt="Add to '+gal_name+'"></a>';}
	}
}
else {    location.href = location.href;}
}


	function addtolightbox(newImageid, newPath, newExtension) {
            newlocation = location.href;
                newlocationarray=newlocation.split("&lightbox");
                newstr=location.search.substring(1);
                newarray=newstr.split("=");
                if (newarray[0]=='action'){ 
                lightbox = '&lightbox=1';
                newtogo=newlocationarray[0]+lightbox;}
                else {newtogo=location.href;}
             	index = document.cookie.indexOf(cookiename);
		countbegin = (document.cookie.indexOf("=", index) + 1);
        	countend = document.cookie.indexOf(";", index);
        	if (countend == -1) {
            		countend = document.cookie.length;
                        
        	}
		fulllist = document.cookie.substring(countbegin, countend);
                itemlist = 0;
		for (var i = 0; i <= fulllist.length; i++) {
			if (fulllist.substring(i,i+1) == '[') {
				itemstart = i+1;
				thisitem = 1;
			} else if (fulllist.substring(i,i+1) == ']') {
				itemend = i;
				thequantity = fulllist.substring(itemstart, itemend);
                    		itemlist=itemlist+1;}}

if (fulllist.length<3500){closeto=3501;}
else{
rawitemsize=fulllist.length/itemlist;
exactitemsize=Math.round(rawitemsize);
itemsize=exactitemsize+50;
closeto=4096-itemsize;}
if (fulllist.length>closeto){alert('ACHTUNG:\r\r----------------------------------\r\rDeine '+gal_text+' beinhaltet '+itemlist+' Dateien und ist voll.\rDu musst erst einige Dateien entfernen, bevor Du neue hinzufügen kannst.\r\r----------------------------------');}
else { 
				index = document.cookie.indexOf(cookiename);
				countbegin = (document.cookie.indexOf("=", index) + 1);
        			countend = document.cookie.indexOf(";", index);
	        		if (countend == -1) {
        	    			countend = document.cookie.length;
	        		}
		                document.cookie=""+cookiename+"="+document.cookie.substring(countbegin, countend)+"["+newImageid+"|"+newPath+"|"+newExtension+"|]"+"; expires="+expiry.toGMTString()+"; path=/";
if (is_ie5up || is_nav6up){
	div='div';
	layerdiv=div+newPath+newImageid+newExtension;
	if (usetextlinks==1){
		if (is_ie5up){ document.all[layerdiv].innerHTML = '<A HREF="javascript:removeItem(\''+newImageid+'\',\''+newPath+'\',\''+newExtension+'\')" onMouseOver="Status(\'Remove from '+gal_name+'\');return true" onMouseOut="Status(\'\');return true"><nobr><'+font_remove_link+'>Remove from '+gal_name+'</font></nobr></a>';}
		else { document.getElementById(layerdiv).innerHTML = '<A HREF="javascript:removeItem(\''+newImageid+'\',\''+newPath+'\',\''+newExtension+'\')" onMouseOver="Status(\'Remove from '+gal_name+'\');return true" onMouseOut="Status(\'\');return true"><nobr><'+font_remove_link+'>Remove from '+gal_name+'</font></nobr></a>';}
	}
	else{
		if (is_ie5up){ document.all[layerdiv].innerHTML = '<A HREF="javascript:removeItem(\''+newImageid+'\',\''+newPath+'\',\''+newExtension+'\')" onMouseOver="Status(\'Remove from '+gal_name+'\');return true" onMouseOut="Status(\'\');return true"><img src="'+gal_img_dir+'/'+gal_yes_gif+'" border=0 alt="Remove from '+gal_name+'"></a>';}
		else { document.getElementById(layerdiv).innerHTML = '<A HREF="javascript:removeItem(\''+newImageid+'\',\''+newPath+'\',\''+newExtension+'\')" onMouseOver="Status(\'Remove from '+gal_name+'\');return true" onMouseOut="Status(\'\');return true"><img src="'+gal_img_dir+'/'+gal_yes_gif+'" border=0 alt="Remove from '+gal_name+'"></a>';}
	}
}
else { location.href = location.href;}}
}
function Status(text){window.status = text;}

function clearZIPBox() {
	if (confirm('Bist Du sicher, dass Du Deine Diddl-ZIP-Box leeren willst?')) {
		index = document.cookie.indexOf(cookiename);
		document.cookie=""+cookiename+"=.; path=/";
		location.href = location.href;
	}
}
