var iLastMonthId, iLastMonthBulletId;

function expandMonth(AMonthId, AMonthBulletId){
	var elm = document.getElementById(AMonthId);
	var img = document.getElementById(AMonthBulletId);
	if (elm && elm.style && elm.style.display){
		if (elm.style.display == "none"){
			elm.style.display = "block";
			img.src = "images/bullet_arrow_down.png";
		}else{
			elm.style.display = "none";
			img.src = "images/bullet_arrow_right.png";
		}
	}
}

function showHiddenCommentForm(AFormDivId, AButtonDivId){
	var rForm = document.getElementById(AFormDivId);
	var rButton = document.getElementById(AButtonDivId);
	if (!rForm){return}
	rForm.style.display = "";
	if (!rButton){return}
	rButton.style.display = "none";
}

function hideHiddenCommentForm(AFormDivId, AButtonDivId){
	var rForm = document.getElementById(AFormDivId);
	var rButton = document.getElementById(AButtonDivId);
	if (!rForm){return}
	rForm.style.display = "none";
	if (!rButton){return}
	rButton.style.display = "";
}

function OnForumIdChangeHandler(AElm){
	if (AElm){
		if (AElm.selectedIndex > 0){
			document.location.href = "default.asp?id=" + AElm.value;
		}
	}
}

function showLeftMenu(){
	var lm = document.getElementById("leftmenu");
	var mtog = document.getElementById("mtoggle");
	lm.style.display = "block";
	mtog.innerHTML = "<input type='button' value='Απόκρυψη μενού' onClick='hideLeftMenu()' style='font-size:10px; width:100px;'>";
}
	
function hideLeftMenu() {
	var lm = document.getElementById("leftmenu");
	var mtog = document.getElementById("mtoggle");
	lm.style.display = "none";
	mtog.innerHTML = "<input type='button' value='Εμφάνιση μενού' onClick='showLeftMenu()' style='font-size:10px; width:100px;'>";
}	

function menuMouseOver(AElm, ALinkId){
	if (AElm && AElm.style.backgroundColor){
		AElm.style.backgroundColor = "#296994";
	}
	if (document.getElementById(ALinkId)){
		document.getElementById(ALinkId).style.color = "white";
	}
}

function menuMouseOut(AElm, ALinkId){
	if (AElm && AElm.style.backgroundColor){
		AElm.style.backgroundColor = "#e7e7ef";
	}
	if (document.getElementById(ALinkId)){
		document.getElementById(ALinkId).style.color = "black";
	}
}

function confirmOffensive(AId, ARedir){
	if (window.confirm("Πατήστε [ΟΚ] για να αναφέρετε στο Capital.gr ότι το μήνυμα έχει προσβλητικό περιεχόμενο ή άσχετο με το θέμα της συγκεκριμένης συζήτησης.")) {
		document.location.href="reportOffensive.asp?id=" + AId.toString() + "&redirto=" + ARedir
	}
}

function deleteLinkVerify(AMessage, AId){
	if (confirm(AMessage)){
		document.location.href = "deleteLink.asp?id=" + AId.toString()
	}
}

function deleteArticleVerify(AMessage, AId){
	if (confirm(AMessage)){
		document.location.href = "deleteArticle.asp?id=" + AId.toString()
	}
}

function unpublishArticleVerify(AMessage, AId){
	if (confirm(AMessage)){
		document.location.href = "unpublishArticle.asp?id=" + AId.toString()
	}
}

function publishArticleVerify(AMessage, AId){
	if (confirm(AMessage)){
		document.location.href = "publishArticle.asp?id=" + AId.toString()
	}
}

function deleteCommentVerify(AMessage, AId, AActive){
	if (confirm(AMessage)){
		document.location.href = "deleteComment.asp?id=" + AId.toString() + "&active=" + AActive.toString()
	}
}

function unpublishCommentVerify(AMessage, AId){
	if (confirm(AMessage)){
		document.location.href = "unpublishComment.asp?id=" + AId.toString()
	}
}

function publishCommentVerify(AMessage, AId){
	if (confirm(AMessage)){
		document.location.href = "publishComment.asp?id=" + AId.toString()
	}
}

function openUploadImageDialog(AId, AElement, AHiddenField, AImageNum) {
	var AValue;
	var retVal = "";
	retVal = openModalDialog("image_upload_frame.asp?id=" + AId + "&imgnum=" + AImageNum.toString(), AValue, 250, 550, false, false);
	if ((retVal != null) && (retVal != "")) {
		AHiddenField.value = retVal.toString();
		AElement.firstChild.src = "files/avatars/" + retVal.toString();
		AElement.style.display = "";
	}else{
		if (AHiddenField.value = "") {
			AHiddenField.value = "";
			AElement.style.display = "none";
		}
	}
}

function deleteImage(AElementToHide, AHiddenField) {
	AElementToHide.firstChild.src = "images/avatar_medium.png";
//	AElementToHide.style.display = "none";
	AHiddenField.value = "";
}

function openUploadImagePopUp(AId, AElement, AHiddenField, AImageNum) {
	var popup = openWindow("upload_image.asp?id=" + AId + "&imgnum=" + AImageNum.toString(), "image_upload", 250, 550, true, true, true);
	zElement = AElement;
	zHiddenField = AHiddenField;
}

function UploadPopUpClosing(AValue) {
	if ((AValue != null) && (AValue != "")) {
		zHiddenField.value = AValue.toString();
		zElement.firstChild.src = "files/avatars/" + AValue.toString() + "?" + Math.random();
		zElement.style.display = "";
	}else{
		if (zHiddenField.value = "") {
			zHiddenField.value = "";
			zElement.style.display = "none";
		}
	}
}

	function submitonce(theform){
		//if IE 4+ or NS 6+
		if (document.all||document.getElementById){
			//Ελέγχω τα πεδία της φόρμας και οταν βρώ το submit το απενεργοποιώ.
			for (i=0;i<theform.length;i++){
				var tempobj=theform.elements[i]
				if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
				//Απενεργοποίηση του element.
				tempobj.disabled=true
			}
		}
	}
	
	//Κάνω focus το πρώτο πεδίο της φόρμας.
	function placeFocus() {
		if (document.forms.length > 0) {
			var field = document.forms[0];
			for (i = 0; i < field.length; i++) {
				if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
					if (!field.elements[i].disabled) {
						if (!field.elements[i].nofocus) {
							document.forms[0].elements[i].focus();
							break;
						}
					}
				}
			}
		}
	}

	function openWindow(AUrl, AName, AHeight, AWidth, AScroll, AResizable, ADependent) {
		if (document.all||document.getElementById){
			var zScroll;
			var zResizable;
			var zDependent;
			if (AScroll){zScroll="yes"}else{zScroll="no"};
			if (AResizable){zResizable="yes"}else{zResizable="no"};
			if (ADependent){zDependent="yes"}else{zDependent="no"};
			return window.open(AUrl, AName, "width=" + AWidth.toString() + ", height=" + AHeight.toString() + ", resizable=" + zResizable + ", scrollbars=" + zScroll + ", dependent=" + zDependent);
		}else{alert("Ο browser που χρησιμοποιείτε είναι παλιάς έκδοσης. Παρακαλώ αναβαθμίστε με την τελευταία έκδοση του Internet Explorer ή το Netscape Navigator.")}
	}


	function mover(AElm){
		if (AElm){
			AElm.style.backgroundColor='#5181af';
			AElm.style.color='white';
		}
	}

	function mout(AElm){
		if (AElm){
			AElm.style.backgroundColor='';
			AElm.style.color='';
		}
	}

	function navigateto(AUrl){
		document.location.href=AUrl;
	}
	
	function DateString()
	{
		var Today = new Date();
		var suffix = "";
		var monthsuffix = "";
		switch (Today.getDay())
		{
			case 1:
				suffix = "Δευτέρα, "; break;
			case 2:
				suffix = "Τρίτη, "; break;
			case 3: 
				suffix = "Τετάρτη, "; break;
			case 4:
				suffix = "Πέμπτη, "; break;
			case 5:
				suffix = "Παρασκευή, "; break;
			case 6:
				suffix = "Σάββατο, "; break;
			case 7:
				suffix = "Κυριακή, "; break;
		};
		switch (Today.getMonth())
		{
			case 0:
				monthsuffix = "Ιανουαρίου"; break;
			case 1:
				monthsuffix = "Φεβρουαρίου"; break;
			case 2: 
				monthsuffix = "Μαρτίου"; break;
			case 3:
				monthsuffix = "Απριλίου"; break;
			case 4:
				monthsuffix = "Μαΐου"; break;
			case 5:
				monthsuffix = "Ιουνίου"; break;
			case 6:
				monthsuffix = "Ιουλίου"; break;
			case 7:
				monthsuffix = "Αυγούστου"; break;
			case 8:
				monthsuffix = "Σεπτεμβρίου"; break;
			case 9:
				monthsuffix = "Οκτωβρίου"; break;
			case 10:
				monthsuffix = "Νοεμβρίου"; break;
			case 11:
				monthsuffix = "Δεκεμβρίου"; break;
		};

		var strDate = suffix + Today.getDate() + " " + monthsuffix + " " + Today.getFullYear();
		return strDate;
	}	
	
	function modalDialogShow_IE(url,width,height) //IE
	{
		return window.showModalDialog(url,window,
			"dialogWidth:"+width+"px;dialogHeight:"+height+"px;edge:Raised;center:Yes;help:No;Resizable:Yes;Maximize:Yes");
	}

	function modalDialogShow_Moz(url,width,height) //Moz
	{
		var left = screen.availWidth/2 - width/2;
		var top = screen.availHeight/2 - height/2;
		activeModalWin = window.open(url, "", "width="+width+"px,height="+height+",left="+left+",top="+top);
		window.onfocus = function(){if (activeModalWin.closed == false){activeModalWin.focus();};};
	}

	var sActiveAssetInput;
	function setAssetValue(v) //required by the asset manager
	{
		document.getElementById(sActiveAssetInput).value = v;
	}
	
	function openAsset(s)
	{
		sActiveAssetInput = s
		if(navigator.appName.indexOf('Microsoft')!=-1)
			document.getElementById(sActiveAssetInput).value=modalDialogShow_IE("filemanager/assetmanager.asp",640,465); //IE	
		else
			modalDialogShow_Moz("filemanager/assetmanager.asp",640,465); //Moz	
	}

	function searchSubmit(AForm, AElmName){
		var sel = document.getElementById(AElmName);
		if (!sel){return false;}
		switch (sel.value){
			case "thisblog":
				AForm.action = "search.asp";
			break;
			default:
				AForm.action = "globalSearch.asp";
		}
		return true;
	}
	
function lockMemberCommentsVerify(AMessage, AId, ANickName){
	if (confirm(AMessage)){
		document.location.href = "manageBannedMembers.asp?action=lock&id=" + AId.toString() + "&nickname=" + escape(ANickName)
	}
}
function unlockMemberCommentsVerify(AMessage, AId, ANickName){
	if (confirm(AMessage)){
		document.location.href = "manageBannedMembers.asp?action=unlock&id=" + AId.toString() + "&nickname=" + escape(ANickName)
	}
}

function mouseOver(elm, color)
{
	elm.style.backgroundColor = color;
}

function toggleBannedMembersList(elmName)
{
	var elm = document.getElementById(elmName);
	if (!elm) { return; }
	if (elm.style.display == "none")
	{
		elm.style.display = "block";
	}
	else
	{
		elm.style.display = "none";
	}
}

function findPosX(obj)
{
	var curleft = 0;
	if(obj.offsetParent)
			while(1) 
			{
				curleft += obj.offsetLeft;
				if(!obj.offsetParent)
					break;
				obj = obj.offsetParent;
			}
	else if(obj.x)
			curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if(obj.offsetParent)
			while(1)
			{
				curtop += obj.offsetTop;
				if(!obj.offsetParent)
					break;
				obj = obj.offsetParent;
			}
	else if(obj.y)
			curtop += obj.y;
	return curtop;
}
	