   function formatText(el,tagstart,tagend) {	  
  	if (el.setSelectionRange) {
 		el.value = el.value.substring(0,el.selectionStart) + tagstart + el.value.substring(el.selectionStart,el.selectionEnd) + tagend + el.value.substring(el.selectionEnd,el.value.length)
  	}
  	else {
  		 var selectedText = document.selection.createRange().text;
        
        if (selectedText != "") {
            var newText = tagstart + selectedText + tagend;
            document.selection.createRange().text = newText;
        }
  	}
  }
  
    function formatTextLink(el,tagstart,tagend,linkObj) {
		val = linkObj.value;
		if(val=="")
			val="#";

  	if (el.setSelectionRange) {		
 		el.value = el.value.substring(0,el.selectionStart) + tagstart + " href=\"" + val + "\" target=\"_blank\" class=\"texte_article_red\">" + el.value.substring(el.selectionStart,el.selectionEnd) + tagend + el.value.substring(el.selectionEnd,el.value.length)
  	}
  	else {
  		 var selectedText = document.selection.createRange().text;
        
        if (selectedText != "") {

            var newText = tagstart + " href=\"" + val + "\" class=\"texte_article_red\">" + selectedText + tagend;			
            document.selection.createRange().text = newText;
        }
  	}
  }
  
  function formatTextLinkwhite(el,tagstart,tagend,linkObj) {
		val = linkObj.value;
		if(val=="")
			val="#";

  	if (el.setSelectionRange) {		
 		el.value = el.value.substring(0,el.selectionStart) + tagstart + " href=\"" + val + "\" target=\"_blank\" class=\"texte_article_red_white\">" + el.value.substring(el.selectionStart,el.selectionEnd) + tagend + el.value.substring(el.selectionEnd,el.value.length)
  	}
  	else {
  		 var selectedText = document.selection.createRange().text;
        
        if (selectedText != "") {

            var newText = tagstart + " href=\"" + val + "\" class=\"texte_article_red_white\">" + selectedText + tagend;			
            document.selection.createRange().text = newText;
        }
  	}
  }
 
function formatTextMailLink(el,tagstart,tagend,linkObj) {
		val = linkObj.value;
		if(val=="")
			val="#";

  	if (el.setSelectionRange) {		
 		el.value = el.value.substring(0,el.selectionStart) + tagstart + " href=\"mailto:" + val + "\" target=\"_blank\">" + el.value.substring(el.selectionStart,el.selectionEnd) + tagend + el.value.substring(el.selectionEnd,el.value.length)
  	}
  	else {
  		 var selectedText = document.selection.createRange().text;
        
        if (selectedText != "") {

            var newText = tagstart + " href=\"" + val + "\">" + selectedText + tagend;			
            document.selection.createRange().text = newText;
        }
  	}
  }
  
 function formatTextAddSymbol(el,tagstart,tagend,linkObj) {
		val = linkObj.value;
		if(val=="")
			val="";

  	if (el.setSelectionRange) {		
 		el.value = el.value.substring(0,el.selectionStart) + tagstart + " src=\"images/symbols/" + val + "\"" + el.value.substring(el.selectionStart,el.selectionEnd) + tagend + el.value.substring(el.selectionEnd,el.value.length)
  	}
  	else {
  		 var selectedText = document.selection.createRange().text;
        
        if (selectedText != "") {

            var newText = tagstart + " href=\"" + val + "\">" + selectedText + tagend;			
            document.selection.createRange().text = newText;
        }
  	}
  } 
  
  
//Function to check whether the value given is a number or String
//Returns true if it is a number and false other wise.
function IsNumeric(arg)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
 
   for (i = 0; i < arg.length && IsNumber == true; i++) 
   { 
      Char = arg.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
      {
         IsNumber = false;
      }
   }
return IsNumber;
}

//Checks whether the value passed is a valid email address
//Returns true if it is  valid email address and false other wise.
function isEmail(arg) {
    if (arg.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}

function printPage(url)
{
	var maxWin = window.open(url, 'KIPPREPORT', "top=0, left=0, resizable=no,menubar=yes,scrollbars=yes");
	maxWin.moveTo(-4, -4);
	maxWin.resizeTo(maxWin.screen.availWidth+8, maxWin.screen.availHeight+8);

	//window.open(url,'KIPPREPORT',"toolbar=no,location=no,directories=no,menubar=yes,status=no,resizable=yes,scrollbars=yes,width=900,height=1000");
	//window.open(url,"Print Article");
}

function mailpage()
{
	mail_str = "mailto:?subject=Check out the " + document.title;
	mail_str += "&body=I thought you might be interested in the " + document.title;
	mail_str += ". You can view it at, " + location.href;
	location.href = mail_str;
}



String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

// example of using trim, ltrim, and rtrim
/*
var myString = " hello my name is ";
alert("*"+myString.trim()+"*");
alert("*"+myString.ltrim()+"*");
alert("*"+myString.rtrim()+"*");
*/

function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();

}

function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
  
  document.cookie = cookie_string;
}

function getposOffset(what, offsettype){	
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}

return totaloffset;
}

function getQueryString(url,string)
{	
	var queryarray = url.split("?")
	if((queryarray.length)>0)
	{		
		var querysubarray = queryarray[1].split("&");	
	}
	for(var j=0;j<querysubarray.length;j++)
	{
		var newarray = querysubarray[j].split("=");
		if(newarray.length>0)
		{
	
			if(newarray[0]==string)
				return newarray[1];
		}
	}
	
}