// mouse event
function mouseOver(obj)
{
	obj.style.cursor = 'hand';
}

function showUnderline(obj)
{
	obj.className = obj.className + "_underline";
}

function hideUnderline(obj)
{
	obj.className = obj.className.replace("_underline","");
}


// messages functions
function showMessage(nMessageSeq, strMessageID)
{
	//if the message is already open we will close it
	if (document.all["body_" + nMessageSeq].className == "display_inline")
	{
		hideMessage(nMessageSeq, strMessageID);
		return;
	}
	strReplyMessagesSeq += nMessageSeq + "|";
	strReplyMessagesID += strMessageID + "|";
	document.all["title_" + nMessageSeq].className = document.all["title_" + nMessageSeq].className.replace("msg_close","msg_open");
	document.all["body_" + nMessageSeq].className = "display_inline";
	document.all["buttons_" + nMessageSeq].className = "display_inline";
		
	markingAsReadMessage(nMessageSeq,strMessageID);
}

function hideMessage(nMessageSeq, strMessageID)
{
	strReplyMessagesSeq.replace("|" + nMessageSeq + "|","|");
	strReplyMessagesID.replace("|" + strMessageID + "|","|");
	
	document.all["title_" + nMessageSeq].className = document.all["title_" + nMessageSeq].className.replace("msg_open","msg_close");
	document.all["body_" + nMessageSeq].className = "display_none";
	document.all["buttons_" + nMessageSeq].className = "display_none";
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function changeActivityStatus()
{
	var oAll							= window.document.all;
	var checkboxes						= window.document.getElementsByTagName("INPUT");
	var	isChecked						= false;
	
	if(oAll.activityBox.value=="0")	return;	
	
	try
	{
		var xmlDoc						= new ActiveXObject("Msxml2.DOMDocument");
		var	root						= xmlDoc.createElement("content"); 
		var element, el;
					
			xmlDoc.appendChild(root);
			
			element					= xmlDoc.createElement("forumid");
			element.text			= oAll.talkbackForum.value;
			root.appendChild(element);
			
			element					= xmlDoc.createElement("status");
			element.text			= oAll.activityBox.value;
			root.appendChild(element);
			
			element					= xmlDoc.createElement("messages");
			root.appendChild(element);
		
		for(var j=0; j<checkboxes.length; j++)
		{
			if(checkboxes[j].type=="checkbox")
			{
				if(checkboxes[j].activity=="true" && checkboxes[j].checked)
				{
					el				= xmlDoc.createElement("message");
					el.text			= checkboxes[j].id.substring(4);
					element.appendChild(el);
					isChecked		= true;
				}
			}
		}

		var xmlpath					= "ChangeStatus.xml.aspx";

		if(isChecked)
		{
//				alert(xmlDoc.xml);
				
				postXMLData(xmlpath, xmlDoc);
				
				alert(window.result);
		}
	}
	catch(e)
	{
		alert("changeActivityStatus() \n"+e.description);
	}
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function changeApprovalMode()
{
	var oAll							= window.document.all;
	try
	{
		var xmlDoc						= new ActiveXObject("Msxml2.DOMDocument");
		var	root						= xmlDoc.createElement("content"); 
		var element;
					
			xmlDoc.appendChild(root);
			
			element					= xmlDoc.createElement("forumid");
			element.text			= oAll.talkbackForum.value;
			root.appendChild(element);
			
		var xmlpath					= "ChangeView.xml.aspx";

//			alert(xmlDoc.xml);
			
			postXMLData(xmlpath, xmlDoc);
			
			if(window.result!="")	throw new Error(window.result);
			
			window.location.reload(true);
	}
	catch(e)
	{
		alert("changeApprovalMode() \n"+e.description);
	}
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function Message(nForumID,nID,strLang,strAction)
{
	window.open("Message.aspx?fid=" + nForumID + "&id=" + nID + "&lang=" + strLang + "&action=" + strAction,"message","width=563,height=410"); 
}

function deleteMessage(nForumID,nID)
{
	window.open("DeleteMessage.aspx?fid=" + nForumID + "&id=" + nID,"deleteMessage","width=536,height=249"); 
}

function printMessage(nForumID,nID,strLang)
{
	window.open("PrintMessage.aspx?fid=" + nForumID + "&id=" + nID + "&lang=" + strLang,"printMessage","width=578,height=420,scrollbars=yes"); 
}

function sendMessage(nForumID,nID,strLang)
{
	window.open("SendMessage.aspx?fid=" + nForumID + "&id=" + nID + "&lang=" + strLang,"sendMessage","width=578,height=345,scrollbars=yes"); 
}

function systemMessage(strMessageType,strLang)
{
	window.open("SystemMessage.aspx?type=" + strMessageType + "&lang=" + strLang,strMessageType,"width=535,height=420,scrollbars=yes"); 
}

function openingMessage(strLang,nForumID)
{
	window.open("OpeningMessage.aspx?lang=" + strLang + "&fid=" + nForumID,"openingMessage","width=534,height=339,scrollbars=yes"); 
}

function aboutManager(strLang,nForumID)
{
	window.open("AboutManager.aspx?lang=" + strLang + "&fid=" + nForumID,"openingMessage","width=530,height=400,scrollbars=yes,status=no "); 
}

function editOpeningMessage(strLang,nForumID)
{
	window.open("EditOpeningMessage.aspx?lang=" + strLang + "&fid=" + nForumID,"editOpeningMessage","width=534,height=399,scrollbars=yes"); 
}

function editAboutManager(strLang,nForumID)
{
	window.open("EditAboutManager.aspx?lang=" + strLang + "&fid=" + nForumID,"editOpeningMessage","width=533,height=350,scrollbars=yes"); 
}

function deleteOpeningMessage(strLang,nForumID)
{
	window.open("DeleteOpeningMessage.aspx?lang=" + strLang + "&fid=" + nForumID,"deleteOpeningMessage","width=530,height=310"); 
}

function deleteAboutManager(strLang,nForumID)
{
	window.open("DeleteAboutManager.aspx?lang=" + strLang + "&fid=" + nForumID,"deleteOpeningMessage","width=536,height=250"); 
}

function ForumMembers(nForumID,strLang)
{
	window.open("ForumMembers.aspx?fid=" + nForumID + "&lang=" + strLang,"message","width=652,height=429,scrollbars=yes"); 
}

// paging
function paging(nPageNo,nForumID, strLang)
{
	location.href = String(document.location).split("?")[0] + "?fid=" + nForumID + "&page=" + nPageNo + "&lang=" + strLang;
}


// hide and show reply messages
var actionReply = getCookieValue("KSForumsReply"); 
if (actionReply == "") actionReply = "show";
function hideAndShowReply()
{
	if (actionReply == "show")
	{
		actionReply = "hide";
		document.all.linkSubjectsOnly.className = document.all.linkSubjectsOnly.className.replace(" display_inline"," display_none");
		document.all.linkSubjectsAndReply.className = document.all.linkSubjectsAndReply.className.replace(" display_none"," display_inline");
	}
	else
	{
		actionReply = "show";
		document.all.linkSubjectsAndReply.className = document.all.linkSubjectsAndReply.className.replace(" display_inline"," display_none");
		document.all.linkSubjectsOnly.className = document.all.linkSubjectsOnly.className.replace(" display_none"," display_inline");
	}
	
	closeAllReplyMessages(actionReply);
	
	var trs = document.all.tags('TR');
	for (var i=0 ; i<trs.length ; i++)
	{
		var tr = trs.item(i);
		if (tr.IsReply && tr.IsReply.indexOf("True") > -1)
		{
			if (actionReply == "hide")
			{
				tr.className = tr.className.replace(" display_inline"," display_none");
			}
			else
			{
				tr.className = tr.className.replace(" display_none"," display_inline");
			}
		}
	}
	
	var date = new Date();
	date.setMonth(date.getMonth()+1);
	document.cookie = "KSForumsReply=" + actionReply + "; expires=" + date.toGMTString();
}


// marking read messages
var actionRead = getCookieValue("KSForumsRead"); 
if (actionRead == "") actionRead = "|";
function markingAsReadMessage(nMessageSeq, strMessageID)
{
	// display the 'read' image
	document.all["imgRead_" + nMessageSeq].className = document.all["imgRead_" + nMessageSeq].className.replace('none','inline');
	
	// chek if the current messageid is not allready marked
	if (actionRead.indexOf("|" + strMessageID + "|") > -1) return;
	
	// save the cuurent messageid as read
	actionRead += strMessageID + "|";
	
	// update cookie
	var date = new Date();
	date.setMonth(date.getMonth()+1);
	document.cookie = "KSForumsRead=" + actionRead + "; expires=" + date.toGMTString();
}

// get cookies values
function getCookieValue(strCookieName)
{
	var arrCookies = document.cookie.split("; ");
	for (var i=0 ; i < arrCookies.length ; i++)
	{
		var arrCookie = arrCookies[i].split("=");
		if (arrCookie[0] == strCookieName) 
		{
			return unescape(arrCookie[1]);
		}
	}
}	

var strReplyMessagesSeq = "|";
var strReplyMessagesID = "|";
function closeAllReplyMessages(action)
{
	var arrReplyMessagesSeq = strReplyMessagesSeq.split("|");
	var arrReplyMessagesID = strReplyMessagesID.split("|");
	
	if (action == "hide")
	{
		for (var i=1 ; i<arrReplyMessagesSeq.length-1 ; i++)
		{
			hideMessage(arrReplyMessagesSeq[i],arrReplyMessagesID[i]);
		}
	}
	else
	{
		strReplyMessagesSeq = "|";
		strReplyMessagesID = "|";
		
		for (var i=1 ; i<arrReplyMessagesSeq.length-1 ; i++)
		{
			showMessage(arrReplyMessagesSeq[i],arrReplyMessagesID[i]);
		}
	}
}

// messages functions
function initMessage()
{
	/*if (document.all.txtName == null) return;
	
	if (document.all.txtName.readOnly == true)
	{
		document.all.txtSubject.focus();
	}
	else
	{
		document.all.txtName.focus();
	}
	*/	
	
	//messageAction(document.all.listAction.value);
}

function cancel()
{
	self.close();
}

function doDelete()
{
	document.frm.btnSendServer.click();		
}

/////////////////////////////////////////////////////////////////////////////////////

function doSubmit()
{
	var txtSubject = document.frm.txtSubject.value;
	var txtEmail = document.frm.txtEmail.value;
	var txtFile = document.frm.txtFile.value;	
	var txtFileSize = document.frm.txtFileSize.value;
	
	var fWords = checkForbiddenWords(txtSubject);
	if (fWords.length > 0)
	{
		alert("אינך יכול/ה להשתמש במילים: " + fWords.join(" ,"));
		return;
	}
	
	var sStr = iframeWindow.document.body.innerText;
	var fWords = checkForbiddenWords(sStr);
	if (fWords.length > 0)
	{
		alert("אינך יכול/ה להשתמש במילים: " + fWords.join(" ,"));
		return;
	}
	
	var nStatusConfirmed = document.frm.chkStatusConfirmed!=null&&document.frm.chkStatusConfirmed.checked?document.frm.chkStatusConfirmed.value:0;
	var nStatusDelete = document.frm.chkStatusDelete!=null&&document.frm.chkStatusDelete.checked?document.frm.chkStatusDelete.value:0;
	var nStatusArchive = document.frm.chkStatusArchive!=null&&document.frm.chkStatusArchive.checked?document.frm.chkStatusArchive.value:0;
	var nStatusLocked = document.frm.chkStatusLocked!=null&&document.frm.chkStatusLocked.checked?document.frm.chkStatusLocked.value:0;
	var nStatusStickyPost = document.frm.chkStatusStickyPost!=null&&document.frm.chkStatusStickyPost.checked?document.frm.chkStatusStickyPost.value:0;
	var txtNewStatus = parseInt(nStatusConfirmed) + parseInt(nStatusDelete) + parseInt(nStatusArchive) + parseInt(nStatusLocked) + parseInt(nStatusStickyPost);
	document.frm.txtNewStatus.value = txtNewStatus;

	if (trim(txtSubject) == "")
	{
		alert("חובה להזין נושא");
		return;
	}
	
	var nameRgExp = /[./\\<>\#\$%^&*\=;{\[\]]/g;	//not legal characters
	if (nameRgExp.test(txtSubject))
	{
		alert("שדה נושא לא תקין");
		return;
	}
	
	if (trim(document.frm.txtName.value)!= "" && nameRgExp.test(document.frm.txtName.value))
	{
		alert("שדה שם לא תקין");
		return;
	}
	
	if (!isLegalEmail(txtEmail))
	{
		alert("כתובת דואר אלקטרוני אינה תקנית");
		return;
	}

	//var reOpenTag = new RegExp("<","ig");
	//var reCloseTag = new RegExp(">","ig");
	var reOpenTag = "<";
	var reCloseTag = ">";

	//document.frm.txtContent.innerHTML = iframeWindow.document.body.innerHTML.replace(reOpenTag,"{openTag}").replace(reCloseTag,"{closeTag}");
	//document.frm.txtContent.innerHTML = iframeWindow.document.body.innerHTML.split(reOpenTag).join("{openTag}").split(reCloseTag).join("{closeTag}").split("'").join("`");
	//alert('iframeWindow.document.body.innerHTML 1= \n' + iframeWindow.document.body.innerHTML);
	var orgHTML = iframeWindow.document.body.innerHTML;
	txtSubject = txtSubject.split("'").join("`")
	iframeWindow.document.body.innerHTML = iframeWindow.document.body.innerHTML.split("<P>").join("{n}").split("'").join("`").split("</P>").join(""); //.split(reOpenTag).join("{openTag}").split(reCloseTag).join("{closeTag}").split("'").join("`"); //.split("'").join("`")
	//alert('iframeWindow.document.body.innerHTML 2= \n' + iframeWindow.document.body.innerHTML);
	document.frm.txtContent.innerText = iframeWindow.document.body.innerText;
	
	iframeWindow.document.body.innerHTML = orgHTML;
	 	
	//alert('iframeWindow.document.body.innerText 3= \n' + iframeWindow.document.body.innerText);
	if (txtFile != "" && txtFileSize == "")
	{
		// upload submit
		var sel = document.all.item('iframe_upload').contentWindow.document.all.item('frm_upload').elements('upload:UploadBtn');
		sel.select();
		sel.click();
		
		continueSubmit();
	}
	else
	{
		document.frm.btnSendServer.click();		
	}
}
/*
function trim(str)
{
	try {
		return str.replace(/^\s+|\s+$/g,'');
	}
	catch (e) {
		return str;
	}
}
*/
function doMailSubmit()
{
	var txtEmail = document.frm.txtToEmail.value;
	
	if (txtEmail == "")
	{
		alert("חובה להזין כתובת דואר אלקטרוני");
		return;
	}
	
	if (!isLegalEmail(txtEmail))
	{
		alert("כתובת דואר אלקטרוני אינה תקנית");
		return;
	}

	document.frm.btnSendServer.click();		
}

var nSubmitCounter = 0;
function continueSubmit()
{
	var prefix = document.all.item('iframe_upload').contentWindow.document.all.item('frm_upload').elements('upload:Prefix');
	
	if (prefix.value == "" && nSubmitCounter++ < 10000)
	{
		setTimeout("continueSubmit()",10);
	}
	else
	{
	
		var txtFile = document.frm.txtFile.value;	
		document.frm.txtFilePrefix.value = prefix.value; 
		
		var ext = String(txtFile).toLowerCase().split(".");
		ext = ext[ext.length-1];
				
		if (!(ext != 'jpg' && ext != 'jpeg' && ext != 'gif' && ext != 'bmp' && ext != 'png' && ext != 'tif'))
		{
			// get file size
			var imageObj = document.createElement('IMG');
					
			imageObj.onload = function () 
			{		
				document.frm.txtFileSize.value = imageObj.fileSize;
				if (imageObj.fileSize > 250000)
				{
					alert("הקובץ שאת/ה מנסה לצרף גדול מדי");
					return;
				}
				else
					document.frm.btnSendServer.click();				
			}
			imageObj.src = txtFile;
		}
		else
		{
			document.frm.txtFileSize.value = 10;
			document.frm.btnSendServer.click();	
		}
	}
}

/////////////////////////////////////////////////////////////////////////////////////

function doEditManagerMessageSubmit()
{
	var txtFile = document.frm.txtFile.value;	
	
	if (txtFile != "")
	{
		// upload submit
		var sel = document.all.item('iframe_upload').contentWindow.document.all.item('frm_upload').elements('upload:UploadBtn');
		sel.select();
		sel.click();
		
		continueEditOpeningMessageSubmit();
	}
	else
	{
		document.frm.btnSaveServer.click();		
	}
}

function doEditOpeningMessageSubmit()
{
	var txtManagerName = document.frm.txtManagerName.value;
	var txtFile = document.frm.txtFile.value;	
	
	if (txtManagerName == "") 
	{
		alert("חובה להזין את שם מנהל הפורום");
		return;
	}
	
	//var reOpenTag = new RegExp("<","ig");
	//var reCloseTag = new RegExp(">","ig");
	var reOpenTag = "<";
	var reCloseTag = ">";

	//document.frm.txtContent.innerHTML = iframeWindow.document.body.innerHTML.replace(reOpenTag,"{openTag}").replace(reCloseTag,"{closeTag}");
	document.frm.txtContent.innerHTML = iframeWindow.document.body.innerHTML.split(reOpenTag).join("{openTag}").split(reCloseTag).join("{closeTag}").split("'").join("`");
	
	if (txtFile != "")
	{
		// upload submit
		var sel = document.all.item('iframe_upload').contentWindow.document.all.item('frm_upload').elements('upload:UploadBtn');
		sel.select();
		sel.click();
		
		continueEditOpeningMessageSubmit();
	}
	else
	{
		document.frm.btnSaveServer.click();		
	}
}

var nEditOpeningSubmitCounter = 0;
function continueEditOpeningMessageSubmit()
{
	var prefix = document.all.item('iframe_upload').contentWindow.document.all.item('frm_upload').elements('upload:Prefix');
	
	if (prefix.value == "" && nEditOpeningSubmitCounter++ < 100)
	{
		setTimeout("continueEditOpeningMessageSubmit()",10);
	}
	else
	{
	
		var txtFile = document.frm.txtFile.value;	
		document.frm.txtFilePrefix.value = prefix.value; 
		document.frm.btnSaveServer.click();				
	}
}

function uploadFile_Click()
{
	// upload browse
	var sel = document.all.item('iframe_upload').contentWindow.document.all.item('frm_upload').elements('upload:UploadFile');
	sel.select();
	sel.click();
	document.frm.txtFile.value = sel.value; 
	if (document.frm.txtFileSize)
	{
		document.frm.txtFileSize.value = "";
	}
}

function isLegalEmail(email)
{	
	if (email == "") return true;
	
	var email = new String (email);
	email = email.split("@");
	
	if (email.length != 2) return false;
	if (email[0] == "") return false;
	if (email[1] == "") return false;	
	if (email[1].split(".").length != 2 && email[1].split(".").length != 3) return false;	
	
	for (var i=0 ; i<email[1].split(".").length ; i++)
		if (email[1].split(".")[i] == "")
			return false;

	return true;
}
	
/*function addAttachment()
{
	document.all.txtFile.value = "test.gif";
}*/

function changeScopSearch(obj)
{
	if (obj.id == "ucForumsSearch_radioCats")
	{
		document.all.ucForumsSearch_listSearchForumsScop[0].selected = true;
		document.all.ucForumsSearch_listSearchForumsScop.className = document.all.ucForumsSearch_listSearchForumsScop.className.replace("inline","none");
		document.all.ucForumsSearch_listSearchCatsScop.className = document.all.ucForumsSearch_listSearchCatsScop.className.replace("none","inline");	
	}
	else
	{
		document.all.ucForumsSearch_listSearchCatsScop[0].selected = true;
		document.all.ucForumsSearch_listSearchForumsScop.className = document.all.ucForumsSearch_listSearchForumsScop.className.replace("none","inline");
		document.all.ucForumsSearch_listSearchCatsScop.className = document.all.ucForumsSearch_listSearchCatsScop.className.replace("inline","none");		
	}	
}

function search(strLang)
{
	// query string
	var strQuery = "lang=" + strLang;
	
	// get forum id
	var nForumid = (document.all["ucForumsSearch:listSearchForumsScop"]?document.all["ucForumsSearch:listSearchForumsScop"].value:0);
	var nCatid = (document.all["ucForumsSearch:listSearchCatsScop"]?document.all["ucForumsSearch:listSearchCatsScop"].value:0);
	strQuery += "&fid=" + nForumid;
	strQuery += "&catid=" + nCatid;
	
	// get phrase
	var strPhrase = document.all["ucForumsSearch:txtPhrase"].value;
	strQuery += "&phrase=" + strPhrase;
	
	// advanced search
	var strClassName = document.all.ucForumsSearch_divAdvancedSearch.className;
	if (strClassName.indexOf("inline") > -1)
	{
		// get "from" date
		var nFromDay = document.all["ucForumsSearch:ucFromDate:listDay"].value;
		var nFromMonth = document.all["ucForumsSearch:ucFromDate:listMonth"].value;
		var nFromYear = document.all["ucForumsSearch:ucFromDate:listYear"].value;
		var dFromDate = nFromDay + "/" + nFromMonth + "/" + nFromYear;
		var nFromDate = nFromYear + (nFromMonth<10?"0"+nFromMonth:nFromMonth) + (nFromDay<10?"0"+nFromDay:nFromDay);
		strQuery += "&fromdate=" + dFromDate;
		
		// get "to" date
		var nToDay = document.all["ucForumsSearch:ucToDate:listDay"].value;
		var nToMonth = document.all["ucForumsSearch:ucToDate:listMonth"].value;
		var nToYear = document.all["ucForumsSearch:ucToDate:listYear"].value;
		var dToDate = nToDay + "/" + nToMonth + "/" + nToYear;
		var nToDate = nToYear + (nToMonth<10?"0"+nToMonth:nToMonth) + (nToDay<10?"0"+nToDay:nToDay);
		strQuery += "&todate=" + dToDate;
		
		if (nFromDate > nToDate)
		{
			alert("'מתאריך' צריך להיות קטן מ-'עד תאריך'")
			return;
		}	
		
		// get search combination
		var strSearchCombination = document.all["ucForumsSearch:listSearchCombination"].value;
		strQuery += "&combination=" + strSearchCombination;
	}
	
	location.href = "SearchResults.aspx?" + strQuery;
	
	
}

// advanced search
function advancedSearch()
{
	var strClassName = document.all.ucForumsSearch_divAdvancedSearch.className;
	
	if (strClassName.indexOf("none") > -1)
	{
		document.all.ucForumsSearch_divAdvancedSearch.className = strClassName.replace("none","inline");
	}
	else
	{
		document.all.ucForumsSearch_divAdvancedSearch.className = strClassName.replace("inline","none");
	}	
}

// open user details popup
function openUserDetails(strUserName)
{
	window.open("UserDetails.aspx?username=" + strUserName,"popup_" + strUserName,"width=515,height=270,scrollbars=yes");
}

// in the user details pop, try again sending mail
function tryAgain()
{
	document.all.UserSendMailTab_tblForm.className = document.all.UserSendMailTab_tblForm.className.replace("display_none","display_inline");
	document.all.UserSendMailTab_tblAfterSubmit.className = document.all.UserSendMailTab_tblAfterSubmit.className.replace("display_inline","display_none");
	document.all.UserSendMailTab_sendTD.className = document.all.UserSendMailTab_sendTD.className.replace("display_none","display_inline");
}

function categoriesListUrl(strLang)
{
	location.href = "ForumsList.aspx?lang=" + strLang;
}

function checkForbiddenWords(sText)
{
	var oReg = new RegExp("(^|\\s)(" + words.join("|") + ")($|\\s)","img");
			
	var arr = [];
	function collect(part1)
	{
		var sPart = trim(part1);
		if(!collect.hash) collect.hash = {};
		
		if(!collect.hash[sPart])
		{
			collect.hash[sPart]=true
			arr[arr.length]=sPart;
		}
		
		return part1;
	}
	
	sText.replace(oReg,collect);
	return arr;
}


//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function isPhone(vle)
{
	
     vle		= trim(vle);
   
    if(vle=="")							return true;
	
	if(vle.replace(/[0-9 -]*/g,"")=="") return true;
	//if(vle.replace(/[0-9 ]*/g,"")=="")return true;
	                                    return false;
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function dbg(O)
{
	if(typeof(O)=="string"||typeof(O)=="number"){alert(O);return;}
	
	var arr	=	[];
	
	for(var o in O)
	{
		if(typeof(O[o])=="string"||typeof(O[o])=="number")
		{
				arr.push(o+"='"+O[o]+"' ");
		}
		else	arr.push(o);
	}
	arr.sort();
	alert(arr.join("; "));
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function CInt(vle,dflt)
{
    var str		= trim(vle);
    var strd	= trim(dflt);
    
	var intg	= parseInt(str,10);
	var intd	= parseInt(strd,10);
	
		intd	= (isNaN(intd)?0:intd);
    
	return (isNaN(intg)?intd:intg);
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function CStr(vle,dflt)
{
       dflt += "";
    if(dflt=="undefined") dflt = "";
    if(dflt=="null")      dflt = "";

       vle += "";
    if(vle=="undefined") return dflt;
    if(vle=="null")      return dflt;
    
    return vle;
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function trim(vle)
{
        var trm = CStr(vle);
    return  trm.replace(/(^\s*)|(\s*$)/g, "");
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function postXMLData(xmlpath, xmldoc)
{
	try
	{
		loading(xmlpath);
		
//		alert(xmldoc.xml);
		
		var xmlhttp						= new ActiveXObject("Microsoft.XMLHTTP");
			xmlhttp.onreadystatechange	= HandleStateChange;
			xmlhttp.Open("POST", xmlpath, false);
			xmlhttp.setRequestHeader("Content-Type", "text/xml; charset='utf-8' ");
			xmlhttp.Send(xmldoc);
	
		done();
	}
	catch (e){ws("postXMLData() "+e.description);}
	
			xmlhttp		= null;

	return;

//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	function HandleStateChange()
	{
//		alert(xmlhttp.readyState);
		try
		{
			window.result		= "";
			
			if(xmlhttp.readyState==4)
			{
				window.result	= xmlhttp.responseText;

				if(window.result)
				{
					if(window.result.toLowerCase().indexOf("error")>=0)	throw new Error(window.result);
					else												done();
				}
			}
		}	
		catch(e)
		{
			throw new Error("HandleStateChange() "+e.description);
		}
	}
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function loading(arg)	{	window.status	= arg;			}
function done()			{	window.status	= "Done";		}		
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

/*********************/
/* top
/*********************/

function top_mouseoverButton(obj)
{
	obj.style.cursor = 'hand';
	obj.src = eval(obj.id + "_On").src; 
}

function top_mouseoutButton(obj)
{
	obj.src = eval(obj.id + "_Off").src; 
}

function top_mousepressButton(obj, nForumID)
{
	location.href = "ForumsList.aspx?cid=" + nForumID;
}