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.newsPhoto = function (edid, photoI) {
	if (document.body.scrollTop < windowControl.windowTopCus) topadd = windowControl.windowTopCus - document.body.scrollTop;
	else topadd = 0;
	windowControl.windowOpen('showPhoto', 'index.php?igo=photo&pmod=xml&data_id='+edid+'&photo_i='+photoI, '', [document.body.scrollLeft, document.body.scrollTop+topadd], '');
};

share.developPhoto = function (edid, photoI) {
	if (document.body.scrollTop < windowControl.windowTopCus) topadd = windowControl.windowTopCus - document.body.scrollTop;
	else topadd = 0;
	windowControl.windowOpen('showPhoto', 'index.php?igo=photo&pmod=xml&data_id='+edid+'&photo_i='+photoI, '', [document.body.scrollLeft, document.body.scrollTop+topadd], '');
};

share.noticePhoto = function (edid, photoI) {
	if (document.body.scrollTop < windowControl.windowTopCus) topadd = windowControl.windowTopCus - document.body.scrollTop;
	else topadd = 0;
	windowControl.windowOpen('showPhoto', 'index.php?igo=photo&pmod=xml&data_id='+edid+'&photo_i='+photoI, '', [document.body.scrollLeft, document.body.scrollTop+topadd], '');
};

share.movieOpen = function (id, path, thumb, width, height) {
	if (path) this.path = path;
	if (thumb) this.thumb = thumb;
	if (width) this.width = width;
	if (height) this.height = height;
	if (document.body.scrollTop < windowControl.windowTopCus) topadd = windowControl.windowTopCus - document.body.scrollTop;
	else topadd = 0;
	windowControl.windowOpen('showVideo', 'index.php?igo=video_play&data_id='+id+'&path='+path+'&pmod=xml', '', [document.body.scrollLeft, document.body.scrollTop+topadd], share.videoPlay);
};

share.videoPlay = function (returnString) {
	var s1 = new SWFObject("plugin/flashplayer/player.swf","ply",share.width,share.height,"9","#FFFFFF");
	s1.addParam("allowfullscreen","true");
	s1.addParam("allowscriptaccess","always");
	s1.addParam("flashvars","file=../../"+share.path+"&image="+share.thumb+"&autostart=true");
	s1.write("showPlayer");
};


share.photoOpen = function (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?pid=82&igo=photo_info&pmod=xml&album_id='+albumId+'&edid='+photoId, '', [document.body.scrollLeft, document.body.scrollTop+topadd], '');
};

share.photoSlide = function (albumId, photoId, slideTimer) {
	if (share.timer) clearTimeout(share.timer);
	this.albumId = albumId;
	this.photoId = photoId;
	this.slideTimer = slideTimer;
	XMLHttp.sendReq('POST', 'index.php?pid=82&igo=photo_slide&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?pid=82&igo=photo_slide_start&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);
	slideImage.innerHTML = "<img src='"+share.slideAr[share.slideNum]['path']+"' border='0' />";
	content = "";
	if (share.slideAr[share.slideNum]['name']) content += "<font class='album_info_font'>"+share.slideAr[share.slideNum]['name']+"</font><br>";
	if (share.slideAr[share.slideNum]['desc']) content += "<font class='album_name_font'>"+share.slideAr[share.slideNum]['desc']+"</font><br>";
	if (share.slideAr[share.slideNum]['date']) content += "<font class='album_info_font'>"+share.slideAr[share.slideNum]['date']+"</font><br>";
	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.showCmvBox = function (curr, getText) {
	if ((curr) && (getText)) {
		var pos = XMLHttp.getObjectPos(curr);
		showCmv.style.left = pos[0]+60+"px";
		showCmv.style.top = pos[1]+20+"px";
		showCmv.style.display = "";
		showCmv.innerHTML = "<table border='0' cellpadding='0' cellspacing='10' width='280'><tr><td width='280' class='cmv_box_font'>"+getText+"</td></tr></table>";
	}
};

share.hideCmvBox = function () {
	showCmv.style.display = "none";
};

share.descShow = function (curr, height, name) {
	showDesc.style.display = "block";
	showDescName.innerHTML = name;
	var pos = XMLHttp.getObjectPos(curr);
	showDesc.style.left = pos[0]+height+"px";
	showDesc.style.top = pos[1]+height+"px";
};

share.descHigh = function () {
	showDesc.style.display = "none";
};
