window.onload = Init;

function Init(){
	AssignPopup();
//	FeedBackPopUp();
}



function PopUpWindow(mypage, myname, w, h, scroll, resize, menubbar, by){
	by == undefined ? sizeBy = "px" : sizeBy = by;
	var win = null;
	if (sizeBy == "percent"){
		var wid = (screen.availWidth/100)*w;
		var hig = (screen.availHeight/100)*h;
	}
	else if (sizeBy == "px"){
		var wid = w;
		var hig = h;
	}
	var winl = (screen.availWidth - wid) / 2;
	var wint = (screen.availHeight - hig) / 2 - 40;
	var settings = 'height=' + hig + ',';
	settings += 'width=' + wid + ',';
	settings += 'top=' + wint + ',';
	settings += 'left=' + winl + ',';
	settings += 'scrollbars=' + scroll + ',';
	settings += 'resizable=' + resize + ',';
	settings += 'menubar=' + resize + ',';
	win = window.open(mypage, myname, settings);
	if (parseInt(navigator.appVersion) >= 4){
		win.window.focus();
	}
	return win;
}

//// BeginFunction: Assign Popuups based on type
function PopupTarget(e){
	var targ;
	if(!e) var e = window.event;
	if(e.target) {
		targ = e.target;
		e.preventDefault();
	}
	else if(e.srcElement) {
		targ = e.srcElement;
		e.returnValue = false;
	}
	switch (targ.className.slice(5))
	{
	  case "popup" :
		  PopUpWindow(this.href, "dl"+targ.className.slice(5), 800, 600, "Yes", "Yes", "Yes")
		  break;
	  case "photogallery" :
		  PopUpWindow(this.href, "dl"+targ.className.slice(5), 800, 480, "No", "No", "No")
		  break;
	  case "videogallery" :
		  PopUpWindow(this.href, "dl"+targ.className.slice(5), 660, 560,"No", "No", "Yes")
		  break;

	}
}
function AssignPopup(){
	var anc = document.getElementsByTagName("A");
	for(var x=0; x<anc.length; x++){
		switch (anc[x].className)
		{
		case "open-popup" :
			anc[x].onclick = PopupTarget;
			break;
		case "open-photogallery" :
			anc[x].onclick = PopupTarget;
			break;
		case "open-videogallery" :
			anc[x].onclick = PopupTarget;
			break;
		case "open-organogram" :
			anc[x].onclick = PopupTarget;
			break;
		}
	}
}
//// EndFunction: Assign Popuups based on type

