var share = new Object();

share.subMenuStart = function () {
	if (this.timerId) clearTimeout(this.timerId);
	this.menuAr = new Array();
	var j = 0;
	for(i=0;i<arguments.length;i++) {
		if (i==0) {
			this.menuDiv = arguments[i];
		} else if (i==1) {
			this.currObject = arguments[i];
		} else if (i==2) {
			this.menuY = arguments[i];
		} else if (i==3) {
			this.menuWidth = arguments[i];
		} else {
			this.menuAr[j] = arguments[i];
			j++;
		}
	}
	
	var pos = XMLHttp.getObjectPos(this.currObject);
	menuObject = document.getElementById(this.menuDiv);
	menuObject.style.display = "block";
	menuObject.style.left = pos[0]+"px";
	//if (BrowserDetect.browser == "Firefox") menuObject.style.top = parseInt(pos[1]+this.menuY-90)+"px";
	//else menuObject.style.top = parseInt(pos[1]+this.menuY)+"px";
	menuObject.style.top = parseInt(pos[1]+this.menuY)+"px";
	

	menuHTML = "";
	
	menuHTML += "<table width='"+this.menuWidth+"' border='0' cellpadding='5' cellspacing='0'>\n";
	for(i=0;i<this.menuAr.length;i++) {
		menuHTML += "<tr>\n";
		menuHTML += "<td width='"+this.menuWidth+"' onClick=\"location.href='"+this.menuAr[i][1]+"'\" style='cursor:pointer' class='submenu_bg' onMouseOver=\"this.className='submenu_bg_over'\" onMouseOut=\"this.className='submenu_bg'\">\n";
		menuHTML += this.menuAr[i][0]+"\n";
		menuHTML += "</td>\n";
		menuHTML += "</tr>\n";
	}
	menuHTML += "</table>\n";

	menuObject.innerHTML = menuHTML;
};

share.subMenuStop = function () {
	if (this.timerId) clearTimeout(this.timerId);
	this.timerId = setTimeout("share.subMenuHide()", 1000);
};

share.subMenuShow = function () {
	if (this.timerId) clearTimeout(this.timerId);
	menuObject = document.getElementById(this.menuDiv);
	menuObject.style.display = "block";
};

share.subMenuHide = function () {
	menuObject = document.getElementById(this.menuDiv);
	menuObject.style.display = "none";
};


share.newsDetails = function(school, pageName, id) {
	windowControl.windowOpen('divNews', 'index.php?igo=details&school='+school+'&page_name='+pageName+'&edid='+id+'&pmod=xml', '', [document.body.scrollLeft, document.body.scrollTop], '');
};

share.newsPhoto = function(school, pageName, id, photoI) {
	windowControl.windowOpen('divPhoto', 'index.php?igo=photo&school='+school+'&page_name='+pageName+'&data_id='+id+'&photo_i='+photoI+'&pmod=xml', '', [document.body.scrollLeft, document.body.scrollTop], '');
};

share.facilitiesDetails = function(school, pageName, id) {
	windowControl.windowOpen('divFacilities', 'index.php?igo=details&school='+school+'&page_name='+pageName+'&edid='+id+'&pmod=xml', '', [document.body.scrollLeft, document.body.scrollTop], '');
};

share.photoOpen = function (school, pageName, albumId, photoId) {
	if (share.timer) clearTimeout(share.timer);
	if (document.body.scrollTop < windowControl.windowTopCus) topadd = windowControl.windowTopCus - document.body.scrollTop;
	else topadd = 0;
	windowControl.windowOpen('photo', 'index.php?igo=photo_info&school='+school+'&page_name='+pageName+'&pmod=xml&album_id='+albumId+'&edid='+photoId, '', [document.body.scrollLeft, document.body.scrollTop+topadd], '');
};

share.photoSlide = function (school, pageName, albumId, photoId, slideTimer) {
	if (share.timer) clearTimeout(share.timer);
	this.albumId = albumId;
	this.photoId = photoId;
	this.slideTimer = slideTimer;
	this.school = school;
	this.pageName = pageName;
	XMLHttp.sendReq('POST', 'index.php?igo=photo_slide&school='+school+'&page_name='+pageName+'&pmod=xml&album_id='+albumId+'&edid='+photoId, '', share.photoSlideReturn, 'showSlide', 'send');
};

share.photoSlideReturn = function (returnString) {
	eval(returnString);
	if (share.photoId) {
		for (i=0;i<share.slideAr.length;i++) {
			if (share.slideAr[i]['id'] == share.photoId) {
				share.slideNum = i;
				break;
			}
		}
	} else {
		share.slideNum = 0;
	}
	share.photoSlideInit();
};

share.photoSlideInit = function () {
	if (document.body.scrollTop < windowControl.windowTopCus) topadd = windowControl.windowTopCus - document.body.scrollTop;
	else topadd = 0;
	this.slideTimer = 4;
	windowControl.windowOpen('photo', 'index.php?igo=photo_slide_start&school='+this.school+'&page_name='+this.pageName+'&pmod=xml', '', [document.body.scrollLeft, document.body.scrollTop+topadd], share.photoSlideInitReturn);
};

share.photoSlideInitReturn = function (returnString) {
	if (share.timer) clearTimeout(share.timer);
	share.timer = setTimeout("share.photoSlideStart()", 1000*this.slideTimer);
};

share.photoSlideStart = function (slideTimer) {
	if (share.timer) clearTimeout(share.timer);
	if (slideTimer) {
		this.slideTimer = slideTimer;
	}
	share.timer = setTimeout("share.photoSlideStart()", 1000*this.slideTimer);
	imageInner = "<img src='"+share.slideAr[share.slideNum]['path']+"'";
	if (share.slideAr[share.slideNum]['width']) imageInner += " width='"+share.slideAr[share.slideNum]['width']+"'";
	if (share.slideAr[share.slideNum]['height']) imageInner += " height='"+share.slideAr[share.slideNum]['height']+"'";
	imageInner += " />";
	document.getElementById('slideImage').innerHTML = imageInner;
	content = "";
	if (share.slideAr[share.slideNum]['name']) content += "<p><font class='album_name'>"+share.slideAr[share.slideNum]['name']+"</font></p>";
	if (share.slideAr[share.slideNum]['desc']) content += "<p><font class='album_info'>"+share.slideAr[share.slideNum]['desc']+"</font></p>";
	if (share.slideAr[share.slideNum]['date']) content += "<p><font class='album_info'>"+share.slideAr[share.slideNum]['date']+"</font></p>";
	document.getElementById('slideContent').innerHTML = content;
	share.slideNum++;
	if (share.slideNum >= share.slideAr.length) share.slideNum = 0;
	if (document.images) {
		preloadImage = new Image(); 
		preloadImage.src=share.slideAr[share.slideNum]['path']; 
	}
	buttonHTML = "";
	if (this.slideTimer != 6) {
		buttonHTML += "<img src=\"image/layout1/button_slow_a.gif\" onmouseover=\"this.src='image/layout1/button_slow_b.gif'\" onmouseout=\"this.src='image/layout1/button_slow_a.gif'\" border=\"0\" style=\"cursor:pointer\" onClick=\"share.photoSlideStart(6);\" />&nbsp;";
	} else {
		buttonHTML += "<img src=\"image/layout1/button_slow_b.gif\" border=\"0\" />&nbsp;";
	}
	if (this.slideTimer != 4) {
		buttonHTML += "<img src=\"image/layout1/button_normal_a.gif\" onmouseover=\"this.src='image/layout1/button_normal_b.gif'\" onmouseout=\"this.src='image/layout1/button_normal_a.gif'\" border=\"0\" style=\"cursor:pointer\" onClick=\"share.photoSlideStart(4);\" />&nbsp;";
	} else {
		buttonHTML += "<img src=\"image/layout1/button_normal_b.gif\" border=\"0\" />&nbsp;";
	}
	if (this.slideTimer != 2) {
		buttonHTML += "<img src=\"image/layout1/button_fast_a.gif\" onmouseover=\"this.src='image/layout1/button_fast_b.gif'\" onmouseout=\"this.src='image/layout1/button_fast_a.gif'\" border=\"0\" style=\"cursor:pointer\" onClick=\"share.photoSlideStart(2);\" />&nbsp;";
	} else {
		buttonHTML += "<img src=\"image/layout1/button_fast_b.gif\" border=\"0\" />&nbsp;";
	}
	buttonHTML += "<img src=\"image/layout1/button_pause_play_a.gif\" onmouseover=\"this.src='image/layout1/button_pause_play_b.gif'\" onmouseout=\"this.src='image/layout1/button_pause_play_a.gif'\" border=\"0\" style=\"cursor:pointer\" onClick=\"share.photoSlideStop();\" />";
	//slideButton.innerHTML = buttonHTML;
};

share.photoSlideStop = function () {
	if (share.timer) clearTimeout(share.timer);
	slideButton.innerHTML = "<img src=\"image/layout1/button_pause_play_b.gif\" border=\"0\" style=\"cursor:pointer\" onClick=\"share.photoSlideStart();\" />";
};

share.photoSlideClose = function () {
	if (share.timer) clearTimeout(share.timer);
	windowControl.windowClose('photo');
};

share.hsOpen = function (school, pageName, id, showDiv) {
	XMLHttp.sendReq('POST', 'index.php?igo=open&school='+school+'&page_name='+pageName+'&pmod=xml&edid='+id, '', '', showDiv, 'send');
};

share.hsClose = function (school, pageName, id, showDiv) {
	XMLHttp.sendReq('POST', 'index.php?igo=close&school='+school+'&page_name='+pageName+'&pmod=xml&edid='+id, '', '', showDiv, 'send');
};

share.openWindow = function (url, windowId) {
	if (document.body.scrollTop < windowControl.windowTopCus) topadd = windowControl.windowTopCus - document.body.scrollTop;
	else topadd = 0;
	windowControl.windowOpen(windowId, url, '', [document.body.scrollLeft, document.body.scrollTop+topadd], '');
};