//// Client side interactive cookie starring script
//// Writen by samuel odofin 2006.
////http://www.odofin.com/sam. Call on me at anytime samuelodofin[at]yahoo[dot]com

function downs(){
document.execCommand('saveAs', false, null)
}

function printe(){
var gAutoPrint = false;

if(redit.document.body.innerHTML == 0 ){
alert('Oops Your page is empty, theres nothing to format'); return false;
}else{
	if (document.getElementById != null)
	{
		var html = '<HTML>\n<HEAD>\n';

		if (document.getElementsByTagName != null)
		{
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
				html += headTags[0].innerHTML;
		}
		
		html += '\n</HE' + 'AD>\n<BODY>\n';
		html +=  "<p>&nbsp;</p><div id=\"printer\"><p><a href='javascript:window.print()' title=\"Print\"><img src=\"images/print.gif\" border=\"0\"></a><br>&nbsp;&nbsp;"
if(navigator.appName != "Microsoft Internet Explorer"){
}else{
		html +=	"<br><a href=\"#\" onclick=\"downs()\" title=\"dowload or Save page,Microsoft Internet exlorer Only\"><img src=\"images/download.gif\" border=\"0\"></a></div><p></p>"
}
		
		var printReadyElem = redit.document.body.innerHTML;
		
		if (printReadyElem != null)
		{
				html += printReadyElem
		}
		else
		{
			alert("Oops theres no page to print ");
			return;
		}
				
		html += '\n</BO' + 'DY>\n</HT' + 'ML>';
		
		var printWin = window.open("","printSpecial");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();
	}
	else
	{
		alert("Sorry, this feature is only available in modern browsers.");
	}
}
}

function setCookie(name,value,days,path,domain,secure) {
  var expires, date;
  if (typeof days == "number") {
    date = new Date();
    date.setTime( date.getTime() + (days*24*60*60*1000) );
		expires = date.toGMTString();
  }
  document.cookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function getCookie(name) {
  var nameq = name + "=";
  var c_ar = document.cookie.split(';');
  for (var i=0; i<c_ar.length; i++) {
    var c = c_ar[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameq) == 0) return unescape( c.substring(nameq.length, c.length) );
  }
  return null;
}


function writerr(){
var vali = redit.document.body.innerHTML;
var wre = vali
var fso, f1, ts;
var ForWriting = 2;
fso = new ActiveXObject("Scripting.FileSystemObject");
fso.CreateTextFile ("c:\\psych.txt");
f1 = fso.GetFile("c:\\psych.txt");
ts = f1.OpenAsTextStream(ForWriting, true);
ts.WriteLine(wre)
ts.Close()
alert('page saved');
location.reload();
}

function stoperror(){
return true
}
window.onerror=stoperror



function getval(){
if(navigator.appName == "Netscape"){
document.getElementById('redit').contentDocument.designMode = 'On';
redit.document.execCommand('styleWithCSS', true);
}else{
redit.document.designMode = 'On'
}
var ForReading = 1
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.OpenTextFile("c:\\psych.txt", ForReading);
var rib =  f.ReadAll();
redit.document.body.innerHTML = rib;
}

//// Client side interactive cookie starring script and Research
//// Writen by samuel odofin 2006.
////http://www.odofin.com/sam. Call on me at anytime samuelodofin[at]yahoo[dot]com

function cpo(){
redit.focus();
CopiedTxt = redit.document.selection.createRange();
CopiedTxt.execCommand('Copy');
}

function paster(){
redit.focus();
redit.document.execCommand('paste', false, null);
}

function inn(){
redit.focus();
redit.document.execCommand('indent', false, null);
}

function ouut(){
redit.focus();
redit.document.execCommand('outdent', false, null);
}




function add(something){
var bush = redit.document.body.innerHTML;
var late = bush + something;
redit.document.body.innerHTML = late;
}

function bolder(){
redit.document.execCommand('bold', false, null);
}

function underl(){
redit.document.execCommand('underline', false, null);
}

function udo(){
redit.document.execCommand('undo', false, null);
}

function rdo(){
redit.document.execCommand('redo', false, null);
}

function ita(){
redit.document.execCommand('italic', false, null);
}

function Olip(){
redit.focus();
redit.document.execCommand('InsertorderedList', false, null);
}


function unoli(){
redit.focus();
redit.document.execCommand('InsertUnorderedList', false, null);
}

function addimgs(){
redit.focus();
if(navigator.appName == "Netscape"){
   imagePath = prompt('Enter Image URL:', 'http://');
    if ((imagePath != null) && (imagePath != "")) {
      document.getElementById('redit').contentWindow.document.execCommand('InsertImage', false, imagePath);
    }
}else{
redit.document.execCommand('InsertImage', true, null);
}
}


function rulerh(){
redit.focus();
redit.document.execCommand('inserthorizontalrule',false,null);
}


function fci(){ 
var fCol = prompt('Enter foreground color', 'black'); 

if(fCol != null) 
redit.document.execCommand('forecolor', false, fCol); 
}

function bci(){ 
var fCol = prompt('Enter foreground color', 'white'); 

if(fCol != null) 
redit.document.execCommand('Backcolor', false, fCol); 
} 


function Fonte(fName) 
{ 
if(fName != '') 
redit.document.execCommand('fontname', false, fName); 
}

function Fontee(fName) 
{ 
if(fName != '') 
redit.document.execCommand('fontsize', false, fName); 
}

function header(heType)
{ 
if(heType != '') 
{ 
redit.document.execCommand('formatblock', false, heType); 
fonter(seleFont.options[selFont.selectedIndex].value); 
} 
} 


function mcenter(){
redit.document.execCommand('justifycenter', false, null);
redit.focus();
}

function mleft(){
redit.document.execCommand('justifyleft', false, null);
redit.focus();
}

function mright(){
redit.document.execCommand('justifyright', false, null);
redit.focus();
}
 



function destroi(){
redit.document.body.innerHTML = "";
}


function stoperror(){
return true
}
window.onerror=stoperror

function rload(){
var dru = document.getElementById('fpage');
dru.src = "star_in.htm";
}

function deall(){
if (bless != null){
var hi = "all data has been flushed";
var mitext = window.confirm('You are about to delete all pages you flagged this action cannot be reverse do you want to continue?.');
if (mitext) {
deleteCookie('starred','');
window.alert(hi);
var dru = document.getElementById('fpage');
dru.src = "star_in.htm";
} else  window.alert("Action Arboted");
}else{
window.alert("Ooops you didnt flag any page yet see help for more on using this feature")
}

}



