//  ###  - Comment -  ###  //
function addComment(){
	sh('loading',1);
	hi('commentForm',1);
	if(typeof(tinyMCE)!='undefined'){
		tinyMCE.triggerSave(false, false);
		tinyMCE.execCommand('mceSetContent',false, '');
	}
	else gE('tinymce').value = '';
	load_newComment(xajax.getFormValues('cform'));
}
function editComment(id){
	comment = gE('c_'+id).innerHTML;
	ta = document.createElement('textarea');
	ta.style.height='70px';
	ta.style.width ='95%';
	ta.id = 'commenteditor'+id;
	ta.value = comment;
	ta.onblur = function(){
		load_updateComment(id,this.value);
		gE('c_'+id).innerHTML = this.value;
	}
	gE('c_'+id).innerHTML = '';
	gE('c_'+id).appendChild(ta);
}
function deleteComment(id){load_deleteComment(id);}
function editHF(str){
	html = gE('sub'+str+'er').innerHTML;
	ta = document.createElement('textarea');
	ta.style.height='70px';
	ta.style.width ='95%';
	ta.value = html;
	if(str=='head') type = 1;
	else if(str=='foot') type = 2;
	else if(str=='info') type = 3;
	else if(str=='css') type = 5;
	else if(str=='addr') type = 8;
	ta.onblur = function(){
		load_updateCompany(this.value,type);
		gE('sub'+str+'er').innerHTML = this.value;
	}
	gE('sub'+str+'er').innerHTML = '';
	gE('sub'+str+'er').appendChild(ta);
}
function editCss(){
	html = gE('csspanel').innerHTML;
	html = html.replace(/<style type=\"text\/css\">/gi,'');
	html = html.replace(/<\/style>/gi,'');
	ta = document.createElement('textarea');
	ta.style.width ='100%';
	ta.id = 'tinymce';
	ta.value = html;
	ta.onblur = function(){
		load_updateCompany(this.value,5);
		gE('csspanel').innerHTML = '<style type="text/css">'+this.value+'</style>';
		gE('csseditor').style.display='none';
	}
	ta.onkeyup = function(){gE('csspanel').innerHTML = '<style type="text/css">'+this.value+'</style>';}
	gE('csseditor').style.display='';
	gE('csseditor').innerHTML = '';
	gE('csseditor').appendChild(ta);	
}
//  ###  - Price -  ###  //
function displayChart(type,which){
	vals = xajax.getFormValues('chartForm');
	if(which==1){
		var regs = new RegExp(gE('com').value,"g");
		vals = vals.replace(regs,gE('commod').value);
	}
	gE('status').innerHTML = gE('loader').innerHTML;
	load_browseChart(vals,type);
}
function checkData(suf){
	sh('loading'+suf,1);
	load_checkSignupData(gE('val'+suf).value,suf);
}

function loadSubMenu(mainId,text){
	if(mainId!=0){
		loading('menuorder',text);
		load_getSubMenu(mainId);
		return true;
	}
	return false;
}
function isPubNews(obj){
	if(obj.checked){
		sh('type',2);
		sh('image',2);
		sh('cat',2);
	}
	else{
		hi('type',2);
		hi('image',2);
		hi('cat',2);
	}
}
function turnOnEditor(id,type,news){
	eName = 'input';
	if(type==1) suf = 'title';
	else if(type==2) suf = 'navigate';
	else if(type==3){
		suf = 'content';
		eName = 'textarea';
	}
	el = document.createElement(eName);
	if(type==3){
		el.rows = 5;
	}
	else{
		el.type = 'text';
		if(type==1) if(news) hi('nlinkt'+id,7); else hi('linkt'+id,7);
		else if(type==2) hi('linkn'+id,7);
	}
	if(news) suf = 'news'+suf;
	el.style.width = '95%';
	if(!news) el.onblur = function(){load_updateBlock(id,this.value,type);}
	else el.onblur = function(){load_updateBlock(id,this.value,type,'News');}
	el.value = gE(suf+id).innerHTML;
	gE(suf+id).innerHTML = '';
	gE(suf+id).appendChild(el);
}
function loadSmiles(){
	if(!gE('emo').innerHTML){
		insert('statemo',gE('EMLoader').innerHTML);
		load_loadEmoticons();
	}
	else sh('emo',2);
}
function setMELink(){
	Effect.Fade('statemo');
	setTimeout('insert(\'statemo\',gE(\'EMLink\').innerHTML);Effect.Appear(\'statemo\');',1000);
}
function showNewsList(type){
	gE('newslist').innerHTML = '<img src="design/pic/loader.gif">';
	if(type==1){
		gE('last').style.borderBottom = '1px solid white';
		gE('viewed').style.borderBottom = '1px solid #DEDEDE';
	}
	else if(type==2){
		gE('last').style.borderBottom = '1px solid #DEDEDE';
		gE('viewed').style.borderBottom = '1px solid white';
	}
	load_newsList(type);
}
function saveAds(id){
	url = gE('url'+id).value;
	src = gE('src'+id).value;
	ord = gE('order'+id).value;
	type = gE('type'+id).value;
	load_manageBanner(url,src,type,ord,id);
}