var ZIPop = Array();
var PopUpLocked = 0;
var PopUpShowRequest = 0;
var PopUpHideRequest = 0;

var windowPositionArray = new Array();

var CodeLoad = "";
function LoadFunc() {
	if (CodeLoad != "") {
		eval(CodeLoad);
	}
}


function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers

function changeOpac(opacity, id) {
    if (opacity == 0) {
		document.getElementById(id).style.visibility="hidden";
	} else {
		document.getElementById(id).style.visibility="visible";
	}

	var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
	
} 

function HidePopUp() {
	PopUpHideRequest = 1;
	PopUpShowRequest = 0;
	setTimeout("HidePopUpExec()", 150);
}

function ShowPopUp() {
	PopUpHideRequest = 0;
	PopUpShowRequest = 1;
	setTimeout("ShowPopUpExec()", 150);
}

function HidePopUpExec() {
	if (PopUpHideRequest == 0) return;
	PopUpHideRequest = 0;
	
	var i = 1;
	var DivID; 
	while (document.getElementById('dhtml_goodies_id'+i)) {
		if (document.getElementById('dhtml_goodies_id'+i).style.visibility != "hidden") {
			opacity('dhtml_goodies_id'+i, 100, 0, 250);
		}
		//document.getElementById('dhtml_goodies_id'+i).style.visibility="hidden";
		i++;
	}
}

function ShowPopUpExec() {
	if (PopUpShowRequest == 0) return;
	PopUpShowRequest = 0;
	
	var i = 1;
	if (PopUpLocked == 1) return;
	while (document.getElementById('dhtml_goodies_id'+i)) {
		//changeOpac(0, 'dhtml_goodies_id'+i);
		//document.getElementById('dhtml_goodies_id'+i).style.visibility="visible";
		opacity('dhtml_goodies_id'+i, 10, 100, 400);
		i++;		
	}
}


function DisablePopUp() {
	var i = 1;
	var DivID; 
	
	PopUpLocked = 1;
	while (document.getElementById('dhtml_goodies_id'+i)) {
		document.getElementById('dhtml_goodies_id'+i).style.visibility="hidden";
		i++;
	}
}

function EnablePopUp() {
	var i = 1;
	
	PopUpLocked = 0;
	while (document.getElementById('dhtml_goodies_id'+i)) {
		document.getElementById('dhtml_goodies_id'+i).style.visibility="visible";
		i++;
	}
}

			var PopUpPosition = new Array();
			function SetPUPosition(idx, w, h) {
				PopUpPosition[idx] = new Array();
				PopUpPosition[idx]['h'] = h;
				PopUpPosition[idx]['w'] = w;			
				windowPositionArray[idx] = [w, h];
			}
			
			function GetPUMinDist(x, y) {
				var Min = 10000;
				for( var i in PopUpPosition) {
					if (Min > (Math.sqrt( (x-PopUpPosition[i]['w']) * (x-PopUpPosition[i]['w']) + (y-PopUpPosition[i]['h']) * (y-PopUpPosition[i]['h']) ) ) ) {						
						Min = (Math.sqrt( (x-PopUpPosition[i]['w']) * (x-PopUpPosition[i]['w']) + (y-PopUpPosition[i]['h']) * (y-PopUpPosition[i]['h']) ) );
					}
				}
				return Min;
			}
			
			function RandPUPosition(idx, quart) {
				var Height = 0;
				var Width = 0;
				if (navigator.appName == "Microsoft Internet Explorer") {
					//Width = document.body.clientWidth;
					//Height = document.body.clientHeight;
					Width = ( document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth ) -200;
					Height = ( document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight ) -150;
				} else {
					Width = window.innerWidth;
					Height = window.innerHeight;
				}
				
				if (Width > 900) Width = 900;
				Height = Height - 250;
				
				var XMin = 0;
				var XMax = 0;
				var YMin = 0;
				var YMax = 0;
				
				var XVector = Width / 3;
				switch (quart) {
					case 1 :
							XMin = 15; XMax = Width / 2; 
							YMin = 160; YMax = 160;										
							break;
					case 2 :
							XMin = Width / 2; XMax = Width; 
							YMin = 160; YMax = 160;
							break;
					case 3 :
							XMin = Width / 2; XMax = Width; 
							YMin = ((Height - 200) / 2) + ((Height - 200) / 2); YMax = Height;																	
							break;
					case 4 :
							XMin = Width / 2; XMax = Width; 
							YMin = ((Height - 200) / 2) + ((Height - 200) / 2); YMax = Height;																	
							break;
					default :
							XMin = 15; XMax = Width;
							YMin = ((Height - 200) / 2) + ((Height - 200) / 2); YMax = Height;
				}
								
				var x = 0;
				var y = 0;
				
				var Min=0;
				var i=0;
				for (i=0; i<10; i++) {
					x = ((Math.random() * (XMax - XMin - 350))) + XMin;
					y = (Math.random() * (YMax - YMin)) + YMin+60;
					//if (y > (Height - 200) / 2) y = (Height - 200) / 2;
					if (x < 0) x = 0;
					Min = GetPUMinDist(x, y);
					if (Min > 250) {
						break;
					}
				}
				SetPUPosition(idx, x, y);
			}
