/* Selects All Check Boxes */

function sel(form,hidden)

{

	var a=new Array();

	

	for(i=0;i<document.form.elements.length;i++) 

	{

	document.form.elements[i].checked=true;

	if(document.form.elements[i].checked && document.form.elements[i].name=="checkbox" && document.form.elements[i].type=="checkbox")

		{ 

			if(a=="") a+=document.form.elements[i].value;

			else a+="|"+document.form.elements[i].value;

			document.form.hidden.value=a; }

	}

}

/*	-	-	-	-	-	-	-	-	-	*/



/* Unselects All Selected Check Boxes */

function unsel(form,hidden)

{

	for(i=0;i<document.form.elements.length;i++) 

	{

		document.form.elements[i].checked=false;

		document.form.hidden.value='';

	}

}

/*	-	-	-	-	-	-	-	-	-	*/

/* Send Data To The Hidden Field */






function hid(form,hidden)

{
	var a=new Array();

	for(i=0;i<document.form.elements.length;i++)

	

		if(document.form.elements[i].checked && document.form.elements[i].name=="checkbox")

			if(a=="") a+=document.form.elements[i].value;

			else a+="|"+document.form.elements[i].value;

		document.form.hidden.value=a;

}

/*	-	-	-	-	-	-	-	-	-	*/

/* Opens A Window From The compose.php page*/

function open_contacts_win(url,type) 

{

   if(document.form.select[document.form.select.selectedIndex].value!=0)

   {

   parem="status=no,scrollbars=yes,directories=no,menubar=no,toolbar=no,resizable=no,width=" + 710 + ",height=" + 460;

    var contacts_window=window.open(url+"?ty="+ type, "contact",parem);

   }

}

/*	-	-	-	-	-	-	-	-	-	*/



function pass(ty,ty1)

{

		self.opener.document.form.to.value=ty1;

		self.opener.document.form.hid.value=ty;

		window.close();

}

/*	-	-	-	-	-	-	-	-	-	*/

/* function used in the select_to.php file*/

function test()

{

	var c=new Array();

	var d=new Array();

	for(j=0;j<document.frm.elements.length;j++)

		{ 

		if(document.frm.elements[j].checked)

			if(c=="")  { c+=document.frm.elements[j].value;}

			else { c+=";"+document.frm.elements[j].value;}

		}

	for(k=0;k<document.frmm.elements.length;k++)

		{ 

		if(document.frm.elements[k].checked)

			if(d=="")  { d+=document.frmm.elements[k].value; }

			else  { d+=";"+document.frmm.elements[k].value; }

		}

		document.ff.hid.value=c;

		document.ff.hide.value=d;

}

/*	-	-	-	-	-	-	-	-	-	*/

/* Sends a value to the copy hidden field */

function outbox()

{

	if(document.form.out.checked==true) document.form.copy.value=1;

	else document.form.copy.value=0;

}

/*	-	-	-	-	-	-	-	-	-	*/



function link()

{

		var len = document.links.length

		for(i=0;i<len;i++)

		{

			document.links.onclick=link;

			window.status="http://www.thelearningsphere.com";

		}

}



function open_win(url,ty) 

{

    parem="status=no,scrollbars=yes,directories=no,menubar=no,toolbar=no,resizable=no,width=" + 710 + ",height=" + 460;

    if(!ty) { var contacts_window=window.open(url,"contact",parem); }

	if(ty) { var contacts_window=window.open(url+"?ty="+ty,"contact",parem); }

}



function ConfirmDelete(id,page)

{  

	if (confirm( "Are you sure you want to delete this Note?" ) == true)  

		{

		self.location.href='./notes_submit.php?delaction=del&id='+id+'&page_no='+page;

		}

}
function ConfirmDelete1(id)

{  

	if (confirm( "Are you sure you want to delete this Thought?" ) == true)  

		{

		self.location.href='./thought_submit.php?delaction=del&id='+id;

		}

}

function ConfirmDeleteinspiration (id)

{  

	if (confirm( "Are you sure you want to delete this Inspirational Quote?" ) == true)  

		{

		self.location.href='./inspiration_submit.php?delaction=del&id='+id;

		}

}

function ConfirmActivate(id)

{  

	if (true)  

		{

		self.location.href='./thought_submit.php?act=a&&id='+id;

		}

}

function ConfirmActivate1(id)

{  


	if (true)  

		{

		self.location.href='./inspiration_submit.php?act=a&&id='+id;

		}

}

/* disable right click starts here*/

function but(btnClick)

{

	if(navigator.appName!="Netscape" && event.button==2)

	{ 

		alert("This function has been disabled!"); 

		return false;

	}

	if(navigator.appName=="Netscape" && btnClick.which==3)

	{ 

		alert("This function has been disabled!");

		return false;

	}

}

/*for IE*/

/*document.onmousedown=but;

document.onmouseup=but;*/

/*for Netscape*/

if(document.layers) window.captureEvents(Event.MOUSEDOWN);

if(document.layers) window.captureEvents(Event.MOUSEUP);



/*window.onmousedown=but;

window.onmouseup=but;*/

/* disable right click ends here */



/* trim function */

 function trim(str,string)

				{

					var startpos,endpos,fstr,ch;

					

					startpos = 0;

					ch=str.charAt(startpos);

					while ((ch == " "))	{ startpos++; ch = str.charAt(startpos); }

					

					endpos=str.length-1;

					ch=str.charAt(endpos);

					while ((ch == " "))	{ endpos--;	ch = str.charAt(endpos); }

					if (ch=='') { alert(string); return false; }

				}

/**********End of Trim function *****************/





function open_window(url,sub,scroll,sem,win_name) 

{

    if(!scroll)

	{

	parem="status=no,scrollbars=no,directories=no,menubar=no,toolbar=no,resizable=no,width=" + 710 + ",height=" + 460;

    }else{ parem="status=no,scrollbars=yes,directories=no,menubar=no,toolbar=no,resizable=no,top=0,left=0,width=" + 790 + ",height=" + 540; }

	var contacts_win=window.open(url+"?ty="+sub+"&&id="+scroll+"&&sem_id="+sem,win_name,parem);

}



function new_window(url,win_name,sub) 

{

   	parem="status=no,scrollbars=no,directories=no,menubar=no,toolbar=no,resizable=no,width=" + 250 + ",height=" + 50;

	var contacts_win=window.open(url+"?ty="+sub,win_name,parem);

}

/********************* Trim Function ***********************/

function trimit(str,message)

{

	var startpos,endpos,fstr,ch;

	

	startpos = 0;

	ch=str.charAt(startpos);

	while ((ch == " "))	{ startpos++; ch = str.charAt(startpos); }

	

	endpos=str.length-1;

	ch=str.charAt(endpos);

	while ((ch == " "))	{ endpos--;	ch = str.charAt(endpos); }

	if (ch=='') { alert(message); return false; } else{ new_window('./check.php','Verify',document.form.username.value); }

}

/**********************************************************/



function o_window(url) 

{

    parem="status=no,scrollbars=yes,directories=no,menubar=no,toolbar=no,resizable=no,height=560,width=790,left=0,top=0";

     var contacts_window=window.open(url,"contact",parem); 

}



/***********************  #####################   *********************/



function clear_all()

{

		document.form.body.value="";

		return true;

}  

function clear_all1()

{

		document.frm.body.value="";

		return true;

}  





function checkemptynote()
{
var k=0;
var kl=0;
  for(var p=0;p<document.forma.elements.length;p++)
  {
	 if(document.forma.elements[p].type=="text" || document.forma.elements[p].type=="textarea")
	  {		    
     var nimbus=Trim(document.forma.elements[p].value);
	 var nim=nimbus.length
	
	 if(nim==0)
	 {
	
	   var field=document.forma.elements[p].name;
	   if(field=='title')
	   {
	   field='Title';
	   }
	   alert("Please enter "+field+"!" );
       document.forma.elements[p].value='';
	   document.forma.elements[p].focus();
	 
	   return false
	 }
	 /*if(checkSpecial(nimbus)==false)
	 {
	 var field=document.forma.elements[p].name;
	 alert("Special characters not allowed in "+field+"!" );
     document.forma.elements[p].focus();
	 return false;
	 }*/

	 for(var k=0;k<nim;k++)

	 {

       if(nimbus.charAt(k)==" ")

	   {
          kl++;
	   }
	 }
  }
}	 
}

function checkemptynote1()

{

var k=0;

var kl=0;

  for(var p=0;p<document.forma.elements.length;p++)

  {

	 if(document.forma.elements[p].type=="text" || document.forma.elements[p].type=="textarea")

	  {		    

     var nimbus=Trim(document.forma.elements[p].value);

	 var nim=nimbus.length

	 if(nim==0)

	 {

	   var field=document.forma.elements[p].name;	
		if(field=='title')
		{
		field='Author';
		}
		else
		{
		field='Thought';
		}
	   alert("Please enter "+field +"!");
	   document.forma.elements[p].value='';
       document.forma.elements[p].focus();

	   return false

	 }

	 for(var k=0;k<nim;k++)

	 {

       if(nimbus.charAt(k)==" ")

	   {

          kl++;

	   }

	 }

  }

}	 

}

function Trim(s) 
{
  // Remove leading spaces and carriage returns
  
  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
  {
    s = s.substring(1,s.length);
  }

  // Remove trailing spaces and carriage returns

  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
  {
    s = s.substring(0,s.length-1);
  }
  return s;
}
