if(!("console"in window)||!("firebug"in console))
{var names=["log","debug","info","warn","error","assert","dir","dirxml","group","groupEnd","time","timeEnd","count","trace","profile","profileEnd"];window.console={};for(var ii=0;ii<names.length;++ii)
window.console[names[ii]]=function(){}}
var auto_load_cookie = "yuLidOadADasfHP";
var domain_name = "roohit.org" ; var domain_glob = "http://"+domain_name+"/";var IMAGE_DIR=domain_glob+"images/";var CURSOR_DIR=IMAGE_DIR+"cursors/";var pos_popup_x=0;var pos_popup_y=0;var file_name="index.php";var str=window.location.href;var base_url=domain_glob;var pos_x;var pos_y;var d=0;var red_d=0;var resize=0;var is_up_resize=0;var is_down_resize=0;var is_left_resize=0;var is_right_resize=0;var height=0;var width=0;var GRAB_PEN_STATE=0;var on_gp="images/grab_pen_on.gif";var off_gp="images/grab_pen_off.gif";var m_over_gp="images/grab_pen_mose_over.gif";var was_scroll=0;var popTop;var popLeft;var top_colors_state=0;var n_of_hl=1;var divArr=Array();var textRangeArray=Array();var vTimerID;var activeDiv=null;var HL_counter=0;var FLOAT_RIGHT=0;var FLOAT_BOTTOM=0;var TAG_PANEL_VISIBLE=0;var prev_top=0;var prev_left=0;var scroll_Top=0;var scroll_Left=0;var _SShS_status=0;var HLS_ALLOWED=1;var reason_save="";var ALL_RESTORED=0;var fr_id_arr=Array();var HLS_ACTIVE=1;var debug=false;var cur_curs=base_url+'images/cursors/FFFF00.cur';var minimized=0;var SAVE_PAGE_STATE=0;var CUR_PAGE_SAVED=0;var d_m=0;var delete_popup_function=null;var glob_j=0;var glob_sel=null;var glob_rng=null;var glob_anchor_done=true;var glob_focus_done=true;var glob_sel_color=0;var glob_main_div_id="asjkdfnkajsd_div";var ID_SAVED_PAGE=0;var SHOW_SAVED_PAGE=0;var number_of_selections=0;var history_ids=new Array();var my_page=0;var shortcutId="";var flag_from_restore=0;var moreColorsLoaded=0;var text_arr_rest;var path_arr_rest;var offset_arr_rest;var id_arr_rest;var comments_arr_rest;var color_arr_rest;var date_arr_rest;window.onerror=function(sMsg,sUrl,sLine){debugger
var str="<b>An error was thrown and caught.</b><p>";str+="Error: "+sMsg+"<br>";str+="Line: "+sLine+"<br>";str+="URL: "+sUrl+"<br>";trace(str);return false;};function submit_form_first()
{E("url_word").value=E("url_red").value;submit_form();}
var temp__val="";function on_focus(obj)
{obj.style.color="#000000";temp__val=obj.value;if(obj.value=="E-Mail this page to:"||obj.value=="Enter URL here:")
obj.value="";}
function lose_focus(obj)
{obj.style.color="#000000";if(obj.value=="")
obj.value=temp__val;}
function trace(str)
{console.debug(str);}
function E(el)
{return document.getElementById(el);}
function get_offset_in_parent(obj)
{		
	if(BrowserDetect()!="Microsoft Internet Explorer")
	{
	//Do nothing
	}	
	else
	{
		if(!obj.parentElement)
		{
			return;
		}
		var next_obj=obj.parentElement();
		var rng=createRange();
		rng.moveToElementText(next_obj);
		//alert(rng.text);
		rng.setEndPoint("EndToStart",obj);
		return rng.text.length;
	}
}

function get_patch(obj)
{
	
	if(BrowserDetect()!="Microsoft Internet Explorer")
	{
		if(!obj.parentNode)
		{
			return;
		}
		var next_obj=obj.parentNode;
		var res_str=next_obj.nodeName;
		//if (res_str == "#text") {next_obj=next_obj.parentNode; res_str =next_obj.nodeName;}
		while(next_obj=next_obj.parentNode)
		{
			res_str=res_str+"|"+next_obj.nodeName;
		}
		
		return res_str;
	}
	
	else
	{
		if(!obj.parentElement)
		{
			return;
		}
		var next_obj=obj.parentElement();
		var res_str=next_obj.tagName;
		while(next_obj=next_obj.parentNode)
		{
			res_str=res_str+"|"+next_obj.nodeName;
		}
		return res_str;
	}
}
function get_fpath(obj)
{if(!obj.parentNode)
{return;}
var next_obj=obj.parentNode;var res_str=next_obj.tagName;while(next_obj=next_obj.parentNode)
{res_str=res_str+"|"+next_obj.nodeName;}
return res_str;}


function save_page(reason)
{
trace("save_page("+reason+")");var repl=0;trace("Saving....");
try
{
var str;
if (BrowserDetect()!="Microsoft Internet Explorer")
	{
	var e = document.documentElement;
	str = e.innerHTML;
	}
else
	{	
	arr=document.getElementsByTagName("html");
	var str=encodeURIComponent(arr[0].outerHTML);
	}


url=base_url+"new_insert.php";
	if(ID_SAVED_PAGE!=0)
	{
		repl=ID_SAVED_PAGE;}
		else if(SHOW_SAVED_PAGE!=0)
		{
		answer=confirm("Do you want to overwrite the existing copy of this page? \n (If you press Cancel, a new copy will be created)");
		if(answer)
			{
			repl=SHOW_SAVED_PAGE;
			}
		else
			{
			repl=0;
			}
		}
	else if(history_ids.length!=0&&ALL_RESTORED&&my_page==1)
	{
		answer=confirm("Do you want to save changes to the last saved copy of the page? \n (If you press Cancel, a new copy will be created)");
		if(answer)
			{
			repl=history_ids[1];
			}
		else
			{
			repl=0;
			}
	}
	else
	{
		repl=0;
	}

HLS_ACTIVE=0;
var title=document.getElementsByTagName("title");
var url_to_save=E("url_word").value;
for(var cnt=url_to_save.length-1;((url_to_save.charAt(cnt)<="/")&&(url_to_save.charAt(cnt)!=""));cnt--);
	url_to_save=url_to_save.substring(0,cnt+1);

if(!document.charset) dcharset=document.characterSet;
else dcharset=document.charset;

data="id="+encodeURIComponent(E("sesid").value)+"&url="+encodeURIComponent(url_to_save)+"&data="+str+"&num="+number_of_selections+"&HL_counter="+HL_counter+"&title_p="+encodeURIComponent(title[0].innerHTML)+"&charset="+encodeURIComponent(dcharset)+"&repl="+repl+reason;trace(url);

document.getElementById('pasteIt').style.display='none';
document.getElementById('pasteIt').style.visibility='hidden'; 
document.getElementById('loadingShurl').style.display=''; 
document.getElementById('loadingShurl').style.visibility='visible'; 

do_post(url,data,onSumResponse);

if ((reason.indexOf('reason=1')=='1') && !isUserLoggedIn() && (parseInt(GetCookie("numOfHLs")) > 2) && (!isCookieSet("dontshow")) )
	{
	showBox('box');
	}
}
catch(ex)
{
trace("exception on data sending"+ex.message);
}

save_state();
//onmouseover_HL(event, null);
}

function isUserLoggedIn(){if (isCookieSet("c6346359c72f0d28e27a")){if ( '29b77ff80658375b3bbe' == getCookie("c6346359c72f0d28e27a"))return true ;}return false ;}


function onSumResponse(xhReq)
{
HLS_ACTIVE=1;
var id=xhReq.responseText;
var returnParams=id.split("&");
id=returnParams[0];
var shortcutId=returnParams[1];

if(undefined!=shortcutId)
{
//if (parseInt(GetCookie('emSent'))==0){showBox('tipsBox');}

incrementCookie('numOfHLs',7776000000);
var expdate = new Date ();
FixCookieDate (expdate);
expdate.setTime (expdate.getTime() + 31536000);
SetCookie("j4ksd8Gef6dCewe", "3", expdate,"/"); 	
E('shortcutId').value = shortcutId;
E('shortcuturl').value =  base_url+shortcutId;
document.getElementById('show_shortcut').style.visibility='visible';
document.getElementById('show_shortcut').style.display='';
document.getElementById('loadingShurl').style.display='none';
document.getElementById('loadingShurl').style.visibility='hidden'; 
document.getElementById('pasteIt').style.display=''; 
document.getElementById('pasteIt').style.visibility='visible'; 
document.body.style.cursor="url("+cur_curs+"), auto";
document.getElementById('PastHL').href=base_url+'/site/view1.php';
document.getElementById('PastHL').className='btn';
document.getElementById('PastMOB').href=base_url+'/site/view1.php';
document.getElementById('PastMOB').className='btn_tip';
}
E('ID_SAVED_PAGE').value = parseInt(id);
trace("Saved, id = "+id);
CUR_PAGE_SAVED=1;
ID_SAVED_PAGE=parseInt(id);
}

function colorPickerGetTopPos(inputObj)
{var returnValue=inputObj.offsetTop;while((inputObj=inputObj.offsetParent)!=null)
{returnValue+=inputObj.offsetTop;}
return returnValue;}
function colorPickerGetLeftPos(inputObj)
{var returnValue=inputObj.offsetLeft;while((inputObj=inputObj.offsetParent)!=null)returnValue+=inputObj.offsetLeft;return returnValue;}
var ALL_COLORS_LINK=null;function loadMoreColors(transport)
{responseT=transport.responseText;E("ALL_COLORS_PALETTE").innerHTML=responseT;E("ALL_COLORS_PALETTE").style.display="inline";E("ALL_COLORS_PALETTE").style.visibility="visible";E("PALETTE_CHANGE_TOP").style.display="none";E("PALETTE_CHANGE_ALL").style.display="inline";}
function change_pallete(top_colors)
{trace("change_pallete( "+top_colors+") ");if(top_colors==1)
{E("TOP_COLORS_PALLETTE").style.visibility="visible";if(moreColorsLoaded==0)
{var url_colors=base_url+"moreColors.php";var data="";do_post(url_colors,data,loadMoreColors);moreColorsLoaded=1;}
else
{E("ALL_COLORS_PALETTE").style.display="inline";E("ALL_COLORS_PALETTE").style.visibility="visible";E("PALETTE_CHANGE_TOP").style.display="none";E("PALETTE_CHANGE_ALL").style.display="inline";}
E("popup").style.height="200px";top_colors_state=1;}
else
{E("TOP_COLORS_PALLETTE").style.visibility="visible";E("PALETTE_CHANGE_TOP").style.display="inline";E("PALETTE_CHANGE_ALL").style.display="none";E("ALL_COLORS_PALETTE").style.display="none";E("ALL_COLORS_PALETTE").style.visibility="hidden";top_colors_state=0;}
return false;}
function getHexFromCSSRGB(col){trace("getHexFromCSSRGB call");col=col.toUpperCase();if(col.substring(0,3)!="RGB")return col;col=col.substring(4,col.indexOf(')'));trace("col = "+col);var tmpa=col.split(",");return'#'+RGBtoHex(tmpa[0],tmpa[1],tmpa[2]);}
function RGBtoHex(R,G,B){return toHex(R)+toHex(G)+toHex(B)}
function toHex(N){if(N==null)return"00";N=parseInt(N);if(N==0||isNaN(N))return"00";N=Math.max(0,N);N=Math.min(N,255);N=Math.round(N);return"0123456789ABCDEF".charAt((N-N%16)/16)
+"0123456789ABCDEF".charAt(N%16);}

function set_color(col)
{
E("selectedColor").style.backgroundColor=col;
col=getHexFromCSSRGB(col);
cur_curs=CURSOR_DIR+(col.substring(1)).toUpperCase()+'.cur';
document.body.style.cursor="url("+cur_curs+"), auto";
trace(cur_curs);
trace(document.body.style.cursor);
var expdate=new Date();
FixCookieDate(expdate);
expdate.setTime(expdate.getTime()+31536000);
SetCookie("pencolor",col,expdate,"/");
}


function grab_pen()
{if(GRAB_PEN_STATE==0)
{E("GRAB_PANE").innerHTML="Put Pen Down";GRAB_PEN_STATE=1;E("HIGHTLIGHT_BUTTON").style.display="none";document.body.style.cursor="url("+cur_curs+"), auto";}
else
{document.body.style.cursor = "default";
E("GRAB_PANE").innerHTML="Grab Pen";GRAB_PEN_STATE=0;E("HIGHTLIGHT_BUTTON").style.visibility="visible";E("HIGHTLIGHT_BUTTON").style.display="inline";}}

function grab_pane_mouse_enter()
{if(GRAB_PEN_STATE==0)
{E("grab_pane").src=m_over_gp;}}

function grab_pane_mouse_leave()
{if(GRAB_PEN_STATE==0)
{E("grab_pane").src=off_gp;}}
function grab_pen_click()
{if(GRAB_PEN_STATE==1)
{GRAB_PEN_STATE=0;E("grab_pane").src=off_gp;}
else
{GRAB_PEN_STATE=1;E("grab_pane").src=on_gp;}}
function down_border_down(arg)
{is_down_resize=1;document.body.style.cursor="N-resize";pos_y=parseInt(E("popup").style.top);}
function minimize()
{minimized_prev_state=minimized;if(minimized==1)
{minimized=0;}
else
{minimized=1;}
save_state();show_acording_to_minim();}
function show_acording_to_minim()
{trace("show_acording_to_minim()");if(minimized==0)
{if(E("minimized").style.visibility=="visible")
{var x=parseInt(E("minimized").style.left)+parseInt(E("minimized").style.width)-parseInt(E("popup").style.width)+8;if(x<0)x=0;E("popup").style.left=x+'px';}
else
{E("popup").style.left=(parseInt(E("reduce").style.left)+parseInt(E("reduce").style.width)-parseInt(E("popup").style.width))+4+'px';}
if(E("popup").style.top<0)
{E("popup").style.top=10;}
E("minimized").style.visibility="hidden";E("login_row").style.visibility="hidden";E("reduce").style.visibility="hidden";E("popup").style.display="inline";E("minimized").style.display="none";E("reduce").style.display="none";scroll_();show_HP();}
if(minimized==1)
{E("minimized").style.visibility="visible";E("reduce").style.visibility="hidden";E("reduce").style.visibility="hidden";E("minimized").style.top=E("popup").style.top;E("minimized").style.left=(parseInt(E("popup").style.left)+parseInt(E("popup").style.width)-parseInt(E("minimized").style.width)-8)+'px';E("popup").style.display="none";E("minimized").style.display="inline";E("reduce").style.display="none";scroll_();hide_HP();}
if(minimized==2)
{E("reduce").style.top=E("popup").style.top;E("reduce").style.left=(parseInt(E("popup").style.left)+parseInt(E("popup").style.width)-parseInt(E("reduce").style.width)-4)+'px';E("reduce").style.visibility="visible";E("minimized").style.visibility="hidden";E("popup").style.display="none";E("minimized").style.display="none";E("reduce").style.display="inline";scroll_();hide_HP();}
if(minimized==3)
{if(E("reduce").style.visibility=="visible")
{unreduce();}
E("login_row").style.top=E("popup").style.top;E("login_row").style.left=(parseInt(E("popup").style.left)+parseInt(E("popup").style.width)-parseInt(E("login_row").style.width)-4)+'px';E("login_row").style.visibility="visible";E("minimized").style.visibility="hidden";E("popup").style.display="none";E("minimized").style.display="none";E("reduce").style.display="none";scroll_();hide_HP();}
save_state();}
function save_state()
{var expdate=new Date();FixCookieDate(expdate);expdate.setTime(expdate.getTime()+360000000);SetCookie("minimized",minimized,expdate,"/");SetCookie("SHOW_SAVED_PAGE",SHOW_SAVED_PAGE,expdate,"/");SetCookie("GRAB_PEN_STATE",GRAB_PEN_STATE,expdate,"/");SetCookie("top_colors_state",top_colors_state,expdate,"/");}
function restore_state()
{if(isCookieSet("minimized"))
minimized=GetCookie("minimized");if(isCookieSet("GRAB_PEN_STATE"))
GRAB_PEN_STATE=GetCookie("GRAB_PEN_STATE");if(isCookieSet("top_colors_state"))
top_colors_state=GetCookie("top_colors_state");}
function m_enter_minimize()
{E("minimize_but").src=IMAGE_DIR+"minimize_active.png";}
function m_enter_reduce()
{E("reduce_but").src=IMAGE_DIR+"reduce.jpg";}
function m_leave_minimize()
{E("minimize_but").src=IMAGE_DIR+"minimize.png";}
function m_leave_reduce()
{E("reduce_but").src=IMAGE_DIR+"reduce.jpg";}
function down_border_up(arg)
{is_down_resize=0;}
var text_input=null;var mail_input=null;var mail_but=null;var cancel_but=null;function send_mail_HP()
{if(test_mail(E('mail_for_link').value))
{var arr=document.getElementsByTagName("html");var data=arr[0].outerHTML;if(data==null)data=document.getElementsByTagName("html")[0].innerHTML;send_mail(data,E('mail_for_link').value,"HP");return true;}
else{if((arguments.length==0)||(typeof arguments[0]=='object'))
{alert("Invalid e-mail address.");E('ol').style.display='none';}
return false;}}
function test_mail(addr_list)
{var emailReg="^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";var regex=new RegExp(emailReg);addr_list=trim(addr_list);addr_list=addr_list.replace(/,/,";");to_arr=addr_list.split(";");for(i=0;i<to_arr.length;i++)
{to_arr[i]=extractEmail(trim(to_arr[i]));if(to_arr[i]!="")
{if(!regex.test(trim(to_arr[i])))
{return false;}}
else
{return false;}}
return true;}
function extractEmail(inStr)
{var strtAdd=inStr.indexOf('<');if(strtAdd>-1)
{var endAdd=inStr.lastIndexOf('>');if(endAdd>-1)
{inStr=inStr.substring(strtAdd+1,endAdd);}}
return inStr;}
function send_mail(data,mail,entryPoint)
{document.body.style.cursor="url("+base_url+"images/cursors/busy.cur), wait";url=base_url+"send_mail.php";var cur_adr=E("url_word").value;var hl_ids=document.getElementById('hl_id').value;document.getElementById('hidden_uemail').value=mail;var subject=document.getElementById('subject').value;var from=document.getElementById('from_mob').value;var comments=document.getElementById('mail_data').value;var private=($('private_mob').checked)?1:0;var send_what3='Link_only';if(document.getElementsByName("send_what")[0].checked==true)
{send_what3='Link_only';}
else if(document.getElementsByName("send_what")[1].checked==true)
{send_what3='full_article';}
else if(document.getElementsByName("send_what")[2].checked==true)
{send_what3='HL_only';}
data="hl_ids="+hl_ids+"&entry_point="+encodeURIComponent(entryPoint)+"&body="+encodeURIComponent(data)+"&mail="+encodeURIComponent(mail)+"&sesid="+E("sesid").value+"&id="+E("sesid").value+"&url="+encodeURIComponent(cur_adr)+"&subject="+encodeURIComponent(subject)+"&from="+encodeURIComponent(from)+"&ucomments="+encodeURIComponent(comments)+"&private="+encodeURIComponent(private)+"&send_what="+send_what3+"&shurl="+document.getElementById('shortcuturl').value;do_post(url,data,onMailResponse);trace(url+":"+data)
trace('mail sending hl_ids:'+hl_ids);}
function showResponse(originalRequest)
{if(originalRequest.responseText=="ok")
{document.body.style.cursor="url("+cur_curs+"), auto";alert("Success: your highlights have been sent.");hm();incrementCookie('emSent',7776000000);}
else
{}}
function onMailResponse(mail_req)
{var returnResponse=mail_req.replace(/(\n| |\r)/gi,"");if(returnResponse.match(/[a-zA-Z]/gi)==null)
{returnResponse="";}
if(returnResponse.indexOf("ok")!=0)
{if(returnResponse!="")
{E("systemWorking").style.top=200+scroll_Top;E("systemWorking").style.left=300+scroll_Left;$('systemWorking').innerHTML=mail_req;$('systemWorking').style.visibility='visible';$('systemWorking').style.display="";$('systemWorking1').style.visibility='hidden';$('systemWorking1').style.display="none";}
else
{$('systemWorking1').style.visibility='hidden';$('systemWorking1').style.display="none";$('systemWorking').innerHTML="";$('systemWorking').style.display="none";}}
if(returnResponse.indexOf("ok")==0)
{hm();E('ol').style.display='none';incrementCookie('emSent',7776000000);alert("Success: your highlights have been e-mailed.");}
document.body.style.cursor="url("+cur_curs+"), auto";}
function send_link()
{if(E("ID_SAVED_PAGE").value==NaN||E("ID_SAVED_PAGE").value==0)
{return;}
if(test_mail(E("mail_for_link").value))
{url=base_url+"create_link.php";data="id="+encodeURIComponent(E("ID_SAVED_PAGE").value)+"&sesid="+E("sesid").value+"&mail="+encodeURIComponent(E("mail_for_link").value);do_post(url,data,onCreateLink_response);}
else
alert("Invalid e-mail address, please correct it.");}
function onCreateLink_response(link_req)
{if(link_req.responseText!="ok")
{trace("server-side error in mail sending: "+link_req.responseText);}}
function up_border_click()
{pos_x=parseInt(E("popup").style.posHeight)+parseInt(E("popup").style.posTop);height=parseInt(E("popup").style.height);is_up_resize=1;document.body.style.cursor="N-resize";}
function resize_start()
{pos_x=parseInt(E("popup").style.width)+parseInt(E("popup").style.left);pos_y=parseInt(E("popup").style.height)+parseInt(E("popup").style.top);resize=1;}
function resize_finish()
{resize=0;is_up_resize=0;is_down_resize=0;is_left_resize=0;is_right_resize=0;d=0;if(GRAB_PEN_STATE==1)
{document.body.style.cursor="url("+cur_curs+"), auto";trace("set cursor to "+cur_curs);}}
function left_border_down(arg)
{is_left_resize=1;pos_x=parseInt(E("popup").style.left)+parseInt(E("popup").style.width);}
function left_border_up(arg)
{is_left_resize=0;}
function right_border_down(arg)
{is_right_resize=1;pos_x=parseInt(E("popup").style.left);}
function right_border_up(arg)
{is_right_resize=0;}
function down(evt)
{var ev=evt?evt:window.event;pos_x=ev.clientX-parseInt(E("popup").style.left);pos_y=ev.clientY-parseInt(E("popup").style.top);d=1;}
function down_min(evt)
{var ev=evt?evt:window.event;pos_x=ev.clientX-parseInt(E("minimized").style.left);pos_y=ev.clientY-parseInt(E("minimized").style.top);d_m=1;}
function down_red(evt)
{var ev=evt?evt:window.event;pos_x=ev.clientX-parseInt(E("reduce").style.left);pos_y=ev.clientY-parseInt(E("reduce").style.top);red_d=1;}
function clear_sel()
{ClearSelection()}
function move(evt)
{var ev=evt?evt:window.event;if(typeof(FLOAT_RIGHT)!='undefined'){if(FLOAT_RIGHT&&FLOAT_RIGHT!=1&&FLOAT_BOTTOM&&FLOAT_BOTTOM!=1)
{if(is_left_resize==1)
{E("popup").style.left=ev.clientX+"px";E("popup").style.width=pos_x-ev.clientX+"px";clear_sel();}
if(d==1)
{E("popup").style.left=ev.clientX-pos_x+"px";E("popup").style.top=ev.clientY-pos_y+"px";clear_sel();}
if(d_m==1)
{E("minimized").style.left=ev.clientX-pos_x+"px";E("minimized").style.top=ev.clientY-pos_y+"px";clear_sel();}
if(red_d==1)
{E("reduce").style.left=ev.clientX-pos_x+"px";E("reduce").style.top=ev.clientY-pos_y+"px";clear_sel();}
if(is_down_resize==1)
{E("popup").style.height=ev.clientY-pos_y+"px";clear_sel();}
if(is_up_resize==1)
{E("popup").style.top=ev.clientY+"px";E("popup").style.height=pos_x-ev.clientY+"px";clear_sel();}
if(is_right_resize==1)
{E("popup").style.width=ev.clientX-pos_x;clear_sel();}
if(resize==1)
{E("popup").style.width=ev.clientX-parseInt(E("popup").style.posLeft)+"px";E("popup").style.height=ev.clientY-parseInt(E("popup").style.posTop)+"px";clear_sel();}}}}
function reportError()
{}
function clickk()
{document.location.href=base_url+"index.php/"+encodeURIComponent(E("url_word").value)+"";}
function up(ev)
{d=0;red_d=0;d_m=0;}
function up_min(ev)
{}
function up_red(ev)
{}
function key_down(arg)
{if(window.event.keyCode==13)
clickk();}
var win;function hide_mob()
{if(vTimerID!=null)window.clearTimeout(vTimerID);hide_popup();}
function m_enter_close()
{E("close_but").src=IMAGE_DIR+"close_active.png";}
function m_leave_close()
{E("close_but").src=IMAGE_DIR+"close.png";}
function m_enter_unfloat()
{E("unfloat_but").src=IMAGE_DIR+"unfloat_active.png";}
function m_leave_unfloat()
{E("unfloat_but").src=IMAGE_DIR+"unfloat.png";}
function fix_ext(tag_name,atr,dom_,url_,debug)
{}
function show_HP()
{trace("show_HP()");E("popup").style.visibility="visible";change_pallete(top_colors_state);}
function hide_HP()
{trace("hide_HP");E("popup").style.visibility="hidden";E("TOP_COLORS_PALLETTE").style.visibility="hidden";if(E("ALL_COLORS_PALETTE"))
E("ALL_COLORS_PALETTE").style.visibility="hidden";E("HIGHTLIGHT_BUTTON").style.visibility="hidden";}
function time_left()
{if(E('popup').style.visibility=="hidden")
{initialize();}}
function trim(str)
{str=str.toString();while(1)
{if(str.substring(0,1)!=" ")
{break;}
str=str.substring(1,str.length);}
while(1)
{if(str.substring(str.length-1,str.length)!=" ")
{break;}
str=str.substring(0,str.length-1);}
return str;}
function restore_hl(text,path,offset,color,id,comments,date)
{
trace("restore_hl call");
if(BrowserDetect()!="Microsoft Internet Explorer")
	{
	alert("This is to call to restore of NON-IE");
	alert(text);
	var temp_div = document.createElement("div");
	temp_div.innerHTML = text; 
	var any_match=0;

	inRange = function(node) 
					{ 
					//This function decides if the node is in the selection or out of based on end,start point comparison
					if (get_patch(node) == path)
						{
						return NodeFilter.FILTER_ACCEPT;
						}	
					else
						{
						return NodeFilter.FILTER_SKIP;
						}
					}


	var treeWalker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, inRange, true);

	selObj= window.getSelection();

	var y = treeWalker.nextNode();
	while (y)
		{
		var currentNode = treeWalker.currentNode;
		y = treeWalker.nextNode();			
		var highlight_found = 0;
		
		var treeWalker_bef_html = document.createTreeWalker(temp_div, NodeFilter.SHOW_TEXT, null, true);
		var x = treeWalker_bef_html.nextNode();
				
		if (currentNode.textContent.substr(offset,x.textContent.length) == x.textContent)
			{
			highlight_found = 1; //if only single node. Then the highlight is found.
			selObj.collapse(currentNode,offset);
			var offset_len = parseInt(offset) + parseInt(x.textContent.length);
			while(1)
				{
				//Wierd but true is all I can say. Safari, Chrome have a screwed up sense of extend, textContent.length.
				//Turns out if I cannot highlight till the last point of node but only till certain point where the text ends.
				//Reports screwed up length in first place, then does not allow me to highlight till that. WTF.
				try
					{
					selObj.extend(currentNode,offset_len);
					break;
					}
				catch(excep)
					{
					offset_len--;
					continue;
					}
				}
			//alert("this is the after");
			//Found the node that matches the path and whose characters match the first node characters of the innerHTML
			//Now we need to locate this node in the main body tree.
			var treeWalker_body = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, true);
			var z = treeWalker_body.nextNode();
			while (z)
				{
				var currentNode_body = treeWalker_body.currentNode;
				var found_flag = 0;
				if (currentNode_body == currentNode) 
					{
					//Found the matching node in the bodytree also. Now we need to scan node by node for matching nodes to follow	
					found_flag = 1;
					x = treeWalker_bef_html.nextNode();
					z = treeWalker_body.nextNode();
					var current_x;
					var current_z;
					//alert(x);
					
						do
						{
						var break_var=0;
						if (x) current_x = treeWalker_bef_html.currentNode;
						if (z) current_z = treeWalker_body.currentNode;
						if (x!=null && z!=null) if (x.textContent == z.textContent) 
							{							
							//alert(x.textContent);
							highlight_found = 1;		//Till it is equal the highlight is being found
							var off_len_2 = 0+z.textContent.length;
							while(1)
								{
								//The same safari,chrome bug
								try
									{
									selObj.extend(z,off_len_2 );
									break;
									}
							catch(excep)
									{
									off_len_2--;
									continue;
									}
								}
							
							} 
						else 
							{
							highlight_found = 0; //On the first inequality the highlight is no more found.
							break_var = 1;
							}					
						x = treeWalker_bef_html.nextNode();
						z = treeWalker_body.nextNode();
						if (break_var) break;
						}while (x);
						
						
					if (current_x != null && current_z != null) if (current_x.textContent != current_z.textContent && current_x.textContent == current_z.textContent.substr(0,current_x.textContent.length) && x==null)	//IF only the highlight is equal till here is this condition checked.
						{
							highlight_found=1;
							var off_len_3 = current_x.textContent.length;
							while(1)
								{
								//The same safari,chrome bug
								try
									{
									selObj.extend(current_z,off_len_3);
									break;
									}
								catch(excep)
									{
									off_len_3--;
									continue;
									}
								}
						}

					else if(x != null)
						{
						highlight_found=0;	
						}
					
					else if (current_x.textContent == current_z.textContent)
						{
						if(selObj.containsNode(current_z,true) == false) 
							{
							var off_len_4 = 0+current_x.textContent.length;
							while(1)
								{
								//The same safari,chrome bug
								try
									{
									selObj.extend(current_z, off_len_4);
									break;
									}
								catch(excep)
									{
									off_len_4--;
									continue;
									}
								}
							
							}
							
						highlight_found=1;
						}
					else 
						{
						highlight_found=1;	
						}
						
						
					}
				if(found_flag) break;
				z = treeWalker_body.nextNode();
				}
			}

	if(highlight_found) {change(1,color,id,date,decodeURIComponent(comments));any_match=1;}
	}
	
	
	if(any_match) return true;
	else return false;
}
	
	
else
	{
	//Start of restore_hl for IE
	var rgn=document.body.createTextRange();
	var body_rgn=document.body.createTextRange();
	var text_dec;
	try
		{
		text_dec=decodeURIComponent(text);
		path=decodeURIComponent(path);
		while(rgn.findText(text_dec))
			{
			if((get_patch(rgn)==path)||(get_offset_in_parent(rgn)==offset))
				{
				rgn.select();
				flag_from_restore=1;
				change(1,color,id,date,decodeURIComponent(comments));
				return true;
				}
			body_rgn.setEndPoint("StartToEnd",rgn);
			rgn.setEndPoint("EndToEnd",body_rgn);
			rgn.setEndPoint("StartToStart",body_rgn);
			}
		}
	catch(exc)
		{
		trace(exc.message);
		}
	var res_range=document.body.createTextRange();
	var left_range=document.body.createTextRange();
	var arr_str=text.split('%0D%0A');
	var j=0;rgn=document.body.createTextRange();
	body_rgn=document.body.createTextRange();
	var str_=trim(decodeURIComponent(arr_str[j]));
	var j=0;
	while(trim(decodeURIComponent(arr_str[j]))=="")	j++;
	str_=trim(decodeURIComponent(arr_str[j]));
	while(rgn.findText(str_))
		{
		res_range.setEndPoint("EndToEnd",rgn);
		res_range.setEndPoint("StartToStart",rgn);
		left_range.setEndPoint("StartToEnd",rgn);
		left_range.setEndPoint("EndToEnd",document.body.createTextRange());
		for(i=j+1;i<arr_str.length;i++)
			{
			var temp_str=trim(decodeURIComponent(arr_str[i]));
			if(temp_str.replace(" ","").length==0)
				{
				continue;
				}
			try
				{
				if(left_range.findText(temp_str))
					{
					res_range.setEndPoint("EndToEnd",left_range);
					left_range.setEndPoint("EndToEnd",document.body.createTextRange());
					left_range.setEndPoint("StartToEnd",res_range);
					}
				else
					{
					left_range.select();
					return false;
					}
				}
			catch(exc)
				{
				alert("error: "+arr_str[i]+"|"+i+"|"+arr_str.length);
				}
			}
		if((get_patch(res_range)==path)||(get_offset_in_parent(res_range)==offset))
			{
			res_range.select();
			flag_from_restore=1;
			change(1,color,id,date,decodeURIComponent(comments));
			return true;
			}
		else
			{
			}
		body_rgn.setEndPoint("StartToEnd",rgn);
		rgn.setEndPoint("EndToEnd",body_rgn);
		rgn.setEndPoint("StartToStart",body_rgn);
		}
		
	//End of restore_hl for IE
	}
	
//End of function..restore_hl
}


function async_restore_hls(transport)
{var responseText=transport.responseText;
alert(responseText);
eval(responseText);
try
{text_arr_rest=text_arr;path_arr_rest=path_arr;offset_arr_rest=offset_arr;id_arr_rest=id_arr;comments_arr_rest=comments_arr;color_arr_rest=color_arr;
date_arr_rest=date_arr;
if(!SHOW_SAVED_PAGE)
{ALL_RESTORED=restore_hls();}


}
catch(exc)
{trace(exc.message+" ln: 1058");ALL_RESTORED=false;}
if(!ALL_RESTORED)
{E("saving_menu").style.visibility="visible";}
else
{E("saving_menu").style.visibility="hidden";}
url=base_url+"get_saved_page_ids.php?"+"sesid="+E("sesid").value+"&url="+restore_url;var data="";do_post(url,data,get_saved_page_id);/*if(indirect)
{E("saving_menu").style.visibility="hidden";}*/}
function get_saved_page_id(transport)
{var responseText=transport.responseText;eval(responseText);if(shortcutId!=""&&shortcutId!=undefined&&my_page==1)
{E('shortcutId').setAttribute("value",shortcutId);E('shortcuturl').setAttribute("value",base_url+shortcutId);document.getElementById('show_shortcut').style.visibility='visible';document.getElementById('show_shortcut').style.display='';}
if(SHOW_SAVED_PAGE!=0)
{show_saved_click();}
if(E("VIEW_PAGE"))
if(history_ids.length>0)
E("VIEW_PAGE").style.visibility='visible';trace('SHOW_SAVED_PAGE'+SHOW_SAVED_PAGE);if(SHOW_SAVED_PAGE!=0)
{show_saved_click();}
if(SHOW_SAVED_PAGE)
{attach_events_to_HLs_made();}
/*if(indirect)
{E("VIEW_PAGE").style.visibility="hidden";}*/}
function restore_hls_rest()
{text_arr=text_arr_rest;path_arr=path_arr_rest;offset_arr=offset_arr_rest;id_arr=id_arr_rest;comments_arr=comments_arr_rest;color_arr=color_arr_rest;date_arr=date_arr_rest;trace("restore_hls call");var index;var all_restored=true;for(index=0;index<text_arr.length;index++)
{if(!restore_hl(text_arr[index],path_arr[index],offset_arr[index],color_arr[index],id_arr[index],comments_arr[index],date_arr[index]))
{all_restored=false;}}
//scroll(0,0);
return all_restored;}
function restore_hls()
{
trace("restore_hls call");
var index;
var all_restored=true;
for(index=0;index<text_arr.length;index++)
{
if(!restore_hl(text_arr[index],path_arr[index],offset_arr[index],color_arr[index],id_arr[index],comments_arr[index],date_arr[index]))
	{
	all_restored=false;
	}
}
//scroll(0,0);
return all_restored;
}


function show_evreones()
{if(E("SHOW_ALL").getAttribute("CHECKED"))
{document.getElementById('ajxbusy').style.visibility='visible';try
{url=base_url+"get_all_hls.php";var data="all=1&url="+encodeURIComponent(E("url_word").value);do_post(url,data,on_show_all_resp);}
catch(ex)
{trace("Exception on restoring everyones hilights."+ex.message);}}
else
{
var expdate = new Date ();
expdate.setTime (expdate.getTime() + 31500);
SetCookie(auto_load_cookie,"2",expdate,"/");
history.go(0);}}
function delete_others()
{idoc=window.document;try
{document.getElementById('systemWorking').style.visibility='hidden';document.getElementById('systemWorking').style.display="none";document.getElementById('systemWorking').innerHTML="";for(index=0;index<text_arr.length;index++)
{var arr_font=window.document.body.getElementsByTagName("FONT");var atr=null;for(i=0;i<arr_font.length;i++)
{atr=arr_font[i].getAttribute("active");if(atr==id_arr[index])
{HL_counter--;number_of_selections--;arr_font[i].style.backgroundColor="";arr_font[i].onmouseover=null;arr_font[i].onmouseleave=null;arr_font[i].setAttribute("active",null);}}}}
catch(ex)
{trace("error: "+ex.message);}}
function show_friends()
{try
{url=base_url+"get_all_hls.php";var data="all=2&url="+encodeURIComponent(E("url_word").value);do_post(url,data,on_show_all_resp);}
catch(ex)
{trace("Exception on restoring friends hilights."+ex.message);}}
function on_show_all_resp(hls)
{document.getElementById('ajxbusy').style.visibility='hidden';if(hls.responseText!="ok")
{var test=eval(hls.responseText);trace("Total number of HLs :"+id_arr.length);restore_hls();}}
function show_friends_hl(fr_id)
{var index;var all_restored=true;for(index=0;index<text_arr.length;index++)
{if(fr_id==fr_id_arr[index])
{if(!restore_hl(text_arr[index],path_arr[index],offset_arr[index],color_arr[index],id_arr[index],comments_arr[index],date_arr[index]))
{all_restored=false;}}}}
function show_saved()
{trace("show_saved()");var src_el=window.event.srcElement;var s_id=src_el.value;SHOW_SAVED_PAGE=s_id;save_state();history.go(0);}
function reload_saved_page(transport)
{if(SHOW_SAVED_PAGE==0)
{window.location=unescape(restore_url);}
else
{window.location=base_url+unescape(restore_url);}}
function show_saved_click()
{E("saving_menu").innerHtml="";var temp_str="";var i=0;var select_=document.createElement("<select></select>");var temp_p;var oOption;var selected_num=0;for(i=0;i<history_ids.length;i++)
{trace("SHOW_SAVED_PAGE="+SHOW_SAVED_PAGE+"|"+history_ids[i]+"|"+(SHOW_SAVED_PAGE==history_ids[i]));oOption=document.createElement("OPTION");oOption.text=history_dates[i];oOption.value=history_ids[i];oOption.setAttribute('class','nice_');if(SHOW_SAVED_PAGE==history_ids[i])
selected_num=i;select_.add(oOption);}
select_.setAttribute('class','nice');var arr_=E("saving_menu").getElementsByTagName("select");try
{for(i=0;i<=arr_.length;i++)
{E("saving_menu").removeChild(arr_[i]);}}
catch(exc)
{trace('Error while deleting selects.');}
if(E("VIEW_PAGE"))E("saving_menu").removeChild(E("VIEW_PAGE"));select_.style.visibility="visible";select_.style.font="normal 12px Arial";addEvent(select_,"change",function(){show_saved();return false;});if(selected_num>0)select_.options[selected_num].selected=true;E("saving_menu").appendChild(select_);trace("list building finished");}
var usercontacts_in=null;function eq_user(usercontacts)
{usercontacts_in=usercontacts;}
function async_email(transport)
{var responseText=transport.responseText;var sScript=responseText.lastIndexOf("</div>");if(sScript=='-1')
{/*do nothing */}
else
{document.getElementById("populate_mails").innerHTML=responseText.substr(0,sScript-1);eval(responseText.substring(sScript+6+31,responseText.length-10));eq_user(usercontacts);}
var url_async=base_url+"s7Tes82sw0R/dzRiJ.31o/fZoOkd/s8Ge7sWeD0/kPuT5.pU3ifT/actb_js.js.php";var data="";do_post(url_async,data,async_actb);}
function async_actb(transport)
{var responseText=transport.responseText;var usercontacts=usercontacts_in;eval(responseText);if(usercontacts_in)
{actb(document.getElementById('mail_from'),usercontacts);actb(document.getElementById('mail_for_link'),usercontacts);actb(document.getElementById('mail_from2'),usercontacts);}}


function initialize()
{
	/*if (GetCookie(auto_load_cookie) == "2")
		{
		DeleteCookie(auto_load_cookie,"/", "."+domain_name);
		url_async=base_url+"new_restore_hls.php?"+"sesid="+E("sesid").value+"&url="+restore_url+"&SHOW_SAVED_PAGE="+E("HAVE_SAVED").value;data="";
		do_post(url_async,data,async_restore_hls);
		}
	else
		{
			DeleteCookie(auto_load_cookie,"/", "."+domain_name);
			E("SHOW_ALL").checked=true;
			show_evreones();
		}
	*/

	
try {                   //This image reloading bug
		document.execCommand("BackgroundImageCache", false, true);
	} catch(err) {}


var url_async=base_url+"populate_emails.php";
var data="";
do_post(url_async,data,async_email);
restore_state();
trace("initialize called<br>");
hide_HP();
hide_popup();
url_async=base_url+"new_restore_hls.php?"+"sesid="+E("sesid").value+"&url="+restore_url+"&SHOW_SAVED_PAGE="+E("HAVE_SAVED").value;
data="";
do_post(url_async,data,async_restore_hls);
var url=E("url_word").value;if(url.indexOf("http://")==-1)
{if(url.indexOf('/')!=-1)url=url.substr(0,url.indexOf('/'));url="http://"+url;}
else
if(url=="")
url=E("url_word").value;var domain_="http://"+window.location.host+"/";

bod=document.body;
addEvent(bod,'mouseup',resize_finish);
addEvent(bod,'mouseup',up);
if(BrowserDetect()!="Microsoft Internet Explorer")
{
//addEvent(window,'load',prepDoc);
addEvent(bod,'mouseup',grab);
}
else{
addEvent(bod,'mouseup',grab);
}
addEvent(bod,'mousemove',move);
addEvent(bod,'scroll',scroll_);
addEvent(window,'scroll',scroll_);
addEvent(window,'resize',scroll_);
addEvent(E("popup"),'click',remove_onout_event);



document.body.style.cursor="default";E("GRAB_PANE").innerHTML="Grab Pen";GRAB_PEN_STATE=0;E("HIGHTLIGHT_BUTTON").style.visibility="visible";grab_pen();var ind1=0;var str1=document.location.href+'';str1=str1.toLowerCase();if(str1.indexOf(domain_name)>0)ind1=str1.indexOf(domain_name);var str2=str1.substring(ind1+12);if(str2.substring(0,2).toLowerCase()=='')str2=str.substring(3);if(str2.substring(0,2)=='1/')minimized=0;else if(str2.substring(0,2)=='2/')minimized=1;else if(str2.substring(0,2)=='3/')minimized=2;show_acording_to_minim();if(isCookieSet("pencolor"))
{pencolor=GetCookie("pencolor");set_color(pencolor);}
else
{var col=new Array('#FFFF00','#00FFFF','#FF00FF','#00FF00','#ff0000','#FFFF00','#00FFFF','#FF00FF','#00FF00','#ff0000');var i=Math.floor(Math.random()*10);set_color(col[i]);}
if("1"==GetCookie("mailPage"))
{DeleteCookie("mailPage","/", "."+domain_name) ; mailPage(); /*SetCookie("mailPage","0",0,"/");*/}
if("1"==GetCookie("printPage"))
{DeleteCookie("printPage","/", "."+domain_name) ; printPage(); /*SetCookie("printPage","0",0,"/");*/}
trace("initialize finished<br>");}



function add_onout_event()
{E("popup").onmouseleave=restore_prev_val;}
function remove_onout_event()
{trace("remove_onout_event");E("popup").onmouseleave=null;addEvent(E("popup"),"mouseleave",function(){mouse_in_the_HP(0);});}
function restore_prev_val()
{if(E("popup").style.visibility=="visible")
{minimized=minimized_prev_state;show_acording_to_minim();}}
function attach_events_to_HLs_made()
{var fonts=window.document.body.getElementsByTagName("FONT");var temp="";for(i=0;i<fonts.length;i++)
{temp=fonts[i].getAttribute("active");if(temp!=null&&temp!="null")
{fonts[i].onmouseleave=function(){onmouseleave_HL();};fonts[i].onmouseover=function(){onmouseover_HL(event,null);};}}}
function delete_all_HL()
{var fonts=window.document.body.getElementsByTagName("FONT");var temp="";for(i=0;i<fonts.length;i++)
{temp=fonts[i].getAttribute("active");if(temp!=null&&temp!="null")delete_HL(temp,false);}}
function on_save_page_click()
{SAVE_PAGE_STATE=E("savep").getAttribute("CHECKED")?1:0;save_page("&reason=0");}
function set_chbox_state(saved_par)
{if(saved_par==1)
{E("savep").setAttribute("disabled",false);E("savep").setAttribute("checked",true);addEvent(E("savep"),"click",on_save_page_click);SAVE_PAGE_STATE=1;}
else if(saved_par==0)
{SAVE_PAGE_STATE=1;}
else if(saved_par==2)
{}}
function mouse_in_the_HP(is_in)
{
	HLS_ALLOWED=!is_in;
	//GRAB_PEN_STATE = HLS_ALLOWED ;
	if (is_in)
		{document.body.style.cursor = "default";}
	else if (GRAB_PEN_STATE)
		{document.body.style.cursor = "url(" + cur_curs + "), auto";}
}
function addNote(id)
{var idoc=window.document;var div_=null;var str="";if(id=="")
str="mama_";else
str="mama_"+id;div_=idoc.getElementById(str);try
{if(E("NOTE_INPUT").style.visibility=="hidden")
{E("AdNoteLink").innerText="save changes";if(div_!=null&&div_.text!="")
{E("NOTE_INPUT").value=div_.getAttribute("text");}
else
E("NOTE_INPUT").value="";E("NOTE_INPUT").style.visibility="visible";}
else
{E("AdNoteLink").innerText="add note";div_.setAttribute("text",E("NOTE_INPUT").value);var temp_str=E("NOTE_INPUT").value;E("COMMENTS_S").innerText=E("NOTE_INPUT").value;E("NOTE_INPUT").style.visibility="hidden";var reason="&reason=3&hlid="+id+"&text="+encodeURIComponent(temp_str);save_page(reason);}}
catch(ex)
{}}
function change_D_HL()
{if(vTimerID!=null)
{window.clearTimeout(vTimerID);vTimerID=null;}
else
{vTimerID=window.setTimeout("hide_popup();",500);}}

function grab()
{
/*alert(BrowserDetect());
if(BrowserDetect()!="Microsoft Internet Explorer")
	{
	txt=window.getSelection();
		if(txt!="")
		{
		alert("Please, please, please try this in Microsoft Internet Explorer.  \r\nThis functionality for your browser has not been publicly released yet.");
		return;
		}
	}
*/
if(HLS_ALLOWED==1&&GRAB_PEN_STATE==1&&getSelectionHTML()!="")
	change(0,0,-1,0,0);
if(GRAB_PEN_STATE==1)
	{
	document.body.style.cursor="url("+cur_curs+"), auto";
	trace("set cursor to "+cur_curs);
	}
}

function hide_delete_popup()
{trace("hide_delete_popup call");if(vTimerID!=null)window.clearTimeout(vTimerID);vTimerID=window.setTimeout("hide_popup();",100);}
function hide_popup()
{trace('hide_popup call');if($("tat_table")&&$("del_HL").style.visibility!="hidden")
return;$("del_HL").style.visibility="hidden";$("del_HL").style.display="none";$("clear_selection").onclick=null;$('Edit_wnd').style.visibility='hidden';}
function checkSelectedFromactb()
{var emailIds=$("populate_mails").getElementsByTagName("input");var selectedEmailId=$("mail_from").value;if(selectedEmailId.replace(" ","")=="")
{return;}
var iCounter;for(iCounter=0;iCounter<emailIds.length;iCounter++)
{if(selectedEmailId.replace(" ","")!=""&&selectedEmailId.indexOf(emailIds[iCounter].value)>=0)
{emailIds[iCounter].checked=true;break;}}}
function delete_HL(id,save_)
{trace('delete_HL: id ='+id+';save_ = '+save_);idoc=window.document;try
{var div_=null;div_=idoc.getElementById("mama_"+id);var arr_font=window.document.body.getElementsByTagName("FONT");var atr=null;for(i=0;i<arr_font.length;i++)
{atr=arr_font[i].getAttribute("active");if(atr==id)
{arr_font[i].style.backgroundColor="";arr_font[i].onmouseover=null;arr_font[i].onmouseleave=null;arr_font[i].setAttribute("active",null);}}
idoc.body.removeChild(div_);}
catch(ex)
{}
HL_counter--;hide_popup();var reason="&reason=2&hlid="+id;if(save_)save_page(reason);}
function delete_all_HL()
{try
{url=base_url+"get_all_hls.php";var data="all=1&url="+encodeURIComponent(E("url_word").value);do_post(url,data,call_back_delete);}
catch(ex)
{trace("Exception on restoring everyones hilights."+ex.message);}}
function call_back_delete(hls)
{if(hls.responseText!="ok")
{idoc=window.document;try
{document.getElementById('systemWorking').style.visibility='hidden';document.getElementById('systemWorking').style.display="none";document.getElementById('systemWorking').innerHTML="";for(index=0;index<text_arr.length;index++)
{var arr_font=window.document.body.getElementsByTagName("FONT");var atr=null;for(i=0;i<arr_font.length;i++)
{atr=arr_font[i].getAttribute("active");if(atr==id_arr[index])
{arr_font[i].style.backgroundColor="";arr_font[i].onmouseover=null;arr_font[i].onmouseleave=null;arr_font[i].setAttribute("active",null);}}}}
catch(ex)
{trace("error: "+ex.message);}}}
function show_delete_popup(selected_HL,pgX,pgY)
{
trace('show_delete_popup called');
try
{
	if(selected_HL==null) return;
	var id=selected_HL.getAttribute("active");
	if(id==null) id="";
	$("clear_selection").onclick=function(){delete_HL(id,true); trace("delete_HL "+id);};
	console.debug('event attached');
	console.debug('event attached');
	if(vTimerID!=null) window.clearTimeout(vTimerID);
	E("del_HL").style.top=pgY + "px";
	E("del_HL").style.left=pgX + "px";
	E("del_HL").style.visibility="visible";
	E("del_HL").style.display="inline";
}
catch(exc)
{console.error("show_delete_popup : "+exc.message);
}
}

function save_comments()
{}
function click()
{}
function onmouseleave_HL()
{console.debug('onmouseleave_HL');hide_delete_popup();}

function onmouseover_HL(evt)
{
console.debug('onmouseover_HL ');
var selected_HL;
var pgX;
var pgY;
if(evt!=null)
{
pgX=parseInt(evt.pageX);
pgY=parseInt(evt.pageY);
}
else{
evt=window.event;
pgY=parseInt(evt.clientY)+parseInt(getDocScrollTop());
pgX=parseInt(evt.clientX)+parseInt(getDocScrollLeft());
}
if(evt.target) selected_HL=evt.target;
else if(evt.srcElement) selected_HL=evt.srcElement;
if(selected_HL.nodeType==3)
selected_HL=selected_HL.parentNode;

//if(what!=null)selected_HL=what;
show_delete_popup(selected_HL,pgX,pgY);
}



function rgbToHex(rgb) { 
  var rgbvals = /rgb\((.+),(.+),(.+)\)/i.exec(rgb); 
  var rval = parseInt(rgbvals[1]); 
  var gval = parseInt(rgbvals[2]); 
  var bval = parseInt(rgbvals[3]); 
  var rs = rval.toString(16); if (rs=='0') rs='00';
  var gs = gval.toString(16); if (gs=='0') gs='00';
  var bs = bval.toString(16); if (bs=='0') bs='00';
  return '#' + ( 
    rs + 
    gs + 
    bs 
  ).toLowerCase(); 

} 

function change_others(not_save,color,id,date,comments)
{
//THIS IS A FUNCTION TO HIGHLIGHT FOR NON-IE BROWSERS

alert("This is the NON-IE version of Highlight Function");

//THIS IS A BROWSER DETECT OBJECT WHICH CAN DIFFERENTIATE BETWEEN SAFARI,CHROME,OPERA,FIREFOX UNLIKE CURRENT BROWSER DETECT FUNCTION

var BrowserDetect={init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS"},searchString:function(data){for(var i=0;i<data.length;i++){var dataString=data[i].string;var dataProp=data[i].prop;this.versionSearchString=data[i].versionSearch||data[i].identity;if(dataString){if(dataString.indexOf(data[i].subString)!=-1)return data[i].identity}else if(dataProp)return data[i].identity}},searchVersion:function(dataString){var index=dataString.indexOf(this.versionSearchString);if(index==-1)return;return parseFloat(dataString.substring(index+this.versionSearchString.length+1))},dataBrowser:[{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};BrowserDetect.init();

//END OF BROWSER DETECT OBJECT


if(HLS_ACTIVE==0&&ID_SAVED_PAGE==0)
	{
		alert("Heh, heh, not so fast. Please make a real hilight. \r\n Lets not fill up the database with junk hilights. \r\nPlease try again...");
		window.getSelection().removeAllRanges();
		document.body.style.cursor="url("+base_url+"images/cursors/busy.cur), wait";
		return 0;
	}
			
	selObj = window.getSelection();
	if (selObj.toString().length == 0)
		return;				//IF SELECTION IS EMPTY RETURN
		
	
	if(flag_from_restore!=1)
	{
		if(selObj.toString().length>=1024)		//IF MORE THAN 1024 CHARACTERS ARE HIGHLIGHTED CHECK IF THIS IS INTENDED
		{
			var c=confirm("Are you sure you want to highlight all this?");
			if(!c)
			{
				selObj.removeAllRanges();	
				return;
			}
		}
	}
	flag_from_restore=0;
		
				
	//THE BELOW LOGIC IS USED WHEN THE SELECTION IS MADE BOTTOM-UP(REVERSED), WE CHANGE THE START AND END OF SELECTION AND MAKE IT FORWARD INSTEAD OF BACKWARD
	
	range = document.createRange();
	range.setStart(selObj.focusNode, selObj.focusOffset);
	range.setEnd(selObj.focusNode, selObj.focusOffset);
	
	if (range.comparePoint(selObj.anchorNode,selObj.anchorOffset) == 1) //IF the selection is done reverse direction, we swap ends to make it forward direction.
	{
	var startNode = selObj.anchorNode;
	var startOffset = selObj.anchorOffset;
	window.getSelection().collapse(selObj.focusNode,selObj.focusOffset);
	window.getSelection().extend(startNode, startOffset);
	selObj = window.getSelection();
	}
	
	//END OF LOGIC TO CHANGE THE DIRECTION OF SELECTION OBJECT
	
	//CHECKING THAT THE FIRST NODE IS TEXT NODES ONLY. REQUIRED FOR RESTORING
	
	if (selObj.anchorNode.nodeType != 3 || selObj.anchorNode.textContent == "")
	{
	alert("Please Highlight Text Only");
	selObj.removeAllRanges();
	return;
	}
	
	//END OF CHECKING
	
	//BELOW IS THE LOGIC WHICH DETERMINES IF A NODE IS IN THE SELECTION BY COMPARING ITS END AND START POINTS WITH THAT OF SELECTION OBJECT RANGE
	
	sel_range = selObj.getRangeAt(0);
	inRange = function(node) 
					{ 
					//This function decides if the node is in the selection or out of based on end,start point comparison
					range_compare = document.createRange();
					range_compare.selectNode(node);
					
					if ( (sel_range.compareBoundaryPoints(Range.START_TO_START, range_compare) >= 0) && (sel_range.compareBoundaryPoints(Range.END_TO_END, range_compare) <= 0))
						{
						return NodeFilter.FILTER_ACCEPT;
						}
						
					else if( (sel_range.compareBoundaryPoints(Range.START_TO_START, range_compare) >= 0) && (sel_range.compareBoundaryPoints(Range.END_TO_END, range_compare) >= 0) && (sel_range.compareBoundaryPoints(Range.END_TO_START, range_compare) <= 0) )
						{
						return NodeFilter.FILTER_ACCEPT;
						}
						
					else if( (sel_range.compareBoundaryPoints(Range.START_TO_START, range_compare) <= 0) && (sel_range.compareBoundaryPoints(Range.END_TO_END, range_compare) <= 0) && (sel_range.compareBoundaryPoints(Range.START_TO_END, range_compare) >= 0) )
						{
						return NodeFilter.FILTER_ACCEPT;
						} 
						
					else if( (sel_range.compareBoundaryPoints(Range.START_TO_START, range_compare) <= 0) && (sel_range.compareBoundaryPoints(Range.END_TO_END, range_compare) >= 0))
						{
						return NodeFilter.FILTER_ACCEPT;
						} 
						
					else
						{
						return NodeFilter.FILTER_SKIP;
						}
						
					}
					
	//END OF LOGIC TO DETERMINE IF NODE IS IN SELECTION
	
	
	
	//DOING SOME HOUSEKEEPING IN ORDER TO GET THE DETAILS REQUIRED TO SAVE THE HIGHLIGHT.
	
	var path_=get_patch(selObj.anchorNode);
	var offset_=selObj.anchorOffset;
	var text_=selObj.toString();

	//END OF HOUSEKEEPING.
	
	//GETTING BEFORE HTML
	
	var html_bef_HL;
	var temp_div = document.createElement("div");
	temp_div.appendChild(sel_range.cloneContents());	
	html_bef_HL = temp_div.innerHTML;
	if(temp_div.firstChild != null && temp_div.firstChild.textContent == "")	//Some more checks.
	{
	alert("Please Highlight Text Only");
	selObj.removeAllRanges();
	return;
	}
		
	//END OF GETTING BEFORE HTML.
	
	
	var treeWalker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, inRange, true);	 //CREATING TREEWALKER OBJECT BASED ON ABOVE FUNCTION	
	
	
	//BELOWS IS THE LOGIC WHICH TRAVERSES THE TREEWALKER OBJECT CONTAINING THE NODES IN THE SELECTION OBJECT AND HIGHLIGHTING THEM ACCORDING TO TYPE
	//THERE CAN BE 4 TYPES OF NODES WHICH ARE A PART OF THE SELECTION OBJECT
	//1.) A NODE WHICH IS COMPLETELY SURROUNDS THE SELECTION, AS IN THE SELECTION LIES COMPLETELY WITHIN IT
	//2.) A START NODE OF SELECTION
	//3.) AN END NODE OF SELECTION
	//4.) A NODE WHICH IS COMPLETELY SURROUNDED BY THE SELECTION OBJECT, AS IN IT LIES BETWEEN THE START AND END NODE OF SELECTION
	
	//THE HIGHLIGHTING LOGIC INVOLVES EXTRACTING THE PART OF THE NODE WHICH IS IN THE SELECTION OBJECT BY COMPARING THE NODE TYPE AND THE OFFSET
	//NEXT WE CREATE DIFFERENT FONT NODES CONTAINING THE TEXT WHICH IS IN AND OUT OF THE SELECTION. 
	//WE REMOVE THE CURRENT TEXT OF THE NODE AND THEN APPEND THE NEWLY CREATED FONT NODES TO THE NODE.
	//WE THEN CHANGE THE BACKGROUND COLOR OF THE TEXT WHICH IS IN THE SELECTION OBJECT. 
	
	var y = treeWalker.nextNode();
	var safari_error = 0;
	var color_to_update=color==0?E("selectedColor").style.backgroundColor:color;
	var temp=(id==-1)?String(number_of_selections++):String(id);
	var affected=0;

	while (y)
	{
		var currentNode = treeWalker.currentNode;
		y = treeWalker.nextNode();
		if (currentNode.textContent.replace(/\s+/g,'').length == 0) continue;	//The regular expression removes white spaces. Takes care of text empty nodes.
		if ((currentNode == selObj.anchorNode) && (selObj.focusNode==currentNode))
		{
			//TYPE 1 NODE
			//alert("this is start and end node");
			var highliteContent = currentNode.textContent.substring(selObj.anchorOffset , selObj.focusOffset);
			var nonHighliteContent1 = currentNode.textContent.substring(0 , selObj.anchorOffset);
			var nonHighliteContent2 = currentNode.textContent.substring(selObj.focusOffset , currentNode.textContent.length);
			var highliteTextNode = document.createTextNode(highliteContent);
			var nonHighliteTextNode1 = document.createTextNode(nonHighliteContent1);
			var nonHighliteTextNode2 = document.createTextNode(nonHighliteContent2);
			var sp1 = document.createElement("font");
			var sp2 = document.createElement("font");
			sp2.appendChild(highliteTextNode);
			sp2.style.backgroundColor = color_to_update;
			sp2.setAttribute("active",temp);
			sp2.onmouseout=function(){onmouseleave_HL();};
			sp2.onmouseover=onmouseover_HL;
			affected=1;
			sp1.appendChild(nonHighliteTextNode1);
			sp1.appendChild(sp2);
			sp1.appendChild(nonHighliteTextNode2);
			currentNode.parentNode.replaceChild(sp1, currentNode);
			safari_error = 1;
		}
		
		else if (currentNode == selObj.anchorNode)
		{
			//TYPE 2 NODE
			//alert("this is the start node");
			var highliteContent = currentNode.textContent.substring(selObj.anchorOffset , currentNode.textContent.length);
			var nonHighliteContent = currentNode.textContent.substring(0 , selObj.anchorOffset);
			var highliteTextNode = document.createTextNode(highliteContent);
			var nonHighliteTextNode = document.createTextNode(nonHighliteContent);	
			var sp1 = document.createElement("font");	
			var sp2 = document.createElement("font");
			sp2.appendChild(highliteTextNode);
			sp2.style.backgroundColor = color_to_update;
			sp2.setAttribute("active",temp);
			sp2.onmouseout=function(){onmouseleave_HL();};
			sp2.onmouseover=onmouseover_HL;
			affected=1;	
			sp1.appendChild(nonHighliteTextNode);
			sp1.appendChild(sp2);
			currentNode.parentNode.replaceChild(sp1, currentNode);
		}
		
		else if(currentNode == selObj.focusNode)
		{
			//TYPE 3 NODE
			//alert("this is the end node");
			var highliteContent = currentNode.textContent.substring(0 , selObj.focusOffset);
			var nonHighliteContent = currentNode.textContent.substring(selObj.focusOffset , currentNode.textContent.length);
			var highliteTextNode = document.createTextNode(highliteContent);
			var nonHighliteTextNode = document.createTextNode(nonHighliteContent);		
			var sp1 = document.createElement("font");	
			var sp2 = document.createElement("font");
			sp2.appendChild(highliteTextNode);
			sp2.style.backgroundColor = color_to_update;
			sp2.setAttribute("active",temp);
			sp2.onmouseout=function(){onmouseleave_HL();};
			sp2.onmouseover=onmouseover_HL;
			affected=1;	
			sp1.appendChild(sp2);
			sp1.appendChild(nonHighliteTextNode);	
			currentNode.parentNode.replaceChild(sp1, currentNode);
		}
		
		else
		{
			//TYPE 4 NODE
			//alert("any other node");
			var sp1 = document.createElement("font");
			sp1.style.backgroundColor = color_to_update;
			sp1.setAttribute("active",temp);
			sp1.onmouseout=function(){onmouseleave_HL();};
			sp1.onmouseover=onmouseover_HL;
			affected=1;
			sp1.appendChild(currentNode.cloneNode(true));
			currentNode.parentNode.replaceChild(sp1, currentNode);
		}
	}
	

//END OF LOGIC TO HIGHLIGHT THE NODES WHICH ARE A PART OF THE SELECTION


//BELOW IS THE SECTION FOR SAFARI AND CHROME WHICH HAVE AN ERROR AS THEY DO NOT INCLUDE THE FIRST AND THE LAST NODE OF THE TREEWALKER OBJECT. 
//WE EXPLICITLY HIGHLIGHT THESE NODES FOR THESE BROWSERS

	var anchorNodeSel = selObj.anchorNode;
	var focusNodeSel = selObj.focusNode;
	var anchorOffsetSel = selObj.anchorOffset;
	var focusOffsetSel = selObj.focusOffset;
	
	if ((BrowserDetect.browser == "Safari" || BrowserDetect.browser == "Chrome") && safari_error == 0)
		{
			//Explicitly highliting the first node of the selection
			currentNode = anchorNodeSel;
			if (currentNode.nodeType == 3)
			{
			var highliteContent = currentNode.textContent.substring(anchorOffsetSel , currentNode.textContent.length);
			var nonHighliteContent = currentNode.textContent.substring(0 , anchorOffsetSel);
			var highliteTextNode = document.createTextNode(highliteContent);
			var nonHighliteTextNode = document.createTextNode(nonHighliteContent);	
			var sp1 = document.createElement("font");	
			var sp2 = document.createElement("font");
			sp2.appendChild(highliteTextNode);
			sp2.style.backgroundColor = color_to_update;
			sp2.setAttribute("active",temp);
			sp2.onmouseout=function(){onmouseleave_HL();};
			sp2.onmouseover=onmouseover_HL;
			affected=1;	
			sp1.appendChild(nonHighliteTextNode);
			sp1.appendChild(sp2);
			currentNode.parentNode.replaceChild(sp1, currentNode);
			}
		}
	
		if ((BrowserDetect.browser == "Safari" || BrowserDetect.browser == "Chrome") && safari_error == 0)
		{
			//Explicitly highliting the last node of the selection
			currentNode = focusNodeSel;
			if (currentNode.nodeType == 3)
			{
			var highliteContent = currentNode.textContent.substring(0 , focusOffsetSel);
			var nonHighliteContent = currentNode.textContent.substring(focusOffsetSel , currentNode.textContent.length);
			var highliteTextNode = document.createTextNode(highliteContent);
			var nonHighliteTextNode = document.createTextNode(nonHighliteContent);		
			var sp1 = document.createElement("font");	
			var sp2 = document.createElement("font");
			sp2.appendChild(highliteTextNode);
			sp2.style.backgroundColor = color_to_update;
			sp2.setAttribute("active",temp);
			sp2.onmouseout=function(){onmouseleave_HL();};
			sp2.onmouseover=onmouseover_HL;
			affected=1;	
			sp1.appendChild(sp2);
			sp1.appendChild(nonHighliteTextNode);	
			currentNode.parentNode.replaceChild(sp1, currentNode);
			}
		}
	
	
	//END OF LOGIC FOR SAFARI BUG CORRECTION
	
	//GETTING AFTER HTML
	
	var html_aft_HL;
	
	var treeWalker_aft_html = document.createTreeWalker(temp_div, NodeFilter.SHOW_TEXT, null, true);		
	var y = treeWalker_aft_html.nextNode();
	while (y)
	{
		var currentNode = treeWalker_aft_html.currentNode;
		y = treeWalker_aft_html.nextNode();
		if (currentNode.textContent.replace(/\s+/g,'').length == 0) continue;	//The regular expression removes white spaces. Takes care of text empty nodes.
		var sp1 = document.createElement("font");
		sp1.style.backgroundColor = "#FF0000";
		sp1.appendChild(currentNode.cloneNode(true));
		currentNode.parentNode.replaceChild(sp1, currentNode);
	}
	
	html_aft_HL = temp_div.innerHTML;
	
	//END OF GETTING AFTER HTML
	
	
	var mamaDiv=document.createElement("div");
	mamaDiv.style.position = "absolute";
	mamaDiv.style.backgroundColor = "#ff0000";
	mamaDiv.style.top = "0px";
	mamaDiv.style.left = "0px";
	mamaDiv.style.height = "100px";
	mamaDiv.style.width = "100px";
	mamaDiv.style.display = "none"; 
	mamaDiv.setAttribute("id","mama_"+temp);
	mamaDiv.setAttribute("html_bef_HL",html_bef_HL);
	mamaDiv.setAttribute("html_aft_HL",html_aft_HL);
	if(comments==0) mamaDiv.setAttribute("text"," ");
	else mamaDiv.setAttribute("text",comments);
	window.document.body.appendChild(mamaDiv);
	
	if(affected==1&&not_save==0)
	{
		HL_counter++;
		number_of_selections++;
		var reason="&reason=1&hlid="+temp+"&html_aft_hl="+encodeURIComponent(html_aft_HL)+"&html_bef_hl="+encodeURIComponent(html_bef_HL)+"&path_="+encodeURIComponent(path_)+"&offset_="+offset_+"&text_="+encodeURIComponent(text_)+"&color="+rgbToHex(E("selectedColor").style.backgroundColor);
		if(not_save==0) save_page(reason);
	}
	
	if(GRAB_PEN_STATE==1)
	{
	E("GRAB_PANE").innerHTML="Put Pen Down";
	E("HIGHTLIGHT_BUTTON").style.visibility="hidden";document.body.style.cursor="url("+cur_curs+"), auto";
	trace("set cursor to "+cur_curs);
	}	
	
	selObj.removeAllRanges();	//REMOVE ALL RANGES FROM SELECTION AND DESELECT THE SELECTION. THIS IS HAS BUG IN OPERA BUT NO OUT OF IT


}





function change(not_save,color,id,date,comments)
{
	
	if (BrowserDetect()!="Microsoft Internet Explorer")
	{
		change_others(not_save,color,id,date,comments);
		return;
	}
	
	alert("This is the IE version of Highlight Function");

	if(HLS_ACTIVE==0&&ID_SAVED_PAGE==0)
	{
		alert("Heh, heh, not so fast. Please make a real hilight. \r\n Lets not fill up the database with junk hilights. \r\nPlease try again...");
		document.selection.empty();
		document.body.style.cursor="url("+base_url+"images/cursors/busy.cur), wait";
		return 0;
	}
	var reason_save="";
	var textRange=null;
	textRange=createRange();
	var path_=get_patch(textRange);
	var offset_=get_offset_in_parent(textRange);
	var text_=getSelectionText();
	if(text_.length<=0)
	{
		return 0;
	}

	if(flag_from_restore!=1)
	{
		if(text_.length>=1024)
		{
			var c=confirm("Are you sure you want to highlight all this?");
			if(!c)
			{
				ClearSelection();
				return 0;
			}
		}
	}
	flag_from_restore=0;
	var html_bef_HL=getSelectionHTML();
	var affected=0;
	var color_to_update=color==0?E("selectedColor").style.backgroundColor:color;
	
	if (BrowserDetect()=="Microsoft Internet Explorer")
	{
		textRange.execCommand("BackColor","false",color_to_update);
	} 

	var temp=(id==-1)?String(number_of_selections++):String(id);
	
	try
	{
	var fonts=window.document.body.getElementsByTagName("FONT");
	for(i=0;i<fonts.length;i++)
	{
		if(fonts(i).onmouseleave==null&&fonts(i).onmouseover==null&&fonts(i).style.backgroundColor==color_to_update)
		{
			fonts[i].setAttribute("active",temp);
			fonts(i).onmouseleave=function(){onmouseleave_HL();};
			fonts(i).onmouseover=function(){onmouseover_HL(null);};
			affected=1;
		}
	}
	}
	catch(ex)
	{
	alert("error:"+ex.message);
	}
	var html_aft_HL=getSelectionHTML();
	var mamaDiv=window.document.createElement('<DIV   style = "position:absolute; background-color:#ff0000; top: 0px ; left: 0px; height: 100px; width:100px; display :none " ></DIV>');
	mamaDiv.setAttribute("id","mama_"+temp);
	mamaDiv.setAttribute("html_bef_HL",html_bef_HL);
	mamaDiv.setAttribute("html_aft_HL",html_aft_HL);
	if(comments==0) mamaDiv.setAttribute("text"," ");
	else mamaDiv.setAttribute("text",comments);
	window.document.body.appendChild(mamaDiv);
	
	if(affected==1&&not_save==0)
	{
		HL_counter++;
		number_of_selections++;
		var reason="&reason=1&hlid="+temp+"&html_aft_hl="+encodeURIComponent(html_aft_HL)+"&html_bef_hl="+encodeURIComponent(html_bef_HL)+"&path_="+encodeURIComponent(path_)+"&offset_="+offset_+"&text_="+encodeURIComponent(text_)+"&color="+E("selectedColor").style.backgroundColor;if(not_save==0)
save_page(reason);

	}
	if(GRAB_PEN_STATE==1)
	{
	E("GRAB_PANE").innerHTML="Put Pen Down";
	E("HIGHTLIGHT_BUTTON").style.visibility="hidden";document.body.style.cursor="url("+cur_curs+"), auto";
	trace("set cursor to "+cur_curs);
	}
	ClearSelection();
}
	
function getSelectionText()
{
	if(window.getSelection)
		return window.getSelection();
	else if(document.getSelection)
		return document.getSelection();
	else return document.selection.createRange().text;
}
function getSelectionHTML()
{
	if(window.getSelection)
		return window.getSelection();
	else if(document.getSelection)
		return document.getSelection();
	else return document.selection.createRange().htmlText;
}
function createRange()
{
	var userSelection;
	if (window.getSelection) {
		userSelection = window.getSelection();
		var rangeObject = getRangeObject(userSelection);
		return rangeObject;
	}
	else if (document.selection) { // should come last; Opera!
		userSelection = document.selection.createRange();
		return userSelection;
	}
}

function getRangeObject(selectionObject) 
{
	if (selectionObject.getRangeAt)
		return selectionObject.getRangeAt(0);
	else { // Safari!
		var range = document.createRange();
		range.setStart(selectionObject.anchorNode,selectionObject.anchorOffset);
		range.setEnd(selectionObject.focusNode,selectionObject.focusOffset);
		return range;
	}
}

function ClearSelection()
{
	if (window.getSelection) {
		window.getSelection.collapseToStart();
	}
	else if(document.selection)document.selection.empty();
	
}
var minimized_prev_state=0;function reduce()
{trace("reduce()");minimized=2;setMinimizedStateCookie();show_acording_to_minim();}
function unreduce()
{trace("<br>unreduce<br>");minimized_prev_state=minimized;minimized=0;setMinimizedStateCookie();show_acording_to_minim();}
function setMinimizedStateCookie()
{var expdate=new Date();FixCookieDate(expdate);expdate.setTime(expdate.getTime()+360000000);SetCookie("minimized",minimized,expdate,"/");}
function min_m_float_right()
{if(FLOAT_BOTTOM==1)
min_m_float_bot();if(FLOAT_RIGHT==1)
{FLOAT_RIGHT=0;E("minimized").style.top=prev_top+scroll_Top+'px';E("minimized").style.left=prev_left+scroll_Left+'px';}
else
{prev_top=parseInt(E("minimized").style.top)-scroll_Top;prev_left=parseInt(E("minimized").style.left)-scroll_Left;FLOAT_RIGHT=1;scroll_();}}
function min_m_float_bot()
{if(FLOAT_RIGHT==1)
min_m_float_right();if(FLOAT_BOTTOM==1)
{FLOAT_BOTTOM=0;E("minimized").style.top=prev_top+scroll_Top+'px';E("minimized").style.left=prev_left+scroll_Left+'px';}
else
{prev_top=parseInt(E("minimized").style.top)-scroll_Top;prev_left=parseInt(E("minimized").style.left)-scroll_Left;FLOAT_BOTTOM=1;scroll_();}}
function m_float_right()
{if(FLOAT_BOTTOM==1)
m_float_bottom();if(FLOAT_RIGHT==1)
{FLOAT_RIGHT=0;E("popup").style.top=prev_top+scroll_Top+'px';E("popup").style.left=prev_left+scroll_Left+'px';}
else
{prev_top=parseInt(E("popup").style.top)-scroll_Top;prev_left=parseInt(E("popup").style.left)-scroll_Left;FLOAT_RIGHT=1;scroll_();}}
function m_float_bottom()
{if(FLOAT_RIGHT==1)m_float_right();if(FLOAT_BOTTOM==1)
{FLOAT_BOTTOM=0;E("popup").style.top=prev_top+scroll_Top+'px';E("popup").style.left=prev_left+scroll_Left+'px';}
else
{prev_top=parseInt(E("popup").style.top)-scroll_Top;prev_left=parseInt(E("popup").style.left)-scroll_Left;FLOAT_BOTTOM=1;scroll_();}}
function scroll_w()
{}
function scroll_()
{var mv=2;var obj=null;if(minimized==0)
{obj=E("popup");}
else if(minimized==1)
{obj=E("minimized");mv=6;}
else if(minimized==2)
{obj=E("reduce");}
else{obj=E("login_row");}
var objtop=parseInt(obj.style.top)+(getDocScrollTop()-scroll_Top);obj.style.top=objtop+'px';if(objtop<getDocScrollTop())
{obj.style.top=getDocScrollTop()+"px";}
if(FLOAT_RIGHT==1)
{obj.style.top=getDocScrollTop()+"px";obj.style.left=window.document.body.clientWidth-parseInt(obj.style.width)-mv+getDocScrollLeft()+'px';}
if(FLOAT_BOTTOM==1)
{obj.style.top=window.document.body.clientHeight-parseInt(obj.style.height)+getDocScrollTop()+'px';obj.style.left=getDocScrollLeft()+'px';}
scroll_Top=getDocScrollTop();scroll_Left=getDocScrollLeft();}
function check_user()
{if(E('username').value=="admin"&&E("password").value=="admin")
{hideLoginForm();showBookmarkPage();}
else
E("ERROR_MSG").innerHTML='<span style = "background-color:#FF0000">Incorect login or password</span>';}
function showBookmarkPage()
{}
function hideLoginForm()
{E("loginForm").style.visibility="hidden";}
function show_tag_panel()
{if(TAG_PANEL_VISIBLE==1)
{E("show_tag_panel").caption="hide tag panel <<";show_tagging();}
else
{E("show_tag_panel").caption="show tag panel >>";}}
function tag_this_page()
{}
function exit()
{document.location.href="http://"+E("url_word").value;}
function show_tagging()
{tag_div=document.createElement("div");}
function show_login()
{trace("show_login()");minimized=3;show_acording_to_minim();makeTransparent();}
function unlogin()
{trace("unlogin()");E('ol').style.display='none';if(E("rooh_errorMSg"))
{E("rooh_errorMSg").style.display="none";}
minimized_prev_state=minimized;minimized=0;show_acording_to_minim();}
function ChangeMailAll()
{var st=$id('SendMailToAll').checked;var all=$class('email_recepients');for(var i=0;i<all.length;i++)
all[i].checked=st;}
function $class(ob,parent)
{var par=document.body;if(parent!=null)par=parent;var children=par.getElementsByTagName('*');var v=[];for(var a=0;a<children.length;a++)if(children[a].className==ob)v[v.length]=children[a];return v;}
function $id(ob)
{return document.getElementById(ob);}
var email_item;function validateEmail(email)
{var emailPattern=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;to_arr=email.split(",");for(i=0;i<to_arr.length;i++)
{var addy=to_arr[i];var strt=addy.indexOf("<");var endof=addy.indexOf(">");if(strt>-1&&endof>-1)
{addy=addy.substring(strt+1,endof);}
addy=trim(addy);if(addy!="")
{if(!emailPattern.test(addy))
{return false;}}}
return true;}
function SendMail()
{ if('Your E-mail Address'==document.getElementById('from_mob').value) document.getElementById('from_mob').value='';
var email_adresses=$id('mail_from').value;var emails=$class('email_recepients');for(var i=0;i<emails.length;i++)
if(emails[i].checked)
{if(emails[i].value!="")
{if(email_adresses=="")
email_adresses+=emails[i].value;else
email_adresses+=','+emails[i].value}}
if(email_adresses.indexOf(",")==0)email_adresses=email_adresses.substring(1);if(email_adresses=="")
{if(arguments.length>0&&arguments[0]==2)
{return false;}
alert("Enter recipients, or select e-mail address from your contacts");E('ol').style.display='none';return false;}
var arr=document.getElementsByTagName("html");var data=arr[0].outerHTML;if(data==null)
data=arr[0].innerHTML;if(validateEmail(email_adresses))
{send_mail(data,email_adresses,"MOB");}
else
{alert("Please enter a valid E-Mail Address");return false;}
hide_popup();}
function BrowserDetect()
{var bName=navigator.appName;var bVer=parseFloat(navigator.appVersion);if(bName=="Netscape")
var browser="Netscape Navigator"
else
var browser=bName;return browser;}
function cursorNotBusy()
{document.body.style.cursor="url("+cur_curs+"), auto";}
function validData()
{datas="";fname="";lastname="";error="";uemail="";if(document.frm.name_errors.value=="name_error")
{if(document.frm.fname.value=="")
{alert("Please enter your First Name")
document.frm.fname.focus();return false;}
if(document.frm.lastname.value=="")
{alert("Please enter your Last Name")
document.frm.lastname.focus();return false;}
fname=document.frm.fname.value;lastname=document.frm.lastname.value;error=document.frm.name_errors.value;fcall=document.frm.functioncall.value;}
if(document.frm.name_errors.value=="email_error")
{if(document.frm.emailaddress.value=="")
{alert("Please enter your E-Mail Address")
document.frm.emailaddress.focus();return false;}
if(document.frm.emailaddress.value!="")
{var re=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;if(!document.frm.emailaddress.value.match(re))
{alert("Please Enter Your Valid E-Mail Address");document.frm.emailaddress.focus();return false;}}
if(document.frm.fname.value=="")
{alert("Please enter your First Name");document.frm.fname.focus();return false;}
if(document.frm.lastname.value=="")
{alert("Please enter your Last Name")
document.frm.lastname.focus();return false;}
uemail=document.frm.emailaddress.value;error=document.frm.name_errors.value;fname=document.frm.fname.value;fcall=document.frm.functioncall.value;lastname=document.frm.lastname.value;document.getElementById('sesid').value=document.frm.usess_id.value;}
Adduser(fname,lastname,uemail,error,fcall)
CancelAdd();return false;}
function checkData(udata)
{document.getElementById('systemWorking').innerHTML=udata.responseText;if(udata.responseText=="Ndone")
{emaildatas=document.getElementById('hidden_uemail').value;document.getElementById('systemWorking').innerHTML="";document.getElementById('systemWorking').style.visibility='hidden'
var arr=document.getElementsByTagName("html");var data=arr[0].outerHTML;if(data==null)data=document.getElementsByTagName("html")[0].innerHTML;send_mail(data,emaildatas,"HP");}
if(udata.responseText=="Edone")
{emaildatas=document.getElementById('hidden_uemail').value;document.getElementById('systemWorking').innerHTML="";document.getElementById('systemWorking').style.visibility='hidden'
var arr=document.getElementsByTagName("html");var data=arr[0].outerHTML;if(data==null)data=document.getElementsByTagName("html")[0].innerHTML;send_mail(data,emaildatas,"HP");}}
function Adduser(fname,lastname,uemail,error,fucntioncall)
{try
{var cur_adr=E("url_word").value;url=base_url+"init.php";var data="act=add_user&mails="+uemail+"&fname="+encodeURIComponent(fname)+"&sesid="+E("sesid").value+"&lastname="+lastname+"&error="+error+"&url="+cur_adr;if(fucntioncall=="")
do_post(url,data,checkData);else
do_post(url,data,checkFriendData);}
catch(ex)
{trace("exception on sending mail: "+ex.message);}}
function CancelAdd()
{document.getElementById('systemWorking').innerHTML="";document.getElementById('systemWorking').style.visibility='hidden';return false;}
function isValid()
{if(document.frm_login.provider.value==""){document.frm_login.provider.focus();alert("Please select a Provider");return false;}
if(document.frm_login.username.value==""){alert("Please enter a Username");document.frm_login.username.focus();return false;}
if(document.frm_login.password.value==""){alert("Please enter a Password");document.frm_login.password.focus();return false;}
if(document.frm_login.terms.checked==false){alert("Please agree to the Terms of Service");return false;}
minimized=0;save_state();return true;}
function isValidHPLogin()
{if(document.frm_login.provider.value==""){document.frm_login.provider.focus();alert("Please select a Provider");return false;}
if(document.frm_login.username.value==""){alert("Please enter a Username");document.frm_login.username.focus();return false;}
if(document.frm_login.password.value==""){alert("Please enter a Password");document.frm_login.password.focus();return false;}
return true;}
function showHPLogin()
{hide_mob();show_login();makeTransparent();document.frm_login.action="javascript: return false;";document.frm_login.submit.value="Login and Send";document.frm_login.cancel.value="Skip";E("UserNameRow").style.display="block";E("rooh_logos").style.display="none";E("rooh_loginboxtitle").innerHTML='<b>Enter your Name & E-mail address</b>';E("rooh_loginmsg").innerHTML='<h3>Validate Your E-mail:</h3> (to prevent spam)';if(arguments.length>0)
{document.frm_login.submit.onclick=importContacts;document.frm_login.cancel.onclick=MOB_hideHPLogin;}
else
{document.frm_login.submit.onclick=ValidateAndSendMail;document.frm_login.cancel.onclick=HP_hideHPLogin;}}
function hideHPLogin()
{alert("Please login to prevent anonymous spammers from e-mailing.");document.frm_login.submit.onclick=isValid;document.frm_login.cancel.onclick=unlogin;document.frm_login.submit.value="Login";document.frm_login.cancel.value="Cancel";E("rooh_logos").style.display="block";E("UserNameRow").style.display="none";E("rooh_loginboxtitle").innerHTML='<b>Login</b>';E("rooh_loginmsg").innerHTML='Use any of your accounts to login:';unlogin();}
function HP_hideHPLogin()
{send_mail_HP(1);hideHPLogin();}
function MOB_hideHPLogin()
{MOBSendMail(2);hideHPLogin();}
function MOBSendMail()
{makeTransparent();if((MOBSendMail.arguments.length>0)&&(typeof arguments[0]!='object')){return ValidateAndSendMail(2);}
else{return ValidateAndSendMail(1);}}
function ValidateAndSendMail()
{if(arguments.length==0||arguments[0]!=2||(typeof arguments[0]=='object'))
{var Validated=isValidHPLogin();if(!Validated)
{return Validated;}}
makeTransparent();hideHPLogin();if((arguments.length>0)&&(typeof arguments[0]!='object'))
{return SendMail(arguments[0]);}
else
return send_mail_HP();}
function AddToFriendList()
{eaddress=document.getElementById("friends_address").value;document.getElementById('hidden_uemail').value=eaddress;if(test_mail(eaddress))
{usesid=document.getElementById('sesid').value
url=base_url+"init.php";var data="act=add_friendList&eaddress="+eaddress+"&usesid="+usesid;do_post(url,data,checkFriendData);}
else
alert("Please enter a valid E-Mail Address");return false;}
function checkFriendData(udata)
{if(udata.responseText!="ok"&&udata.responseText!="Ndone"&&udata.responseText!="Edone"&&udata.responseText!="bad"&&udata.responseText!="wrong")
{document.getElementById('systemWorking').innerHTML=udata.responseText;}
else if(udata.responseText=="Ndone")
{if(document.getElementById("friends_address").value=="")
document.getElementById("friends_address").value=document.getElementById('hidden_uemail').value;AddToFriendList();}
else if(udata.responseText=="Edone")
{if(document.getElementById("friends_address").value=="")
document.getElementById("friends_address").value=document.getElementById('hidden_uemail').value;AddToFriendList();}
else if(udata.responseText=="ok")
{alert("Your request has been sent successfully");}
else if(udata.responseText=="bad")
{alert("The person at this e-mail is already in your list!");}
else if(udata.responseText=="wrong")
{alert("You can't add yourself");}
setTimeout("hide_system()",3000);}
function hide_system(){document.getElementById('systemWorking').style.visibility='hidden';document.getElementById('systemWorking').style.display="none";document.getElementById('systemWorking').innerHTML='';}
function closeEDUCATE()
{if(document.getElementById('EDUCATE'))
document.getElementById('EDUCATE').style.visibility='hidden';}
function openEDUCATE()
{if(document.getElementById('EDUCATE'))
{document.getElementById('EDUCATE').style.visibility='visible';}}
function pageWidth()
{return window.innerWidth!=null?window.innerWidth:document.documentElement&&document.documentElement.clientWidth?document.documentElement.clientWidth:document.body!=null?document.body.clientWidth:null;}
function pageHeight()
{return window.innerHeight!=null?window.innerHeight:document.documentElement&&document.documentElement.clientHeight?document.documentElement.clientHeight:document.body!=null?document.body.clientHeight:null;}
function posLeft()
{return typeof window.pageXOffset!='undefined'?window.pageXOffset:document.documentElement&&document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft?document.body.scrollLeft:0;}
function posTop()
{return typeof window.pageYOffset!='undefined'?window.pageYOffset:document.documentElement&&document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop?document.body.scrollTop:0;}
function $(x)
{return document.getElementById(x);}
function scrollFix()
{var obol=$('ol');obol.style.top=posTop()+'px';obol.style.left=posLeft()+'px';}
function sizeFix()
{var obol=$('ol');obol.style.height=pageHeight()+'px';obol.style.width=pageWidth()+'px';}
function kp(e)
{ky=e?e.which:event.keyCode;if(ky==88||ky==120)hm();return false;}
function inf(h)
{tag=document.getElementsByTagName('select');for(i=tag.length-1;i>=0;i--)
{if(tag[i].name='provider')
continue;tag[i].style.visibility=h;}
tag=document.getElementsByTagName('iframe');for(i=tag.length-1;i>=0;i--)
tag[i].style.visibility=h;tag=document.getElementsByTagName('object');for(i=tag.length-1;i>=0;i--)
tag[i].style.visibility=h;}
function sm(obl,wd,ht)
{var h='hidden';var b='block';var p='px';var obol=$('ol');var obbxd=$('mbd');obbxd.innerHTML=$(obl).innerHTML;obol.style.height=pageHeight()+p;obol.style.width=pageWidth()+p;obol.style.top=posTop()+p;obol.style.left=posLeft()+p;obol.style.display=b;var tp=posTop()+((pageHeight()-ht)/2)-12;var lt=posLeft()+((pageWidth()-wd)/2)-12;var obbx=$('mbox');obbx.style.top=(tp<0?0:tp)+p;obbx.style.left=(lt<0?0:lt)+p;obbx.style.width=wd+p;obbx.style.height=ht+p;obbx.style.display=b;inf(h);hideCheckBox();return false;}
function hm()
{var v='visible';var n='none';$('ol').style.display=n;$('mbox').style.display=n;inf(v);document.onkeypress='';}
function initmb()
{document.getElementById('subject').value=document.title;var ab='absolute';var n='none';var obody=document.getElementsByTagName('body')[0];var frag=document.createDocumentFragment();var obol=document.createElement('div');obol.setAttribute('id','ol');obol.style.display=n;obol.style.position=ab;obol.style.top=0;obol.style.left=0;obol.style.zIndex=998;obol.style.width='100%';frag.appendChild(obol);var obbx=document.createElement('div');obbx.setAttribute('id','mbox');obbx.style.display=n;obbx.style.position=ab;obbx.style.zIndex=999;var obl=document.createElement('span');obbx.appendChild(obl);var obbxd=document.createElement('div');obbxd.setAttribute('id','mbd');obl.appendChild(obbxd);frag.insertBefore(obbx,obol.nextSibling);obody.insertBefore(frag,obody.firstChild);window.onscroll=scrollFix;window.onresize=sizeFix;}
function okSelected()
{if(document.getElementById("dntagain").checked==true)
{var timeNow=new Date();FixCookieDate(timeNow);var timeInMiliSec=timeNow.getTime();if(!isCookieSet("dontshow"))
{timeNow.setTime(timeNow.getTime()+2592000);}
else
{timeInMiliSec=0;timeNow.setTime(timeNow.getTime()+7776000);}
SetCookie("dontshow",timeInMiliSec,timeNow,"/");}}
function makeTransparent()
{var h='hidden';var b='block';var p='px';var obol=$('ol');if(!obol)
{var obol=document.createElement('div');obol.setAttribute('id','ol');}
obol.style.height=pageHeight()+p;obol.style.width=pageWidth()+p;obol.style.top=posTop()+p;obol.style.left=posLeft()+p;obol.style.display=b;}
function printPage()
{if(window.print)
{window.print();}
else
{alert("Sorry, your browser doesn't support this feature.");}}
function mailPage()
{/*alert("I am inside the mailPage function") ;*/ mail_str="mailto:?subject=Check this out ";mail_str+="&body=I think this will interest you "+location.href;location.href=mail_str;}
function hideCheckBox()
{var HLsDone=parseInt(GetCookie("numOfHLs"));var numSent=parseInt(GetCookie("emSent"));if((HLsDone<7)&&(numSent<3))
{document.getElementById("dontshowcb").style.display='none';}
else
{document.getElementById("dontshowcb").style.display='';}}
function saveUrl()
{var second=document.getElementById('newurl').value;

if (second.length < 5) {alert ("URL is too short, need 5 characters at least"); CloseEdit(); return;}

var elem=document.getElementById('shortcuturl');var old=elem.value;var index=old.lastIndexOf('/');var edit=old.substr(index+1);var nonedit=old.substr(0,index+1);var url='/site/Checksc.php';var pars="id="+edit+"&val="+second+"&task=updatesc";var target='';new Ajax.Request(url,{method:'get',parameters:pars,onSuccess:function(transport){var response=transport.responseText||"no response text";if(response=='success'){CloseEdit();


document.getElementById('del_HL').style.display = 'none'; 
var newsc=nonedit+""+second;
sm('newShortcutIdDlg',400,70); 
document.getElementById('resultsc').innerHTML="Send this link to your friends so they can see the highlights directly at <b><br/><br/>"+newsc+"</b>";
elem.value=newsc;

}


else{CloseEdit();alert('invalid url');return false;}},onFailure:function(){alert('Something went wrong...');return false}});}
function CloseEdit()
{$id('Edit_wnd').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;}
function ShowEditWnd()
{document.getElementById('edit_sc').className='send';document.getElementById('edtmob_cancel').className='send';var elem=document.getElementById('shortcuturl');var old=elem.value;var index=old.lastIndexOf('/');var edit=old.substr(index+1);var nonedit=old.substr(0,index+1);document.getElementById('oldurl').innerHTML=nonedit;document.getElementById('oldurl').style.width='auto';document.getElementById('newurl').value=edit;var sm=document.getElementById('Edit_wnd');sm.style.left=findPosX(elem)-100+'px';sm.style.top=findPosY(elem)-10+'px';sm.style.display='inline';sm.style.visibility="visible";sm.focus();

document.getElementById('newurl').select();
}


function setDlgData(elem)
{elem.className='send_disabled';var email_adresses=$id('mail_from2').value;var emails=$class('email_recepients1');for(var i=0;i<emails.length;i++)
{if(emails[i].checked)
{if(emails[i].value!="")
{if(email_adresses=="")
email_adresses+=emails[i].value;else
email_adresses+=','+emails[i].value;}}}
if(email_adresses.indexOf(",")==0)
email_adresses=email_adresses.substring(1);if(email_adresses=="")
{alert("Enter the e-mail address to send to");elem.className="send";return false;}
hideBox();elem.className="send";var arr=document.getElementsByTagName("html");var data=arr[0].outerHTML;if(data==null)data=arr[0].innerHTML;send_mail(data,email_adresses,"SendMailDialog");}
function setEmailData()
{$id('mail_from').value=$id('mail_from1').value;;}
function setDisplay()
{var nsdca=GetCookie('id');var dhaae=GetCookie('c6346359c72f0d28e27a');if((dhaae!='29b77ff80658375b3bbe'))
{document.getElementById('loginblk').style.display='block';document.getElementById('sendmail_blk').style.display='none';document.getElementById('btmtxt').style.visibility='visible';document.getElementById('manualsend').style.display="none";document.getElementById('imptxt').style.display='block';document.getElementById('imptxt').style.visibility='visible';document.getElementById('emailtxt').style.display='none';document.getElementById('emailtxt').style.visibility='hidden';}
else
{document.getElementById('loginblk').style.display='none';document.getElementById('sendmail_blk').style.display='block';document.getElementById('btmtxt').style.visibility='hidden';document.getElementById('manualsend').style.display="none";document.getElementById('imptxt').style.display='none';document.getElementById('imptxt').style.visibility='hidden';document.getElementById('emailtxt').style.display='block';document.getElementById('emailtxt').style.visibility='visible';}}
function checkOption(elem)
{for(var i=0;i<elem.options.length;i++)
{if(elem.options[i].selected)
{if(elem.options[i].value=="manual")
{document.getElementById('loginblk').style.display="none";document.getElementById('manualsend').style.display="block";document.getElementById('provider1').selectedIndex=6;document.getElementById('btmtxt').style.visibility='hidden';}
else
{if(elem.id=="provider1")
{var elem1=document.getElementById('provider2');elem1.selectedIndex=elem.selectedIndex;}
document.getElementById('manualsend').style.display="none";document.getElementById('loginblk').style.display="block";}}}}
function sendmailDlg(elem)
{elem.className='send_disabled';hideBox();elem.className="send";email_addresses=document.getElementById('fmail').value;var arr=document.getElementsByTagName("html");var data=arr[0].outerHTML;if(data==null)data=arr[0].innerHTML;makeTransparent();send_mail(data,email_addresses,"SendMailDialog");}
function importContacts()
{if(arguments.length>0)
{elem=arguments[0];elem.className='send_disabled';try
{url=base_url+"login_dlg.php";var user=document.getElementById('mail_from1').value;var password=document.getElementById('pwddlg').value;if(user&&password)
{document.getElementById('mail_from1').disabled=true;document.getElementById('pwddlg').disabled=true;var prov=document.getElementById('provider2').value;data="username="+encodeURIComponent(user)+"&password="+encodeURIComponent(password)+"&provider="+encodeURIComponent(prov);do_post(url,data,showContactList);}
else
{alert("Username/Password fields cannot be empty");elem.className='send';return false;}}
catch(ex)
{trace("exception on importing contacts"+ex.message);}}
else
{try
{url=base_url+"login_dlg.php";var user=document.frm_login.username.value;var password=document.frm_login.password.value;if(user&&password)
{var prov=document.frm_login.provider.value;data="username="+encodeURIComponent(user)+"&password="+encodeURIComponent(password)+"&provider="+encodeURIComponent(prov);do_post(url,data,loginSend);}
else
{alert("Username/Password fields cannot be empty");return false;}}
catch(ex)
{trace("exception on importing contacts"+ex.message);}}}
function loginSend(xhReq)
{var res=xhReq.responseText.trim();if(res=="error")
{alert('Invalid login, please try again');}
else
{hideHPLogin();SendMail();}}
function showContactList(xhReq)
{var res=xhReq.responseText.trim();document.getElementById('mail_from1').disabled=false;document.getElementById('pwddlg').disabled=false;if(res=="error")
{alert('Invalid login, please try again');document.getElementById('importbtn').className='send';}
else
{document.getElementById('imptxt').style.display='none';document.getElementById('imptxt').style.visibility='hidden';document.getElementById('emailtxt').style.display='block';document.getElementById('emailtxt').style.visibility='visible';document.getElementById('loginblk').style.display='none';document.getElementById('importbtn').className='send';document.getElementById('sendmail_blk').style.display='block';var pm=document.getElementById('populate_mails1');document.getElementById('btmtxt').style.visibility='hidden';pm.innerHTML=res;}}
function showSkip()
{document.getElementById('skiplink').style.visibility='visible';}
function checkSelectedFromactb2()
{var emailIds=$("populate_mails1").getElementsByTagName("input");var selectedEmailId=$("mail_to").value;if(selectedEmailId.replace(" ","")=="")
{return;}
var iCounter;for(iCounter=0;iCounter<emailIds.length;iCounter++)
{if(selectedEmailId.replace(" ","")!=""&&selectedEmailId.indexOf(emailIds[iCounter].value)>=0)
{emailIds[iCounter].checked=true;break;}}}
function hideBox()
{okSelected();var elem=document.getElementById('box');document.getElementById('skiplink').style.visibility='hidden';elem.style.display="none";elem.style.visibility="hidden";E('ol').style.display='none';}
function showBox(divid){
//if (if(BrowserDetect()=="Microsoft Internet Explorer")) {
var elem=document.getElementById(divid);var p='px';
var tp=posTop()+((pageHeight()-150)/2)-100;var lt=posLeft()+((pageWidth()-250)/2)-130;elem.style.top=(tp<0?0:tp)+p;elem.style.left=(lt<0?0:lt)+p;elem.style.display="block";elem.style.visibility="visible";hideCheckBox();makeTransparent();setDisplay();setTimeout("showSkip()",3000);
//}
}
function ChangeMailAll1()
{var st=$id('SendMailToAll1').checked;var pm=document.getElementById('populate_mails1');var elems=pm.getElementsByTagName('input');for(var i=0;i<elems.length;i++)
elems[i].checked=st;}
function sendKey()
{if(window.event&&window.event.keyCode==13)
{var elem=document.getElementById('sendDlgBtn');setDlgData(elem);}}
function showLoginAlert()
{if(''==GetCookie('id'))
{sm('plsLogin',300,100);}
else{window.location=base_url+'site/view1.php';}}
function incrementCookie(cookieName,expiration)
{var cookieVal=parseInt(GetCookie(cookieName));cookieVal++;var expTime=new Date();FixCookieDate(expTime);expTime.setTime(expTime.getTime()+expiration);SetCookie(cookieName,cookieVal,expTime,"/");}
function showGoAlert()
{alert('Please enter a website address URL to go to');}
function okAbtTips() 
{
var elem=document.getElementById('tipsbox');elem.style.display="none";elem.style.visibility="hidden";E('ol').style.display='none';
}
/*
function areCookiesEnabled()
{
	var expdate = new Date ();
	FixCookieDate (expdate);
	expdate.setTime (expdate.getTime() + 3000);
	SetCookie("rctest", "test", expdate, "/") ; 
	if ( "test" != GetCookie("rctest") )
	{
		alert ("cookies are disabled") ;
	}
}
*/
