// JavaScript Document

function moneyCommaSep(ctrl)
{
  var separator = ",";
  var int1 = ctrl.value.replace ( new RegExp ( separator, "g" ), "" );
  var regexp = new RegExp ( "\\B(\\d{3})(" + separator + "|$)" );
  do
  {
    int1 = int1.replace ( regexp, separator + "$1" );
  }
  while ( int1.search ( regexp ) >= 0 )
  ctrl.value = int1;
}
function removeComma(ctrl)
{
  var separator = ",";
  
  ctrl.value = ctrl.value.replace ( new RegExp ( separator, "g" ), "" );
} 
function check_in(){
	if (window.event.keyCode<48 || window.event.keyCode>122 )  
	{
			window.event.keyCode=0;
	}
	}
function check_f_en(){
	if (window.event.keyCode<48 || window.event.keyCode>255 )  
	{
			window.event.keyCode=0;
	}
	}
function check_num(){
	if (window.event.keyCode<46 || window.event.keyCode>57 )  
	{
			window.event.keyCode=0;
	}
	}
function check_0(){
			window.event.keyCode=0;
	}
function in1(ctrl)
{

  ctrl.style.background  = '#CCFFCC';

}
function in_r(ctrl,i)
{
  var w = "RadioGroup1_"+i;
  ctrl.style.background  = '#CCFFCC';
  document.getElementById(w).checked = true;
}
function out1(ctrl)
{
 ctrl.style.background  = '#ffffff';
}
function hide(id){
	if (document.getElementById(id).style.display == "none"){ 
	  document.getElementById(id).style.display = "inline";
	  document.getElementById('pic').src="../images/arrow_up_blue.ico";
	}	  
	else 
	{	
	  document.getElementById(id).style.display = "none";
	  document.getElementById('pic').src="../images/arrow_down_blue.ico";	  
	}         
}
function minmah(ctrl)
{
	  var separator = ",";
  
  ctrl.value = ctrl.value.replace ( new RegExp ( separator, "g" ), "" );
}
function permalert(){
  	alert (' شما اجازه دسترسی به این بخش را ندارید ');
  }
checked = false;
function selectCheckboxes(){

			var aa= document.getElementById( 'frm1' );
			if (checked == false)
			{
				checked = true
			}
			else
			{
				checked = false
			}
			for ( var i =0; i < aa.elements.length; i++ ) 
			{
				aa.elements[i].checked = checked;
			}	  
}

function startTicker()
{
 // Define run time values
 theCurrentStory	 = -1;
 theCurrentLength	= 0;
 // Locate base objects
 if (document.getElementById) { 
	  theAnchorObject	 = document.getElementById("tickerAnchor");
   runTheTicker();	
   }
 else {
			document.write("<style>.ticki{display:none;}.ticko{border:0px; padding:0px;}</style>");
			return true;
 }
}
// Ticker main run loop
function runTheTicker()
{
 var myTimeout;  
 // Go for the next story data block
 if(theCurrentLength == 0)
 {
  theCurrentStory++;
  theCurrentStory	  = theCurrentStory % theItemCount;
  theStorySummary	  = theSummaries[theCurrentStory].replace(/&quot;/g,'"');  
  theTargetLink		= theSiteLinks[theCurrentStory];
  theAnchorObject.href = theTargetLink;
  thePrefix 	  = "<span class=\"tickls\">" + theLeadString + "</span>";
 }
 // Stuff the current ticker text into the anchor
 theAnchorObject.innerHTML = thePrefix + 
 theStorySummary.substring(0,theCurrentLength) + whatWidget();
 // Modify the length for the substring and define the timer
 if(theCurrentLength != theStorySummary.length)
 {
  theCurrentLength++;
  myTimeout = theCharacterTimeout;
 }
 else
 {
  theCurrentLength = 0;
  myTimeout = theStoryTimeout;
 }
 // Call up the next cycle of the ticker
 setTimeout("runTheTicker()", myTimeout);
}
// Widget generator
function whatWidget()
{
 if(theCurrentLength == theStorySummary.length)
 {
  return theWidgetNone;
 }

 if((theCurrentLength % 2) == 1)
 {
  return theWidgetOne;
 }
 else
 {
  return theWidgetTwo;
 }
}


