function byId(_id){return document.getElementById(_id)}
if(navigator.appName=="Netscape"){bis="MM"}else{bis="IE"}
function navSet(){
	for(i=0;i<document.getElementsByTagName("SPAN").length;++i){
		if(document.getElementsByTagName("SPAN")[i].id){
		if(location.pathname.indexOf(document.getElementsByTagName("SPAN")[i].id)!=-1){
			document.getElementsByTagName("SPAN")[i].style.color="#ffdab9"
			
		}
		}
	}
	if(location.pathname=="/home.html"){byId("/index.html").style.color="#ffdab9";
		byId("/index.html").style.textDecoration="underline"}
}
function openWidget(wid,title,href){
	LeftPos = (document.body.clientWidth-wid)/2;
	byId('widgetMain').style.position="absolute"
	byId('tbl_widget').width=wid
	byId('tit_widgetMain').innerHTML=titl
	byId('wid_sub_but').innerHTML=title
	if(bis=="IE"){byId('widgetMain').style.left=LeftPos+"px"}
	byId('widgetMain').style.top="100px"
	ticPad.location=href
	byId('widgetMain').style.display="block"
}
function doc(){
	if(bis=="MM"){return byId("ticPad").contentDocument}
	if(bis=="IE"){return ticPad.document}
}

function toggle(obj){
	doc().execCommand(obj,false,null)
}
function swatch(){
	doc().execCommand("ForeColor",false,"#942C3C")
}
function block(){
	cesel=0
 	if(ticPad.getSelection){
       cesel= byId('ticPad').contentWindow.getSelection(); 
	   ceel=cesel.anchorNode.parentNode
		if (cesel.rangeCount > 0 && window.XMLSerializer){
			cesel=cesel.getRangeAt(0);
			cetxt=new XMLSerializer().serializeToString(cesel.cloneContents());
		}
		wrap(cetxt)
		doc().execCommand("InsertHTML", false, cehtm);
	}else if (doc().selection && doc().selection.createRange){
       cesel=doc().selection.createRange();   
	   ceel=cesel.parentElement()
	   cetxt=cesel.htmlText
	   wrap(cetxt)
	   cesel.pasteHTML(cehtm);
	}	
}
function wrap(txt){
	cehtm='<div style="margin-left:20px;border:1px dashed #999999;padding:5px;background-color:#fdf5e6">'+txt+'</div>'
}
	function setContent(){
		if(navigator.appName=="Netscape"){
			byId('ticPad').contentDocument.designMode="on";
			doc().execCommand("styleWithCSS", false, false);
		}
		if(navigator.appName!="Netscape"){
			ticPad.document.onkeypress=dokeypress
			ticPad.document.body.contentEditable=true
			document.body.focus()
		}
		if(ticket_type==1){
			ticPad.document.body.style.backgroundColor="#F4F4F4"
		}else{
			ticPad.document.body.style.backgroundColor="#F0F8FF"
		}
	}
	function dokeypress(){
	if (ticPad.event.keyCode == 13){
		ky = ticPad.document.selection.createRange();
			if (ky.htmlText.length == 0){
				ky.pasteHTML('<br>'+ky.htmlText);
				ky = ticPad.document.selection.createRange();
				ky.select()
			}else{
				ky.pasteHTML('<br>')
			}	
		ticPad.event.keyCode = 0;				
	}
}
function Shrink(dv){
	if(byId(dv).style.display=="block"){
		byId(dv).style.display="none"
	}else{
		byId(dv).style.display="block"
	}
}
function SubmitTicket(){
	com=ticPad.document.body.innerHTML
	byId('newcomment').value=com
	byId('newForm').submit()
}
function addnewcomment(){
	openWidget("650","Submit New Comment","comment.html")
}
function addnewresponse(){
	openWidget("650","Submit New Response","comment.html")
}
function flag_thread(path){
	url='kb/add_flag.cgi?'+path
	JITc(url)
}
function close_ticket(path){
	url='accounts/close_ticket.cgi?'+path
	JITc(url)
}
function view_ticket(n,id){
		nn=n.split(/-/)
		td="dis"+nn[1]
	if(byId(id).src.match(/comments_add/)){
		url="accounts/view_ticket.cgi?"+n
		JITc(url)
		byId(id).src="/lib/imgs/comments_delete.png"
	}else{
		byId(td).style.display="none"
		byId(id).src="/lib/imgs/comments_add.png"
	}
}
function JITc(URL){
	if(document.getElementById('JQX')){
		document.getElementsByTagName('head')[0].removeChild(document.getElementById('JQX'))
	};
	script = document.createElement('script');	
	script.type = 'text/javascript';	
	script.defer = true;	
	script.id = 'JQX';	
	script.src=url 	
	document.getElementsByTagName('head')[0].appendChild(script);
}
window.onload=navSet

