// shop popups
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=0}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}

// delete gallery category
function deletegallery(galleryid) {
	var confirmation = window.confirm("Are you sure you want to delete this gallery? All images in this gallery will be deleted as well. If you'd like to move the photos before deleting, click Cancel. Otherwise, click Ok.");
	if (confirmation) {
		var url = "admin_gallery_category_editor.php?mode=delete&gallery="+galleryid;
		window.location = url;
	}
}

// delete item
function delete_item(page,id) {
	var confirmation = window.confirm("Are you sure you want to delete this information?");
	if (confirmation) {
		var url = page+"?mode=delete&id="+id;
		window.location = url;
	}
}

function sendCatForm(mode) {
	ref = document.getElementById('catform');
	if (mode == 'edit') {
		ref.action = 'admin_gallery_category_editor.php';
	} else {
		ref.action = 'admin_gallery_category_delete.php';
	}
	return true;
}

/********************************************************************************************/
/******************************* open an image preview window *******************************/
/********************************************************************************************/

// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 600;
defaultHeight = 450;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
close();		
}}

/* examples

Launching from a normal link:

<a href="javascript:popImage('http://SomeSite.com/SomeImage.gif','Some Title')">Click Here</a>

Launching from a form button:

<form>
<input type="button" value="Click Here" onClick="popImage('SomeImage.gif','Some Title')">
</form>*/

// match report dates
var monthDaysValue = new Array();
monthDaysValue['thirtyone'] = new Array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31");
monthDaysValue['feb_non_leap'] = new Array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28");
monthDaysValue['feb_leap'] = new Array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29");
monthDaysValue['thirty'] = new Array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30");

var monthDaysOutput = new Array();
monthDaysOutput['thirtyone'] = new Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31");
monthDaysOutput['feb_non_leap'] = new Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28");
monthDaysOutput['feb_leap'] = new Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29");
monthDaysOutput['thirty'] = new Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30");

function changeDays(input_value) {
	curdate = new Date();
	var year = curdate.getYear()
	if (year >= 100 && year <= 1999) {
		year = year + 1900
	} else {
		year = year;
	}
	var day_selector = eval("document.events_editor." + input_value + "_day");
	var month_selector = eval("document.events_editor." + input_value + "_month");
	for (i = (day_selector.length - 1); i >= 0; i--)
		day_selector[i] = null;
	if (month_selector.value == 2) {
		if ((year % 4) == 0) {
			monthArray = monthDaysValue['feb_leap'];
			monthOutput = monthDaysOutput['feb_leap'];
		} else {
			monthArray = monthDaysValue['feb_non_leap'];
			monthOutput = monthDaysOutput['feb_non_leap'];
		}
	} else if (month_selector.value == 4 || month_selector.value == 6 || month_selector.value == 9 || month_selector.value == 11) {
		monthArray = monthDaysValue['thirty'];
		monthOutput = monthDaysOutput['thirty'];
	} else {
		monthArray = monthDaysValue['thirtyone'];
		monthOutput = monthDaysOutput['thirtyone'];
	}
	for (j = 0; j < monthArray.length; j++)
		day_selector[j] = new Option(monthOutput[j], monthArray[j]);
}