var EditorWindow 	= null;
// -----------------------------------------------------------------
function getXML(url, vars, disable, show, result)
{
	var AjaxRequest = new AjaxPtt(JSSITEURL + url,'POST');
	AjaxRequest.setVariable('resultel',result);
	AjaxRequest.setVariable('type','X');
	AjaxRequest.setVariable('onStart',
		function (){
			SetDisable(disable,1);
			SetVisible(show,1);
		}
	);
	AjaxRequest.setVariable('onComplete',
		function (){
			SetDisable(disable,0);
			SetVisible(show,0);
		}
	);
	if(vars) AjaxRequest.getVars(vars);
	AjaxRequest.Post();
	return false;
}
// -----------------------------------------------------------------
function getHTML(url, vars, hide, show, result)
{
	var AjaxRequest = new AjaxPtt(JSSITEURL + url,'POST');
	AjaxRequest.setVariable('resultel',result);
	AjaxRequest.setVariable('onStart',
		function (){
			SetVisible(hide,0);
			SetVisible(show,1);
		}
	);
	AjaxRequest.setVariable('onComplete',
		function (){
			SetVisible(hide,1);
			SetVisible(show,0);
		}
	);
	if(vars) AjaxRequest.getVars(vars);
	AjaxRequest.Post();
	return false;
}
// -----------------------------------------------------------------
function getCONSOLE(url, vars)
{
	var AjaxRequest = new AjaxPtt(JSSITEURL + url,'GET');
	AjaxRequest.setVariable('resultel','CONSOLEMESSAGE');
	AjaxRequest.setVariable('onStart', function (){ 
												 SetVisible('CONSOLEDIV',1);
												 SetVisible('LOADDIV',1) 
												 });
	AjaxRequest.setVariable('onComplete',function (){SetVisible('LOADDIV',0)});
	if(vars) AjaxRequest.getVars(vars);
	AjaxRequest.Post();
}
// -----------------------------------------------------------------
function SetVisible(obj, visible){
	var el = document.getElementById(obj);
	if(el) el.style.display = visible ? 'block' : 'none';
}
// -----------------------------------------------------------------
function SetDisable(obj, dis){
	var el = document.getElementById(obj);
	if(el) el.disabled = dis ? true : false;
}
// -----------------------------------------------------------------
function Editor(type, object, action){
	if(EditorWindow == null){
	EditorWindow = window.open(JSSITEURL+'index.php?page=bbeditor&type='+type+'&object='+object+'&action='+action,	'',	'width=510, height=320, resizable=1, toolbars=0, scrollbars=1');
	} else {
		EditorWindow.ReferenceObject = object;
	}
	EditorWindow.focus();
}
// -----------------------------------------------------------------
function WriteValue(object, value){
	document.getElementById(object).value = value;
}
// -----------------------------------------------------------------
function ResetForm(object){
	var el = document.getElementById(object);
	el.reset();
	el.elements[0].focus();
}
// -----------------------------------------------------------------
function ReadValue(object){
	return document.getElementById(object).value;
}
// -----------------------------------------------------------------
function PopUp(url, wt, ht){
	window.open(JSSITEURL+url,'',
	'width='+wt+', height='+ht+', resizable=1, toolbars=0, scrollbars=1');
}
// -----------------------------------------------------------------
function SrRevwrite(el){
	var RTR = '';
	RTR += '&q=' + encodeURI(el.q.value);
	RTR += '&pr=' + encodeURI(el.pr.value);
	RTR += '&ys=' + encodeURI(el.ys.value);
	RTR += '&ye=' + encodeURI(el.ye.value);
	location.href = JSSITEURL+'Search/'+RTR+'&mode=1';
	return false;
}
// -----------------------------------------------------------------
function SrLinkRevwrite(el){
	var RTR = '';
	RTR += '&author=' + encodeURI(el.author.value);
	RTR += '&type=' + encodeURI(el.type.value);
	location.href = JSSITEURL+'SearchLink/'+RTR;
	return false;
}
// -----------------------------------------------------------------
function checkPM(){
	var AjaxRequest = new AjaxPtt(JSSITEURL + '?page=pm&p=check','GET');
	AjaxRequest.setVariable('type','X');
	AjaxRequest.setVariable('onStart', function (){});
	AjaxRequest.setVariable('onComplete',function (){});
	AjaxRequest.Post();
}
// -----------------------------------------------------------------
if( ISUSER ) setInterval('checkPM()', 40000);
if( ISUSER ) setTimeout('checkPM()', 5000);
// -----------------------------------------------------------------
function PopPm(num, id){
	document.getElementById('CONSOLEMESSAGE').innerHTML = 'You have got '+num+' new messages<br /><br />Would you like to read now ? <br /><br /><input type="button" value="YES" onclick="SetVisible(\'CONSOLEDIV\',0);SetVisible(\'User_Block\', 1);getHTML(\'?page=pm&p=read&id='+id+'\', null, \'user_wrapper\', \'loading\' , \'user_wrapper\')"/> <input type="button" value="NO" onclick="SetVisible(\'CONSOLEDIV\',0)"/><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="1" height="1" id="bip" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+JSSITEURL+'template/images/bip.swf" /><param name="quality" value="high" /><embed src="'+JSSITEURL+'template/images/bip.swf" quality="high" width="1" height="1" name="bip" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	SetVisible('CONSOLEDIV',1);
}
// -----------------------------------------------------------------
function writeCookie(name, val){
  var expire = null;
  expire = new Date((new Date()).getTime() + 8760 * 3600000);
  expire = "; expires=" + expire.toGMTString();
  document.cookie = name +'=' + val + expire + '; path=/';
}
// -------------------------------------------------------------------
function selectAll(formObj, obj) {
	for (var i=0;i < formObj.length;i++){
	  fldObj = formObj.elements[i];
	  if (fldObj.type == 'checkbox'){ 
	  	if(fldObj != obj){
			fldObj.checked = obj.checked;
			fldObj.onchange();
		}
	  }
	}
}
// -----------------------------------------------------------------
function checkRow(el, id, class){
	document.getElementById('row'+id).className = ( el.checked ) ? 'checked' : class;
}
// -----------------------------------------------------------------
function getChecked(formObj) {
	var values = new Array;
	for (var i=0;i < formObj.length;i++){
		fldObj = formObj.elements[i];
		if (fldObj.type == 'checkbox' && fldObj.checked){ 
			values.push(fldObj.value);
		}
  	}
	return values.join(',');
}