
var ERROR_SHOW=false;
function save_and_return_publish_check_limits()
         {
         var ACTION = document.contentform.action;
         ACTION.value='EDIT_CONT_SAVE_RET_PUB_ITEM';
         return check_limits();
         }
function save_and_return_check_limits()
         {
         var ACTION = document.contentform.action;
         ACTION.value='EDIT_CONT_SAVE_RET_ITEM';
         return check_limits();
         }
function check_limits()
         {
         var re= /<\S[^>]*>/g;
         var ERRM = document.getElementById('ERRM');
         var A = ERRM.innerHTML.replace(re,"");
         (ERROR_SHOW==true)?alert(A):'';
         return (ERROR_SHOW==true)?false:true;
         return false;
         }
function err_display(text)
         {
         var ERRM = document.getElementById('ERRM');
         var NICE = new Array('Content','Summary','Title');
         var LIST = new Array('PC_CONT','PC_SUM','PC_NAME');
         for(var i=0;i<LIST.length;i++){if(LIST[i]==text){text=NICE[i]; break;}}
         ERRM.style.display = (text.length>0)?'':'none';
         if(text.length==0){return;}
         ERRM.innerHTML='<h5>Error: Please Correct : '+text+'.</h5><BR />';
         //alert(' Error: Please Correct : '+text+' Length.');
         }

function check_limitsa()
         {
         var ERRM = document.getElementById('ERRM');
         var LIST = new Array('PC_CONT','PC_SUM','PC_NAME');
         var LIM  = new Array('5000','500','10');
         var NICE = new Array('Content','Summary','Title');
         var CHA  = new Array('0','1','1');
         var ERR  = false;
         var BRK  = false;

         for(var i=0;i<LIST.length;i++)
            {
            if(CHA[i])
               {
               if(ERR=(CountWords(LIST[i])>LIM[i])?true:false){BRK=i; break;}
               }
               else
                   {
                   ERR =(GetWordCount(LIST[i])>LIM[i])?true:false;
                   if(ERR==true){BRK=i;break;}

                   //if(ERR=(GetWordCount(LIST[i])>LIM[i])?true:false){BRK=i; break;}
                   }

            }

         return false;
         ERRM.innerHTML =(ERR)?'<h5>Error: Please Correct : '+NICE[BRK]+'.</h5><BR />':'';
         ERROR_SHOW    = (ERR==true)?true:false;
         //                (ERR==true)?alert(' Error: Please Correct : '+NICE[BRK]+' Length.'):'';
         return  (ERR==true)? false : true;

         }



function showWordCounts(NAME,LIMIT,COUNT)
         {
         if(!LIMIT){var LIMIT='5000';}
         var LIMIT_A = parseInt(LIMIT) + parseInt((LIMIT*.15));
         var ERR         = false;
         var WCOUNT      = (COUNT)?COUNT:CountWords(NAME);
         var PERCENT     = (WCOUNT)? Math.min(Math.round((WCOUNT/LIMIT_A)*100),99):'0';
         var WOW = (WCOUNT==1) ? ' word':' words';
         var NOTE        = (WCOUNT>LIMIT_A)? 'Error:Over word limit, please correct' : WCOUNT+WOW+' of '+LIMIT+'  '+PERCENT+'%';
         var ERR         = (WCOUNT>LIMIT_A)?true:false;
         ERROR_SHOW      = (WCOUNT>LIMIT_A)?true:false;
         MakeGraph(NAME,PERCENT,NOTE,ERR);
         if(ERROR_SHOW==true){ err_display(NAME); }else{err_display('');}

         }

 function MakeGraph(NAME,PERCENT,NOTE,ERR)
          {
          var BARNOTE = document.getElementById(NAME+'WordCount');
          var BARBASE = document.getElementById(NAME+'meter');
          var BAR     = document.getElementById(NAME+'meterbar');
          BARBASE.style.visibility='visible';
          BAR.style.width=''+PERCENT+'%';
          BARNOTE.innerHTML = NOTE;
          BAR.style.background =(ERR)?'#FF0000':'#8CAAE6';
          //if(ERR){BAR.style.background='#FF0000';}else{BAR.style.background='#8CAAE6';}
          }
 function GetWordCount(this_field)
          {
          var Count =document.getElementById(''+this_field+'').value;
          return (Count)?Count:'0';
          }
 function CountWords(this_field,INPUT)
          {
          var re= /<\S[^>]*>/g;
          if(INPUT)
             {
             var INPUTA = INPUT.replace(re,"");
             return (INPUTA)? INPUTA.split(/\s+/g).length:0;
             }
             else
                 {
                 var content = document.getElementById(''+this_field+'').value;
                 var contenta = content.replace(re,"");
                 return (contenta)? contenta.split(/\s+/g).length:0;
                 }
          //if(content==''){return 0;}
          //var a = content.split(/\s+/g);
          //return a.length;
          }

 function editoronChange(inst)
          {
          var A=inst.getBody().innerHTML;
          var re= /<\S[^>]*>/g;
          A = A.replace(re,"");
          var c = A.split(/\s+/g).length;
          showWordCounts('PC_CONT','',c);
          }

  function SwitchImg(id)
           {
           //var img = new Array('stars_2_10.gif','stars_2_20.gif','stars_2_30.gif','stars_2_40.gif','stars_2_50.gif');
           //var IMG = document.getElementById('Image1');
           //IMG.src='/images/'+img[(id-1)];
           }
  function ChooseImg(id)
           {
           var RATE = document.getElementById('RATE');
           var CH   = document.getElementById('RATEM'+id+'');
           CH.checked = true;
           RATE.value=(id>0)?id:1;
           //RestImg();
           }
  function RestImg()
           {
           //var img = new Array('stars_2_10.gif','stars_2_20.gif','stars_2_30.gif','stars_2_40.gif','stars_2_50.gif');
           //var RATE = document.getElementById('RATE').value;
           //var IMG = document.getElementById('Image1');
           //IMG.src='/images/'+img[(RATE-1)];
           }
  function CheckRate(form,n)
           {
           var s=(n)?1:0;
           var TYPE = new Array('Story','Review');
           if(form.RATE.value==1)
              {
              if(!confirm("You are rating this "+TYPE[s]+" a 1.  Please confirm this is your intended review rating. \n If it is not, please click cancel, and then click the intended number of stars.")){return false;}
              }
           return;
           }
           
  function CheckComment(i)
  {
    if(!parseInt(i.COM.value.length))
    {
        alert("Please Enter a comment");
        return false;
    }
    return true;
  }
  
  
  
//============================================== xmlrequest code imported from js file
 

//===================================================xmlrequest end
  function featureArticle()
  {
  	id=document.getElementById('feature_id').value;

  	window.location = 'http://' + window.location.host + '/index.php?custom=feature_article,'+id;
  	
  } 
  
  function unfeatureArticle()
  {
  	id=document.getElementById('feature_id').value;

  	window.location = 'http://' + window.location.host + '/index.php?custom=unfeature_article,'+id;
  	
  }  