// Collective2 Javascript Framework
// (c) 2009-10 Collective2 LLC

var gReverseX;
var gReverseY;

function initpage()
{
    $('namesearch').value='';
	Tooltip.init();
	preloadImages();
	dragndropInit();
	putEventStackInTicker(gEventStack);
	setTimeout('changeTicker();',2000);
	setTimeout('getDelta(\''+gDeltaClass+'\');',10000);
	checkURLstack();
	
}

function initpagetemplate()
{
	
	try
	{
	   $('namesearch').value='';
	}
	catch (err) {}
	Tooltip.init();
	dragndropInit();
	checkURLstack();
	setTimeout('getDelta(\''+gDeltaClass+'\');',10000);
}
function initsimplepage(useDragDrop)
{
	Tooltip.init();
	
	if (useDragDrop) {dragndropInit();}
	checkURLstack();
}
function initSystemPage()
{
	gCropper=new Cropper.Img( 'chartImage', {minHeight: 300, onEndCrop: onEndCrop});
	initpagetemplate();
}

function jIsInList()
{
	var argv = jIsInList.arguments;
	var argc = argv.length;
	var ret=0;
	for (var i = 1; i < argc; i++)
	{
	  if (argv[0]===argv[i])
	  {
	      ret=1;
	      last;
	  }
	 }
	 return (ret);
}

function removeFromWatchList(divtodrop)
{
	var sid=divtodrop.substring(6);
	
	Effect.DropOut(divtodrop);
	
	
	gWatchList.splice(gWatchList.indexOf(sid), 1);
	
	var url=gRespondingApp+'?want=removefromwatchlist&sid='+sid;
		
	pendURL.push(url);
	
	if (gWatchList.length==0)
	{
		var obj=document.getElementById('watchlistcontainer');
		obj.innerHTML='Drag any system on page<BR>to here.';
		obj.className='emptyContainer';
	}
	
}
function menutoggle(childDiv)
{
	var parentDiv=childDiv.parentNode;
	if (parentDiv.className==='menu show')
	{
		parentDiv.className='menu hide';
	}
	else if (parentDiv.className==='menu hide')
	{
		parentDiv.className='menu show';
	}
}

function handleMouseDown(dragID)
{
	gMouseDownDate=new Date();

	// create Draggable
	if ( dragID )
	{
		if ( typeof(gDraggables[dragID]) === 'object' )
		{
			// destroy so it is properly initialized even if it was previously
			// initialized on a previous load
			gDraggables[dragID].destroy();
		} 
		gDraggables[dragID] = new Draggable( dragID,{revert:true,scroll:window});
	}
}

function handleMouseUpForum(boardid,msgid)
{
	var end=new Date();
	var msSinceMouseDown=end.getTime() - gMouseDownDate.getTime();
	if (msSinceMouseDown<=500)
	{
	window.location='/cgi-perl/board.mpl?want=listmsgs&boardid='+boardid+'&message='+msgid+'&fromelse=1#msgdirect'+msgid;
	}
	
}

function handleMouseUpURL(url)
{
	var end=new Date();
	var msSinceMouseDown=end.getTime() - gMouseDownDate.getTime();
	
    	if (msSinceMouseDown<=500)
	{
		window.location = url;
	}

	// reset gMouseDownDate after delay
	setTimeout("gMouseDownDate=undefined", 500 );	
}

function handleMouseUp(sid,divToChange,param)
{ 
	
	var end=new Date();
	var msSinceMouseDown=end.getTime() - gMouseDownDate.getTime();
	if ((sid==gLastXClick) && (msSinceMouseDown<5000))
	{
		
		return;
	}
	try{
		var msSinceLastDrop=end.getTime()-gLastDroppedOnChart.getTime();
		if (msSinceLastDrop<1500)
		{ 
			return;
		}
	}
	catch (err)
	{
	}
	
	
	if (msSinceMouseDown<=500)
	{
		
		if (isDefined(divToChange))
		{
		
			var el=document.getElementById(divToChange);
			
			var posx=findPosX(el);
			
			var posy=findPosY(el);
			
			
			var snake=document.getElementById('waiticon');
			
			
			
			var WW=getStyle(divToChange,'width');
			
			var HH=getStyle(divToChange,'height');
			
			
			WW=parseInt(WW.substr(0,WW.length-2));
			HH=parseInt(HH.substr(0,HH.length-2));
			
			var xoffset=posx+Math.round(WW/2);
            var yoffset=posy+Math.round(HH/2);
	
           if (el.className=='leftnavsys')
           {
           xoffset=posx-19;
           yoffset=posy-2;
           }
			snake.style.position = "absolute";
			
			if ((yoffset==0)||(isNaN(yoffset))) {yoffset='0';}
			if ((xoffset==0)||(isNaN(xoffset))) {xoffset='0';}
			snake.style.top = yoffset+'px';
            snake.style.left =xoffset+'px';
            setTimeout('show(true,\'waiticon\'); document.getElementById(\'waiticon\').style.display = \'block\';',400);
			new Effect.Opacity(divToChange,{duration:.7, from:1, to:.2});
			var d=0;
			if (divToChange.length>6)
			{
			 if (divToChange.slice(0,6) == 'revsys')
			 {
			     d=1;
			     window.location='/cgi-perl/c2systems.mpl?systemid='+sid+'&review='+param;
			 }
            }
			if (!d) {window.location='/cgi-perl/system'+sid;}
		}
	}
}

function getStyle(el,styleProp)
{
	var x = document.getElementById(el);
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}

function hiliteReview(sid,on)
{
     if (on==1)
     {
          document.getElementById('revsysname'+sid).style.textDecoration='underline';
          document.getElementById('revsys'+sid).style.borderColor='#F87500';
     }
     else
     {
          document.getElementById('revsysname'+sid).style.textDecoration='none';
          document.getElementById('revsys'+sid).style.borderColor='#FFFFFF';
     }
}
function isDefined(variable)
{
	return (!(!(document.getElementById(variable))))
}
function handleMouseUpMySys(sid)
{
	var end=new Date();
	var msSinceMouseDown=end.getTime() - gMouseDownDate.getTime();
	if ((sid==gLastXClick) && (msSinceMouseDown<5000))
	{
		return;
	}
	
	if (msSinceMouseDown<=500)
	{
		
		loadSystem(sid);
	}
	
}



function divtoggle(menudiv,divname)
{
	var url;
	var parentDiv=menudiv.parentNode;
	if (document.getElementById(divname).style.display==='none')
	{
		parentDiv.className='menu show';
		show(true,divname);
		document.getElementById(divname).style.display = "block";
		url=gRespondingApp+'?want=reporttoggle&div='+divname+'&collapsed=0';
	}
	else
	{
		parentDiv.className='menu hide';
		show(false,divname);
		document.getElementById(divname).style.display = "none";
		url=gRespondingApp+'?want=reporttoggle&div='+divname+'&collapsed=1';
	}
	pendURL.push(url);
}

function checkPendingKeypress()
{
	
   if (gUnprocKeypress)
   {
	
	
      var end=new Date();
      var msSinceKeyPress=end.getTime() - gLastKeyPressDate.getTime();
      if (msSinceKeyPress>580)
      {
	
         if ($('namesearch').value.length>2)
	 {
		var url=gRespondingApp+'?want=dynamicsearch&searcher='+gPersonID+'&searchtext='+ $('namesearch').value;
		
		show(false,'searchbutton');
		document.getElementById('searchbutton').style.display = "none";
		
		show(true,'searchactive');
		document.getElementById('searchactive').style.display = "inline";
		
		pendURL.push(url);
		gUnprocKeypress=0;
		
	 }
	 else{
		
		
		gUnprocKeypress=0;
		document.getElementById('searchresults').innerHTML='';
	 }
      }
      else
      {
         setTimeout('checkPendingKeypress();',10);
	 
      }
   }
  
}

function handleAdvancedSearch()
{
	window.location='/cgi-perl/system/grid.mpl?gridId=default&filter=1&column=systemName&relation=like&value=' + $('namesearch').value;
	return false;
}
function clearSearchResults ()
{
	gUnprocKeypress=0;
	document.getElementById('searchresults').innerHTML='';
	$('namesearch').value='';
}

function handleSearchSubmit()
{
	if ($('namesearch').value.length>2)
	{
	show(false,'searchbutton');
	document.getElementById('searchbutton').style.display = "none";
		
	show(true,'searchactive');
	document.getElementById('searchactive').style.display = "inline";

	window.location='/cgi-perl/system/grid.mpl?gridId=default&filter=1&column=systemName&relation=like&value=' + $('namesearch').value;
	}
	return false;
}

function show(sw,obj) {
	if (sw && (ie4 || ie5) ) document.all[obj].style.display = 'inline';
	if (!sw && (ie4 || ie5) ) document.all[obj].style.display = 'none';
	if (sw && ns4) document.layers[obj].display = 'inline';
	if (!sw && ns4) document.layers[obj].display = 'none';
}


function createRequestObject(url)
{

       var req;

        
       if(window.XMLHttpRequest){
          // Firefox, Safari, Opera...
          req = new XMLHttpRequest();
       } else if(window.ActiveXObject) {
          // Internet Explorer 5+
          req = new ActiveXObject("Microsoft.XMLHTTP");
       } else {
          // There is an error creating the object,
          // just as an old browser is being used.
         // alert('Problem creating the XMLHttpRequest object');
       }

       return req;

}



function checkURLstack()
{
    if (pendURL.length>0)
    {
	
	if (gWaitingForURL==0)
	{
	    var URL=pendURL[0];
            
	   
	    gWaitingForURL=1;
	    http=createRequestObject();
	    http.open('get', URL);
	    http.onreadystatechange = handleResponse;
	    http.send(null);
	}
	
    }
    else
    {
    setTimeout('checkURLstack();',500);
    }
}

function handleResponse()
{
    var good=0;
    
    if (http.readyState == 4)
    {
        
        if (http.status == 200)
        {

            var response = http.responseText;

            if (response)
            {
	       var gotback = response.split("=9x8y");	
               gWaitingForURL=0;
	       pendURL.shift();
               
               var arLen=gotback.length;
               for ( var i=0, len=arLen; i<len; ++i )
               {
                parseChunk(gotback[i]);
               }
            }

       }
       else
       {
	    gWaitingForURL=0;
       }
       checkURLstack();
      
    }
}

function parseChunk (chunk)
{
   var segment = chunk.split("=TERM_");
   
   
   
   if (segment[0]=='updatediv')
   {
	try{
        document.getElementById(segment[1]).innerHTML=segment[2];
	}
	catch (err)
	{
	   if (segment[1]=='tip')
	   {
	       segment[1]='topPageTip';
	       try{
            document.getElementById(segment[1]).innerHTML=segment[2];
	       }
	       catch (err)
	       {
	           if (window.console) {
		          window.console.log("Trapped error in updatediv, error is="+err+", first tried tip, then topPageTip; changing to="+segment[2]);
		          }
	       }

	   }
       else if (window.console) {
		  window.console.log("Trapped error in updatediv, error is="+err+", divid to change="+segment[1]+" and changing to="+segment[2]);
       }
	}

	// reload any tables in case they may have changed
        if ( segment[2].match( /sortable|resizable|editable/i ) ) { TableKit.load() };
   }
   else if (segment[0]=='condupdatediv')
   {
    // conditional update of div - last segment is the conditional to be eval'ed
    if ( eval( segment[3] ) )
    {
        try{
            document.getElementById(segment[1]).innerHTML=segment[2];
        }
        catch (err)
        {
            if (window.console) {
            window.console.log("Trapped error in updatediv, error is="+err+", divid to change="+segment[1]+" and changing to="+segment[2]);
            }
        }
	// reload any tables in case they may have changed
        if ( segment[2].match( /sortable|resizable|editable/i ) ) { TableKit.load() };
    }
   }
   else if (segment[0]=='classupdt')
   {
   		arg1=segment.shift();
   		
   	    gChangeHash = new Array();
   		while (segment.length>0)
   		{
   			var c=segment.shift();
   			var v=segment.shift();
   			gChangeHash[c]=v;
   		}
   		changeMultipleEls();
        
   }
   else if (segment[0]=='preloadimages')
   {
      preloadImages (segment[1]);
   }
   else if (segment[0]=='setopacity')
   {
         try
         {
            $(segment[1]).setOpacity(segment[2]);
         }
         catch (err) {
         if (window.console) {
            window.console.log("Trapped error in setopacity, error is="+err+", divid to change="+segment[1]+" and changing to opac="+segment[2]);
            }
         }
      
   }
   else if (segment[0]=='gotolocation')
   {
      window.location=segment[1];
      
   }
   else if (segment[0]=='eval')
   {
    // note that the one limitation here is that you cannot pass function
    // declarations to this code - if this is required, we should switch 
    // back to eval()
      var tmpFunc = new Function(segment[1]);
      tmpFunc();    
   }
}


function pageWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;} 
function pageHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;} 

function glowdiv(divname)
{
	try
	{
	    new Effect.Highlight(divname);
	}
	catch (err) {}
}

function fadediv(divname)
{
	try
	{
	    new Effect.Fade(divname);
	}
	catch (err) {}
}


function handleSearchKeyUp()
{
   gLastKeyPressDate=new Date();
   
   if (gUnprocKeypress==0)
   {
	
      gUnprocKeypress=1;
      setTimeout('checkPendingKeypress();',10);
   }
}


function glow (prefix,whichnum,howmany)
{
  
   for (var i=1; i<=howmany; i++ )
   {
      var el=prefix+i;
      document.getElementById(el).style.borderColor='#ffffff';
      document.getElementById(el).style.borderWidth='5px';
      if (i!==whichnum)
      {
         new Effect.Opacity(el,{duration:.5, from:.1, to:.3});
      }
   }
   
   document.getElementById(prefix+whichnum).style.borderColor='#CC6600';
   document.getElementById(prefix+whichnum).style.borderWidth='5px;';
   new Effect.Highlight(prefix+whichnum);
   new Effect.Opacity(prefix+whichnum,{duration:.1, from:.3, to:1});
   
   document.getElementById('brokerrightholder').innerHTML='';
   
}

function getMouseXYsystem(e)
{
	  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  
  var Mdivx=findPosX(document.getElementById('chartdiv'));
  var Mdivy=findPosY(document.getElementById('chartdiv'));
	
	
  if ((tempX>=Mdivx)&&(tempX<=Mdivx+gChartWidth)&&(tempY>=Mdivy)&&(tempY<=Mdivy+gChartHeight))
  {
	var relX=tempX-Mdivx;
	var relY=tempY-Mdivy;
	
  }
  
  
  return true;
}

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  
  
 	if ((gOnSubsections==1)||(gOnMainSection==1))
	{
		
	var divx=findPosX(document.getElementById(gPriorityDiv));
	var divy=findPosY(document.getElementById(gPriorityDiv));
	var WIDTH=parseInt(document.getElementById(gPriorityDiv).style.width);
	var HEIGHT=parseInt(document.getElementById(gPriorityDiv).style.height);
	
	
		if ((gOnMainSection==0) && ((tempX<divx)||(tempY<divy)||(tempX>divx+WIDTH)||(tempY>divy+HEIGHT+40)))
		{
			//Is it in the main box?
			var inMainBox=clickedInsideDiv('welcomeholder',tempX,tempY);
			restoreDefaultPositions(inMainBox);	
		}
	}
	
	
  
  return true;
}

function clickedInsideDiv(divname,mouseX,mouseY)
{
	var Mdivx=findPosX(document.getElementById(divname));
	var Mdivy=findPosY(document.getElementById(divname));
	
	
	var MWIDTH=getStyle(divname,'width');
	MWIDTH=parseInt(MWIDTH.substr(0,MWIDTH.length-2));
	
	
	var MHEIGHT=getStyle(divname,'height');
	MHEIGHT=parseInt(MHEIGHT.substr(0,MHEIGHT.length-2));
		
	
	if ((mouseX>=Mdivx)&&(mouseX<=Mdivx+MWIDTH)&&(mouseY>=Mdivy)&&(mouseY<=Mdivy+MHEIGHT))
	{
		
		return (1);	
	}
	else
	{
		
		return (0);	
	}
}


  function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

  
  
function doTooltip(e, msg) {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.show(e, msg);
}
function hideTip() {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.hide();
}
function prepTooltip (e,sid,sname)
{
	var txt='<table border="0" cellpadding="0" cellspacing="0"><tr><td width="300"><p align="center"><img border="0" src="http://www.collective2.com/images/charts/thumbnail'+sid+'.png" width="280" height="240"></td></tr><tr><td width="100%" align="center"><table border="0" cellpadding="0" cellspacing="0"><tr><td width="50%"><p class="tp2"><img border="0" src="http://www.collective2.com/images/redline.gif" width="32" height="9">S&amp;P 500</p></td><td width="50%"><p class="tp2"><img border="0" src="http://www.collective2.com/images/greenline.gif" width="32" height="9">'+sname+'</p></td></tr></table></td></tr></table>';
	doTooltip(e, txt);
}



function selectSystemDisplay(selecttype)
{
	
	var url=gRespondingApp+'?want=dashselecttype&type='+selecttype+'&v='+gV;
	pendURL.push(url);
	hidepopupcmd();
}

function rotatepulse(itype,instru,days)
{
	
	var url=gRespondingApp+'?want=rotatepulse&itype='+itype+'&days='+days+'&instru='+instru;
	pendURL.push(url);
}


function showpopupcmd (sid,el,woffset,hoffset,trade,details,itm,autotrade,unsub,notes)
{
	if (gPopUpSid!=sid)
	{
	var popup=document.getElementById('c2popupframe');
	var cont='<div class="popcommands"><BR>';
	if (trade) {cont=cont+'<a href="#" onclick="dispatchTrade('+sid+')" class="btnB"><span><span><span>Trade</span></span></span></a><BR><BR>';}
	if (details) {cont=cont+'<a href="#" onclick="dispatchDetails('+sid+',\'chart'+sid+'\')" class="btnB"><span><span><span>Details</span></span></span></a><BR><BR>';}
	if (itm) {cont=cont+'<a href="#" onclick="dispatchITM('+sid+')" class="btnB"><span><span><span>ITM</span></span></span></a><BR><BR>';}
	if (autotrade) {cont=cont+'<a href="#" onclick="dispatchAutotrade('+sid+')" class="btnB"><span><span><span>AutoTrade</span></span></span></a><BR><BR>';}
	if (unsub) {cont=cont+'<a href="#" onclick="dispatchUnsub('+sid+')" class="btnB" id="unsublink'+sid+'"}><span><span><span>Unsubscribe</span></span></span></a><BR><BR>';}
	if (notes) {cont=cont+'<a href="#" onclick="dispatchMyNotes('+sid+')" class="btnB"><span><span><span>My Notes</span></span></span></a><BR><BR>';}
        cont=cont+'</div>';
        
	popup.innerHTML=cont;
	var divx=findPosX(document.getElementById(el));
	var divy=findPosY(document.getElementById(el));
	
	
	var xoffset=divx+woffset;
	var yoffset=divy+hoffset;


	popup.style.position = "absolute";
	popup.style.top = yoffset+'px';
	popup.style.left =xoffset+'px';
			
			
	
	show(true,'c2popupframe');
	document.getElementById('c2popupframe').style.display = 'block';
	gPopUpSid=sid;
	}
	
}

function toggleHideShowDiv(divname)
{
	var el=document.getElementById(divname);
	if (el.style.display=='block')
	{
		el.style.display='none';
	}
	else
	{
		el.style.display='block';
		var needSessInform=-1;
		if (divname == 'closedBasicpage')
    	{
    	   needSessInform=0;
        }
        else if (divname == 'closedAdvancedpage')
    	{
    	   needSessInform=1;
        }
        if (needSessInform>=0)
        {
    	   var key='unfold'+gSystemID;
    	   var R= Math.random();
    	   var url=gRespondingApp+'?want=setSessionValue&key='+key+'&val='+needSessInform+'&R='+R;
    	   pendURL.push(url);
    	}
	}
	
}
     
function toggleHideShowDivAndLabel(divname,labeldiv,onhtml,offhtml)
{
	var el=document.getElementById(divname);
	if (el.style.display=='block')
	{
		el.style.display='none';
		document.getElementById(labeldiv).innerHTML=offhtml;
	}
	else
	{
		el.style.display='block';
		document.getElementById(labeldiv).innerHTML=onhtml;
	}
}    
function dispatchUnsub(sid)
{
	show(false,'c2popupframe');
	document.getElementById('c2popupframe').style.display = 'none';
	
	var R= Math.random();
	var url='./c2systems.mpl?want=unsubscribe&return=dashboard&systemid='+sid+'&R='+R;
	pendURL.push(url);
}
function dispatchMyNotes(sid)
{
	show(false,'c2popupframe');
	document.getElementById('c2popupframe').style.display = 'none';
	window.location='/cgi-perl/my_analyst.mpl?want=add&systemid='+sid;
}
function dispatchTrade(sid)
{
	show(false,'c2popupframe');
	document.getElementById('c2popupframe').style.display = 'none';
	window.location='/cgi-perl/orderentry.mpl?want=trade&systemid='+sid;
}
function fadeAndSnakeDiv(divToChange)
{
    var el=document.getElementById(divToChange);
	var posx=findPosX(el);
	var posy=findPosY(el);
	
	
	var snake=document.getElementById('waiticon');
	
	var WW=getStyle(divToChange,'width');
	var HH=getStyle(divToChange,'height');
	
	WW=parseInt(WW.substr(0,WW.length-2));
	HH=parseInt(HH.substr(0,HH.length-2));
	
	
	var xoffset=posx+Math.round(WW/2);
	var yoffset=posy+Math.round(HH/2);
    if ((!isNaN(xoffset)) && (!isNaN(yoffset)))
    {
        snake.style.position = "absolute";
    	snake.style.top = yoffset+'px';
    	snake.style.left =xoffset+'px';
    }

	
	
	setTimeout('show(true,\'waiticon\'); document.getElementById(\'waiticon\').style.display = \'block\';',400);
	new Effect.Opacity(divToChange,{duration:.7, from:1, to:.2});

}
function dispatchDetails(sid,divToChange)
{
	show(false,'c2popupframe');
	document.getElementById('c2popupframe').style.display = 'none';
	
	fadeAndSnakeDiv(divToChange)
	
	window.location='/cgi-perl/system'+sid;
	
}
function dispatchITM(sid)
{
	NewWindow=window.open('./msgajax.mpl?want=establish&systemid='+sid+'&sessionid='+gsess,'ITM'+sid,'width=800,height=320,resizable=yes,scrollbars=yes');
}
function dispatchAutotrade(sid)
{
	show(false,'c2popupframe');
	document.getElementById('c2popupframe').style.display = 'none';
	window.location='/cgi-perl/autotrade.mpl?particsysid='+sid;
}

function hidepopupcmd()
{
	try{
	if (gPopUpSid)
	{
		show(false,'c2popupframe');
		document.getElementById('c2popupframe').style.display = 'none';
		gPopUpSid=0;
	}
	}
	catch (err)
	{
	}
	
}

function hideforumpopup()
{
	show(false,'forumpopup');
	document.getElementById('forumpopup').style.display = 'none';
}

function dispatchPost(boardid)
{
	hideforumpopup();
	
	if (boardid==0)
	{
		window.location='/cgi-perl/board.mpl?want=list&setfilter=1';
	}
	else
	{
		window.location='/cgi-perl/board.mpl?want=post&boardid='+boardid;
	}
	
}

function preloadImages ()
{
   
   preloadNext0=new Image();
   preloadNext0.src='../images/bwforward0.gif';
   
   preloadNext1=new Image();
   preloadNext1.src='../images/bwforward1.gif';

}

function putEventStackInTicker(es)
{
	document.getElementById('tickerframe').innerHTML='<div id="innertickerwrap">'+buildEventStackHTML(es)+'</div>';
	
}

function buildEventStackHTML(es)
{
	var htm='';
	
	var numVisible=0;
	
	var addNewIfVisibleLessThan=6;
	
	if (gAdWaitStart)
	{
		var end=new Date();
		var msAdPaused=end.getTime() - gAdWaitStart.getTime();
		if (msAdPaused<5000)
		{
			return('');
		}
		else
		{
			gAdWaitStart=0;
		}
	}
	var needToStartWait=0;
	if (es.length)
	{
		var peekAhead=es[0];
		
		if (peekAhead=='adformat1')
		{
			needToStartWait=1;
			
		}
	}
	while ((es.length) && (numVisible<addNewIfVisibleLessThan))
	{
		numVisible=numVisible+1;
		
		var t=es.shift();
		var iname=es.shift();
		var sid=es.shift();
		var systemname=es.shift();
		var tipname=es.shift();
		
		if (t=='adformat1')
		{
			htm=htm+'<div class="tickerUnitAd1" id="'+iname+'"><table><tr><td><div class="tickerAdChart" id="tickch'+sid+'"><a href="#" onmousedown="gDragTicker=1;handleMouseDown(\'tickch'+sid+'\');" onmouseup="gFreezeTicker=0;gDragTicker=0;handleMouseUp('+sid+',\''+iname+'\');"><img src="dashcharts.mpl?sid='+sid+'&notext=1&width=70&height=37"></a></div></td><td><div class="tickerAdText">'+systemname+'</div></td></tr></table></div><div style="clear:both;"></div></div>';
		}
		else if (t=='sysview')
		{
			htm=htm+'<div class="tickerUnit" id="'+iname+'"><div class="tickName"><span onmouseover="doTooltip(event,\''+tipname+'\')" onmouseout="hideTip()">'+systemname+'</span></div><BR><div class="tickChart" id="tickch' + sid + '"><a href="#" onmousedown="gFreezeTicker=1;handleMouseDown(\'tickch'+sid+'\');" onmouseup="gFreezeTicker=0;handleMouseUp('+sid+',\''+iname+'\');"><img src="dashcharts.mpl?sid='+sid+'&notext=1&width=70&height=37"></a></div></div>';

		}
		else if (t=='login')
		{
			htm=htm+'<div class="tickerUnit" id="'+iname+'"><div class="tickLogin">'+sid+' logs in at '+systemname+'</div></div>';
		}
		else if (t=='sigpost')
		{
			htm=htm+'<div class="tickerUnit" id="'+iname+'"><div class="'+tipname+'"> New signal:<BR>'+sid+' at '+systemname+'</div></div>';
		}
		else if (t=='autotrade')
		{
			htm=htm+'<div class="tickerUnit" id="'+iname+'"><div class="'+tipname+'"> AutoTrader '+sid+'</div></div>';
		}
		gVisibleEventStack.push(t);
		gVisibleEventStack.push(iname);
		gVisibleEventStack.push(sid);
		gVisibleEventStack.push(systemname);
		gVisibleEventStack.push(tipname);
	}
	if ((needToStartWait) && (gAdWaitStart==0))
	{
		gAdWaitStart=new Date();
	}
	return (htm);
}


function changeTicker()
{
	
	
	if ((gEventStack.length>0) && (gFreezeTicker==0))
	{
		var tdrop=gVisibleEventStack.shift();
		var inamedrop=gVisibleEventStack.shift();
		var siddrop=gVisibleEventStack.shift();
		var systemnamedrop=gVisibleEventStack.shift();
		var tipnamedrop=gVisibleEventStack.shift();
		
		Effect.SwitchOff(inamedrop);
		
		var t=gEventStack.shift();
		var iname=gEventStack.shift();
		var sid=gEventStack.shift();
		var systemname=gEventStack.shift();
		var tipname=gEventStack.shift();
		
		gVisibleEventStack.push(t);
		gVisibleEventStack.push(iname);
		gVisibleEventStack.push(sid);
		gVisibleEventStack.push(systemname);
		gVisibleEventStack.push(tipname);
		
		var htm=buildEventStackHTML(gVisibleEventStack);
		
		
		
		var myRegExp = new RegExp("'","g"); 
		var cleanhtm = htm.replace(myRegExp, "\\'"); 
		
		setTimeout('document.getElementById(\'tickerframe\').innerHTML=\'<div id="innertickerwrap">'+cleanhtm+'</div>\'',1000);
	}
	setTimeout('changeTicker();',2000);
}

function getNewTickerData()
{
	
	if ((gEventStack.length<50) && (gFreezeTicker==0))
	{
	var url=gRespondingApp+'?want=moreticker&v='+gV;
	pendURL.push(url);
	}
	setTimeout('getNewTickerData();',7000);
}

function getDelta(deltaClass)
{
	var needTicker=0;
	if ((gEventStack.length<50) && (gFreezeTicker==0))
	{
		needTicker=1;
	}
	var url=gRespondingApp+'?want=getdelta&getTicker='+needTicker+'&v='+gV+'&dinterval='+gDeltaIntervalms+'&dclass='+deltaClass;
	pendURL.push(url);
	setTimeout('getDelta(\''+deltaClass+'\');',gDeltaIntervalms);
}

function tipCheckIn()
{
    var R= Math.random();
    var url='/cgi-perl/c2tip.mpl?want=tipcheckin&session='+gsess+'&R='+R;
	pendURL.push(url);
}




function moveEl1ToLocEl2 (id1,id2,offsetx,offsety)
{
	var el2=document.getElementById(id2);
	var posx2=findPosX(el2);
	var posy2=findPosY(el2);
	var el1=document.getElementById(id1);
	el1.style.position = "absolute";
	var T=parseInt(posy2)+parseInt(offsety);
	var L=parseInt(posx2)+parseInt(offsetx);
	if (offsety!==undefined) {el1.style.top = T+'px';}
	if (offsetx!==undefined) {el1.style.left =L+'px';}
}
function moveEl1ToAbsolute (id1,T,L,B,R)
{
	var el1=document.getElementById(id1);
	el1.style.position = "absolute";
	
	if (T!==undefined) {el1.style.top = T+'px';}
	if (L!==undefined) {el1.style.left =L+'px';}
	if (B!==undefined) {el1.style.bottom =z+'px';}
	if (R!==undefined) {el1.style.right =R+'px';}
}
function moveEl1ToRightCol(id1)
{
	var el1=document.getElementById(id1);
	el1.style.position = "absolute";
	el1.style.top ='0px';
	el1.style.right ='0px';
}
function moveEl1ToRelative (id1,T,L,B,R)
{
	var el1=document.getElementById(id1);
	el1.style.position = "relative";
	
	if (T!==undefined) {el1.style.top = T+'px';}
	if (L!==undefined) {el1.style.left =L+'px';}
	if (B!==undefined) {el1.style.bottom =z+'px';}
	if (R!==undefined) {el1.style.right =R+'px';}
}


function loadhelp(classname,contentname,el)
{
    var posx=findPosX(el);
	var posy=findPosY(el);
    dynamicContent (classname,contentname,'absolute',posy+25,posx-5,'undef','undef');
}
    
//dynamicContent('dynamicOXclass','popupSystemFinder','anchorDiv|absolute',X,Y,R|undef,B|undef) - R,B used for absolute positioning
function dynamicContent (classname,contentname,divAnchorName,offsetX,offsetY,B,R)
{
	if (divAnchorName)
	var rkey=Math.random();
	var url=CGI+'/page.mpl?want=dynamicContent&anchorname='+encodeURIComponent(divAnchorName)+'&classname='+encodeURIComponent(classname)+'&contentname='+encodeURIComponent(contentname)+'&offsetx='+offsetX+'&offsety='+offsetY+'&B='+B+'&R='+R+'&session='+gsess+'&rkey='+rkey;
	
	pendURL.push(url);
}
function handlePostButton()
{
	moveEl1ToLocEl2 ('forumpopup','forumLabel',335,29);
	show(true,'forumpopup');
	document.getElementById('forumpopup').style.display = 'block';
	return false;
	
}

function dchat(cid,sess)
{
	var url=gRespondingApp+'?want=dchat&v='+gV+'&cid='+cid;
	pendURL.push(url);
}
function chatterMore()
{
	var url=gRespondingApp+'?want=morechat&v='+gV;
	pendURL.push(url);
}


function checkEnterKeyChat(myfield,e)
{
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;

    if (keycode == 13)
    {
	var chat=document.forms['chatform'].newchat.value;
	submitChat(chat);
	return false;
    }
    else
	return true;
}
    

function submitChat(chattext)
{
	var urienc=encodeURIComponent(chattext);
	var url=gRespondingApp+'?want=addchat&v='+gV+'&text='+urienc;
	pendURL.push(url);
	document.forms['chatform'].newchat.value='';
}

function handleShowPopUpSubmenu(submenuid,buttonid)
{
	moveEl1ToLocEl2 (submenuid,buttonid,0,19);
	if (1) //if (gCurrentChartType!=='Monte Carlo')
	{
		gCropper.remove();
	}
	toggleHideShowDiv(submenuid);
}

function innerAddWatchList(sid,sess)
{
	var url=gRespondingApp+'?want=addtowatchlist&sid='+sid+'&noTop='+gNoWatchListTop;
	 pendURL.push(url);
	 
	 
	 if (jIsInList(sid,gWatchList))
	 {
		
	 }
	 else
	 {
		setTimeout('glowdiv(\'wltileframe'+sid+'\');',800);
		gWatchList.push(sid);
		
	 }
}
function redrawClosedPop(callapp,sid,skip)
{
	var url=callapp+'?want=reqMoreClosed&systemid='+sid+'&skip='+skip+'&session='+gsess+'&v='+gV;
	pendURL.push(url);
}
function handleRequestReviewForm(callapp,sid)
{
	
     var url=callapp+'?want=reqReviewForm&sid='+sid+'&session='+gsess+'&v='+gV;
     pendURL.push(url);
}

function showClosed(callapp,sid)
{
	
	popupshow(true);
	var url=callapp+'?want=reqClosedTrades&systemid='+sid+'&session='+gsess+'&v='+gV;
	pendURL.push(url);
}
function toggleShowSymbols(sid)
{
    new Effect.Opacity('closedTradeHolder',{duration:.7, from:1, to:.2});
	var R= Math.random();
	var url='/cgi-perl/c2systems.mpl?want=togglesymbols&systemid='+sid+'&session='+gsess+'&R='+R;
	pendURL.push(url);
}
function closedTradeLimit(sid,param)
{
    new Effect.Opacity('closedTradeHolder',{duration:.7, from:1, to:.2});
    
	var R= Math.random();
	var url='/cgi-perl/c2systems.mpl?want=moreClosedTradesInset&systemid='+sid+'&session='+gsess+'&paramtype=limit&paramval='+param+'&R='+R;
	pendURL.push(url);
}	
function closedTradeOffset(sid,param)
{
    new Effect.Opacity('closedTradeHolder',{duration:.7, from:1, to:.2});
	var R= Math.random();
	var url='/cgi-perl/c2systems.mpl?want=moreClosedTradesInset&systemid='+sid+'&session='+gsess+'&paramtype=offset&paramval='+param+'&R='+R;
	pendURL.push(url);
}
function closedTradeReset(sid)
{
    new Effect.Opacity('closedTradeHolder',{duration:.7, from:1, to:.2});
	var R= Math.random();
	var url='/cgi-perl/c2systems.mpl?want=moreClosedTradesInset&systemid='+sid+'&paramtype=reset&R='+R;
	pendURL.push(url);
}
function changePosSort(sid,param,enc)
{
    if (enc=='D')
    {
        new Effect.Opacity('posHold'+sid,{duration:.7, from:1, to:.2});
    }
    else
    {
        new Effect.Opacity('positionsholder',{duration:.7, from:1, to:.2});
    }
	var R= Math.random();
	var url='/cgi-perl/c2systems.mpl?want=changePosSort&systemid='+sid+'&session='+gsess+'&param='+param+'&enc='+enc+'&R='+R;
	pendURL.push(url);
}
function reqNewOpenPos(sid,enc,id)
{
    new Effect.Opacity(id,{duration:.7, from:1, to:.2});
    
	var R= Math.random();
	var url='/cgi-perl/c2systems.mpl?want=reqOpenPos&systemid='+sid+'&session='+gsess+'&enc='+enc+'&R='+R;
	pendURL.push(url);
}
function onEndCrop( coords, dimensions ) {
    
    if (Math.abs(coords.x2-coords.x1)<15)
    {
	return false;
    }
    var R= Math.random();
    document.getElementById('chartdiv').innerHTML='<img id="chartImage" src="syscharts.mpl?charttype='+gCurrentChartType+'&sid='+gSystemID+'&rand='+R+'&cmd=zoom&width='+gChartWidth+'&height='+gChartHeight+'&zoomx1='+coords.x1+'&zoomx2='+coords.x2+'&zoomy1='+coords.y1+'&zoomy2='+coords.y2+'&session='+gsess+'" width="'+gChartWidth+'" height="'+gChartHeight+'">';
    document.getElementById('zoomContent').innerHTML='<span id="innerzoom"><a href="#" onclick="handleChartUnzoom();">Restore unzoomed chart</a></span>';
	stopcrop();
	gCropper=new Cropper.Img( 'chartImage', { minHeight: 300, onEndCrop: onEndCrop} );

	setTimeout('glowdiv(\'innerzoom\');',600);
	setTimeout('glowdiv(\'innerzoom\');',1600);
}

function handleChartUnzoom()
{
	var R= Math.random();
	document.getElementById('chartdiv').innerHTML='<img id="chartImage" src="syscharts.mpl?uz=1&charttype='+gCurrentChartType+'&sid='+gSystemID+'&rand='+R+'&width='+gChartWidth+'&height='+gChartHeight+'&session='+gsess+'" width="'+gChartWidth+'" height="'+gChartHeight+'">';
	document.getElementById('zoomContent').innerHTML='Drag mouse in chart to zoom';
	stopcrop();
	gCropper=new Cropper.Img(
            'chartImage',
            {  	minHeight: 300,
		onEndCrop: onEndCrop}
        );
}

function handleRemoveSysLine(callapp,sess,showingid,removeid)
{
	var R= Math.random();
	new Effect.Opacity('chartcontainer',{duration:.7, from:1, to:.2});
	var url=callapp+'?cmd=removesystem&systemid='+showingid+'&removesys='+removeid+'&charttype='+gCurrentChartType+'&session='+sess+'&v='+gV+'&rand='+R+packagePortfolio();
	pendURL.push(url);
}

function handleChartSelect(callapp,charttype,sid,portfolioDisplay)
{
	if ((charttype=='Monte Carlo')||(charttype=='Personalized'))
	{
		moveEl1ToLocEl2 ('loadingdiv','chartdiv',142,100);
		if (charttype=='Monte Carlo') {document.getElementById('loadingtext').innerHTML='Running Monte Carlo simulation...';}
		else
		{
			document.getElementById('loadingtext').innerHTML='Building custom chart based on your<BR>personalized preferences<BR>(commission rates, starting equity, costs, etc.)...';
		}
		show(true,'loadingdiv');
		document.getElementById('loadingdiv').style.display = "inline";
	}
	
	var R= Math.random();
	var urienc=encodeURIComponent(charttype);
	gCurrentChartType=charttype;
	var url=callapp+'?want=newcharttype&systemid='+sid+'&charttype='+urienc+'&session='+gsess+'&v='+gV+'&rand='+R;
	pendURL.push(url);
	
	
	if (charttype=='Monte Carlo')
	{
		document.getElementById('zoomContent').innerHTML='';
		document.getElementById('removeContent').innerHTML='';
		new Effect.Opacity('chartcontainer',{duration:.7, from:1, to:.2});
		var url=SITE_BASE+'/cgi-perl/syscharts.mpl?charttype='+urienc+'&sid='+gSystemID+'&rand='+R+'&width='+gChartWidth+'&height='+gChartHeight+'&session='+gsess+'&rand='+R+'&forcecache=1';
		pendURL.push(url);
	}
	
	else
	{
		var addend='';
		if (portfolioDisplay!=undefined)
		{
			addend='&portfolioDisplay='+portfolioDisplay+packagePortfolio();
		}
		var url=SITE_BASE+'/cgi-perl/syscharts.mpl?charttype='+urienc+'&sid='+gSystemID+'&rand='+R+'&width='+gChartWidth+'&height='+gChartHeight+'&session='+gsess+'&forcecache=1'+addend;
		
		
		pendURL.push(url);
	
	
		document.getElementById('zoomContent').innerHTML='Drag mouse in chart to zoom';
		
	}
	
	
	
	
	

}

function forcePortfolio(callapp,sess,sid)
{
    if (gPortfolioDisplay==0) {togglePortfolio(callapp,sess,sid);}
}
function togglePortfolio(callapp,sess,sid)
{
	if (gPortfolioDisplay==0)
	{
		var url=callapp+'?want=buildPortfolioDiv&sysid='+sid+'&session='+sess+'&currentShow=0&autorebalance=1';
		pendURL.push(url);
		
		handleChartSelect(callapp,gCurrentChartType,sid,1);
	}
	else
	{
		Effect.BlindUp('portfolio');
		gPortfolioDisplay=0;
		var url=callapp+'?want=reportPortStatus&sysid='+sid+'&session='+sess+'&currentShow=1';
		pendURL.push(url);
		
		handleChartSelect(SITE_BASE+'/cgi-perl/c2systems.mpl',gCurrentChartType,sid,0);
	}
	
}


function handleRemoveForward (callapp,sess,sid)
{
	var url=callapp+'?want=removedelta&delta=-1&sysid='+sid+'&session='+sess;
	pendURL.push(url);
}
function handleRemoveBackward (callapp,sess,sid)
{
	var url=callapp+'?want=removedelta&delta=1&sysid='+sid+'&session='+sess;
	pendURL.push(url);
}

function handlePortKeyDown(sn)
{
	setTimeout('recalcPort('+sn+')',50);
}
function recalcPort(sn)
{
	var total=0;
	var number_of_elements = document.forms['portfolioForm'].elements.length;
	for (var i=0; i<number_of_elements;i++)
	{
		if (document.forms['portfolioForm'].elements[i].name.substring(0,10)=='portWeight')
		{
			total=total+parseInt(document.forms['portfolioForm'].elements[i].value);
		}
	}
	
	updatePortfolioButton(total,sn);
	
}

function updatePortfolioButton(total,sn)
{
	if (total==100)
	{
		document.forms['portfolioForm'].portButton.disabled=false;
		document.getElementById('portConstraint').innerHTML='';
	}
	else
	{
		document.forms['portfolioForm'].portButton.disabled=true;
		document.getElementById('portConstraint').innerHTML='Sum of portfolio should equal 100% (<a href="#" onclick="portAuto('+sn+');return false;">Auto-calculate</a>)';
	}
}
function portAuto(startAfter)
{
	// first get total
	var total=0;
	var number_of_elements = document.forms['portfolioForm'].elements.length;
	var count=0;
	var lockamount=0
	for (var i=0; i<number_of_elements;i++)
	{
		if (document.forms['portfolioForm'].elements[i].name.substring(0,10)=='portWeight')
		{
			total=total+parseInt(document.forms['portfolioForm'].elements[i].value);
			
			count=count+1;
			
			if (count==startAfter)
			{
				lockamount=parseInt(document.forms['portfolioForm'].elements[i].value);
			}
		}
	}
	var remain=100-total;
	var splitBy;
	if (startAfter!=0)
	{
		splitBy=count-1;
	}
	else
	{
		splitBy=count;
	}
	if (splitBy<=0) {startAfter=0; splitBy=count;}
	var split=Math.round(remain/splitBy);
	var recount=0;
	for (var i=0; i<number_of_elements;i++)
	{
		if (document.forms['portfolioForm'].elements[i].name.substring(0,10)=='portWeight')
		{
			recount=recount+1;
			if (recount!=startAfter)
			{
				document.forms['portfolioForm'].elements[i].value=parseInt(document.forms['portfolioForm'].elements[i].value)+split;
				total=total+split;
			}
			
			if (recount==count)
			{
				document.forms['portfolioForm'].elements[i].value=parseInt(document.forms['portfolioForm'].elements[i].value)+(100-total);
				total=100;
			}
		}
	}
	
	updatePortfolioButton(total,startAfter);
	
}
function packagePortfolio()
{
	if (gPortfolioDisplay==0)
	{
		return ('');
	}
	var add='';
	
	var number_of_elements = document.forms['portfolioForm'].elements.length;
	for (var i=0; i<number_of_elements;i++)
	{
		if (document.forms['portfolioForm'].elements[i].name.substring(0,10)=='portWeight')
		{
			add=add+parseInt(document.forms['portfolioForm'].elements[i].value)+'_';
		}
		
	}
	return ('&portfolio='+add);
}

function handlePortfolioSubmit(callapp,sess,sid)
{
	
	handleChartSelect(callapp,gCurrentChartType,sid,1);
	
}

function dropDivAndRestoreCropper(div)
{
	Effect.DropOut(div);
	restoreCropper();
}
function restoreCropper()
{
	stopcrop();
	gCropper=new Cropper.Img(
	'chartImage',
	{  	minHeight: 300,
	    onEndCrop: onEndCrop}
	);
	
}
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}
function handleFuturesRadio()
{
	var disablePerSymbol=false;
	
	if (getCheckedValue(document.personal.futuresCommType)=='same')
	{
		disablePerSymbol=true;
	}
	var doChange =['futures_'];
	disableFormElsStartingWith(disablePerSymbol,'personal',doChange,document.personal.futuresCommType) ;
}
function handleCommCheck()
{
	var dontChangeElementsWith =['startamount', 'showSubs', 'showComm', 'B1'];
	if (document.personal.showComm.checked==false)
	{
		disableFormEls(true,'personal',dontChangeElementsWith);
	}
	else{
		disableFormEls(false,'personal',dontChangeElementsWith);
	}
}

function doSubsetDisable(clickedEl,changeClass)
{
	var doChange =[changeClass];
	var setTo;
	if (clickedEl.checked==true)
	{
		setTo=false;
	}
	else{
		setTo=true;
	}
	disableFormElsStartingWith(setTo,'personal',doChange,clickedEl) ;
}

function disableFormEls(wantDisable,FormName,refDontChangeElementsStartingWith) 
{
	for(i = 0; i < document.forms[FormName].elements.length; i++)
	{ 
		elm = document.forms[FormName].elements[i];
		
		var forceNoChange=0; 
		if (refDontChangeElementsStartingWith.length)
		{
			for (var a=0; a<refDontChangeElementsStartingWith.length; a++)
			{
				if (!forceNoChange)
				{
					var testElement=refDontChangeElementsStartingWith[a];
					var isContained = elm.name.indexOf(testElement) != -1;
					if (isContained)
					{
						forceNoChange=1;
					}
				} 
			}
		}
		if (!forceNoChange)
		{
			elm.disabled=wantDisable;
		}
	}  
}

function disableFormElsStartingWith(wantDisable,FormName,refChangeElementsStartingWith,skipThisEl) 
{
	for(i = 0; i < document.forms[FormName].elements.length; i++)
	{ 
		elm = document.forms[FormName].elements[i];
		if (elm!==skipThisEl)
		{
			var forceChange=0; 
			if (refChangeElementsStartingWith.length)
			{
				for (var a=0; a<refChangeElementsStartingWith.length; a++)
				{
					if (!forceChange)
					{
						var testElement=refChangeElementsStartingWith[a];
						var isContained = elm.name.indexOf(testElement) != -1;
						//alert ('testing if element named '+ elm.name +'contains string='+testElement);
						if (isContained)
						{
							forceChange=1;
						}
					} 
				}
			}
			if (forceChange)
			{
				elm.disabled=wantDisable;
			}
		}
	}  
}

function handlePersonalCancel()
{
	popupshow(false);
	if (gCurrentChartType !== 'Monte Carlo')
	{
		stopcrop();
		
		gCropper=new Cropper.Img(
		'chartImage',
	       
		{  	minHeight: 300,
		    onEndCrop: onEndCrop}
		);
	}
	
}

function handlePersonalSubmit(callapp,sess,sid)
{
	var url=callapp+'?want=submitPersonalization&systemid='+sid+'&session='+sess;
	var didRadio=0;
	for(i = 0; i < document.forms['personal'].elements.length; i++)
	{
		var elm = document.forms['personal'].elements[i];
		var value=elm.value;
		if (elm.name=='futuresCommType')
		{
			value=getCheckedValue(document.personal.futuresCommType);
			
			if (!didRadio)
			{
				url=url+'&'+elm.name+'='+encodeURIComponent(elm.value);
				didRadio=1;
			}
		}
		else
		{
			var returnVal=elm.value;
			if (elm.type == "checkbox")
			{
				returnVal=0;
				if (elm.checked==true)
				{
					returnVal=elm.value;
				}
			}
			url=url+'&'+elm.name+'='+encodeURIComponent(returnVal);
		}
		
	}
	
	
	popupshow(false);
	if (gCurrentChartType !== 'Monte Carlo')
	{
		stopcrop();
		gCropper=new Cropper.Img(
		'chartImage',
	       
		{  	minHeight: 300,
		    onEndCrop: onEndCrop}
		);
	}
	
	
	pendURL.push(url);
	
	handleChartSelect(callapp,'Personalized',sid,gPortfolioDisplay);
}
function requestPopup(which)
{
    var R= Math.random();
	var url=SITE_BASE+'/cgi-perl/dashreceiver.mpl?want=reqPop&which='+encodeURIComponent(which)+'&R='+R;
	pendURL.push(url);
}
function handleEditPersonal(sid)
{
	var R= Math.random();
	var url=SITE_BASE+'/cgi-perl/c2systems.mpl?want=forcePersonalPopUp&systemid='+sid+'&R='+R;
	pendURL.push(url);
}
function stopcrop()
{
	try{
	gCropper.remove();
	gCropper=undefined;
	}
	catch (err)
	{
	}
}

function resubmitsearch(b,searchid,switches)
{
    b.innerHTML='<div class="btnG"><span><span><span>Searching...</span></span></span></div>';
    var R= Math.random();
    var url=SITE_BASE+'/cgi-perl/board.mpl?want=searchforums&searchid='+searchid+'&R='+R+switches;
    new Effect.Opacity('content2colbig',{duration:.7, from:1, to:.2});
	pendURL.push(url);
	setTimeout('searchStatus()',5000);

}

function handleForumSearchSubmit()
{
	if (document.forms['forumsearch'].search.value.length<3)
	{
		document.getElementById('fsearchMsg').innerHTML='<i><b>Search term is too short.<b></i>';
	}
	else{
		document.getElementById('fsearchMsg').innerHTML='Searching...&nbsp;<img src="../images/ajax-loader.gif" alt="Wait" />';
		document.forms['forumsearch'].B1.disabled=true;
		
       var R= Math.random();
	   var url=SITE_BASE+'/cgi-perl/board.mpl?want=ajaxsearchforums&search='+encodeURIComponent(document.forms['forumsearch'].search.value)+'&andor='+getCheckedValue(document.forms['forumsearch'].andor)+'&session='+gsess+'&R='+R;
	   
	   
	   new Effect.Opacity('content2colbig',{duration:.7, from:1, to:.2});
	   pendURL.push(url);
	
	   
	   
	   setTimeout('searchStatus()',5000);
	}
	
}

function searchStatus()
{
    window.location=SITE_BASE+'/cgi-perl/board.mpl?want=searchstatus';
}

function checkEnterKeyForum(myfield,e)
{
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;

    if (keycode == 13)
    {
	handleForumSearchSubmit();
	return false;
    }
    else
	return true;
}

function handleForumSearch(el,woffset,hoffset)
{
	
	var popup=document.getElementById('c2popupframe');
	var cont='<div class="forumsearchbox"><form action="" method="post" name="forumsearch">\
<h2>&nbsp;&nbsp;&nbsp;Search within C2 Forums</h2><div class="frightX"><a href="#" onclick="show(false,\'c2popupframe\');document.getElementById(\'c2popupframe\').style.display = \'none\';">X</a></div><br/><br/>\
<div><span>Search for:&nbsp;</span></div><div><input name="search" type="text" size="30" tabindex="1" onKeyPress="return checkEnterKeyForum(this,event)"/></div><br />\
<div id="std">Separate search terms, using commas, like this.</div><br />\
<div><span class="nudge">Find posts with</span></div><div><input name="andor" type="radio" value="or" checked  tabindex="2"/>Any</div><div><input name="andor" type="radio" value="and"  />All</div><div><span class="nudge">terms</span></div>\
<div id="sub"><input name="B1" type="button" value="Search" onclick="handleForumSearchSubmit();" tabindex="3" /></div><br />\
<div id="fsearchMsg">&nbsp;</div><br/></form></div>';
        
	popup.innerHTML=cont;
	
	var divx=findPosX(document.getElementById(el));
	var divy=findPosY(document.getElementById(el));
	
	
	var xoffset=divx+woffset;
	var yoffset=divy+hoffset;


	popup.style.position = "absolute";
	popup.style.top = yoffset+'px';
	popup.style.left =xoffset+'px';
	
	show(true,'c2popupframe');
	document.getElementById('c2popupframe').style.display = 'block';
	document.forumsearch.search.focus();
	
}

function forumPostSuggestion(q)
{
	if (q.length>1)
	{
	var url=SITE_BASE+'/cgi-perl/suggest.mpl?format=2&entry='+encodeURIComponent(q);
	pendURL.push(url);
	}
}

function setSessionVal(sess,key,uencval)
{
	var R= Math.random();
	var url=gRespondingApp+'?want=setSessionValue&key='+key+'&val='+encodeURIComponent(uencval)+'&R='+R;
	pendURL.push(url);
}

function handleUnsubscribeRequest(sysid,caller)
{
	var R= Math.random();
	var url=SITE_BASE+'/cgi-perl/c2systems.mpl?session='+gsess+'&want=unsubscribe&systemid='+sysid+'&return='+caller+'&R='+R;
	pendURL.push(url);
}
function handleDisclosure()
{
	var R= Math.random();
	var url=SITE_BASE+'/cgi-perl/c2systems.mpl?session='+gsess+'&want=pulldisclosure&R='+R;
	pendURL.push(url);
}
function dropTableRow (sess,nameRowObj,settingVal)
{
    setSessionVal(sess,nameRowObj,settingVal);
    Effect.DropOut(nameRowObj);
    document.getElementById('hiddenrowStatus').innerHTML='<a href="systemmanager.mpl?clear=1">Show hidden rows?</a>';
}
function changeElementsOfClass(className,changeTo)
{
  var all = document.all ? document.all :
  document.getElementsByTagName('*');
  var elements = new Array();
  for (var e = 0; e < all.length; e++)
  {
    if (all[e].className == className)
      elements[elements.length] = all[e];
  }
  var numel=all.length;
  for(var i=0;i<elements.length;i++)
  {
     elements[i].innerHTML=changeTo;
  }
}

function changeMultipleEls()
{
    var all = document.all ? document.all : document.getElementsByTagName('*');
    for (var e = 0; e < all.length; e++)
    {
        
        if (gChangeHash[all[e].className]!==undefined)
        {
            var old=all[e].innerHTML;
            var pfo=parseFloat(old);
            var pfct=parseFloat(gChangeHash[all[e].className]);
            if (pfo<pfct)
            {
                new Effect.Highlight(all[e], { startcolor: '#B6F9AD', endcolor: '#ffffff' });
            }
            else if (pfo>pfct)
            {
                new Effect.Highlight(all[e], { startcolor: '#FFC2C2', endcolor: '#ffffff' });
            }
            all[e].innerHTML=gChangeHash[all[e].className];
        } 
           
    }
}

function loadSystem(sid)
{
    window.location='/cgi-perl/system'+sid;
}

function attention(divname,wiggle,flash,postTipControl)
{
    gTipAcked=0;
    gTipFlashCount=0; 
    setTimeout('_attention(\''+divname+'\','+wiggle+','+flash+',\''+postTipControl+'\')',3000);
}

function _attention(divname,wiggle,flash,postTipControl)
{
    if (wiggle)
    {
        Effect.Shake(divname);
        if (postTipControl.length>0)
        {
        setTimeout('handlePostAttention(\''+divname+'\',\''+postTipControl+'\')',2000);
        }
    }
    if (flash)
    {
        tipflash(divname,wiggle,flash,postTipControl);
    }
    
}
function tipflash(divname,wiggle,flash,postTipControl)
{
    if ((gTipAcked==0)&&(gTipFlashCount<2))
    {
        new Effect.Highlight(divname,{ startcolor: '#FFF4BB', endcolor: '#ffffff' });
        setTimeout('tipflash(\''+divname+'\','+wiggle+','+flash+',\''+postTipControl+'\')',4000);
        gTipFlashCount++;
    }
    else if (!wiggle)
    {
        if (postTipControl.length>0)
        {
        handlePostAttention(divname,postTipControl);
        }
    }
    
}
function handlePostAttention(divname,dothis)
{
    document.getElementById('tip').className='c2tip';
    var e=decodeURIComponent(dothis);
    eval(e);
}

function _flyEl(el,todiv,offsetx,offsety)
{
    var tipx=findPosX(el);
	var tipy=findPosY(el);
	
	gTipX=tipx;
	gTipY=tipy;      
    var el2=document.getElementById(todiv);
	var posx2=findPosX(el2);
	var posy2=findPosY(el2);
	
	var needx=posx2-tipx+offsetx;
	var needy=posy2-tipy+offsety;
	
	new Effect.Move('tip', { x: needx, y: needy, mode: 'relative' });
}


function flytip(flydiv,todiv,offsetx,offsety)
{
    
                  
    var tipel=document.getElementById(flydiv);
    
	var classname='c2tipON_topRight';
	if (offsetx>0)
	{
	   classname='c2tipON_topLeft';
	}
	
	gReverseX=-offsetx;
    gReverseY=-offsety;
    
    _flyEl(tipel,todiv,offsetx,offsety);
    tipel.className=classname;
}


function makeVideoWindow(tipguid,anchordiv,url,offsetx,offsety,videowidth,videoheight)
{
    
	var vidx;
	var vidy;
	
	gTipID=tipguid;
	
	if (undefined == videowidth)
	{
	   videowidth=590;
	}
	if (undefined == videoheight)
	{
	   videoheight=425;
	}

	win = new Window({className: "alphacube", title: "Collective2 Videos", 
                     width:videowidth, height:videoheight, destroyOnClose: true, recenterAuto:false, minimizable:false, maximizable:false, resizable:false, url:url})
		
	if (anchordiv.length==0)
	{
	   vidx=0;
	   vidy=0;
	}
	else
	{
	   var anchorel=document.getElementById(anchordiv);
	   vidx=findPosX(anchorel);
	   vidy=findPosY(anchorel);
	}
	vidy=vidy+offsety;
    vidx=vidx+offsetx;
    
    win.setLocation(vidy, vidx);
    
    win.show();
    
    return(win);
	
}

function centered_ajax_dialog( src, w, h )
{
    if ( ! w ) w = 930;
    if ( ! h ) h = 450;
 
    Dialog.alert( {url: src, options: { method: 'get' }}, {className: "alphacube", 
       width:w, height:h, zIndex: 999999, okLabel: "OK", onOk: function() { return true; } });
}

function hidetip(tipguid)
{
    Effect.DropOut('tip');
    var R= Math.random();
    document.getElementById('tipanchor').innerHTML='<div id="tip" class="c2tip"></div>';
    reqNextTip(tipguid,gsess,'');

}
function ackhidetip(sess,tipid)
{
    Effect.DropOut('tip');
    var R= Math.random();
	var url='/cgi-perl/c2tip.mpl?want=acktip&tipid='+tipid+'&session='+sess+'&R='+R;
    pendURL.push(url);
}
function ackhidetiptop(sess,tipid)
{
    Effect.DropOut('topPageTip');
    var R= Math.random();
	var url='/cgi-perl/c2tip.mpl?want=acktip&tipid='+tipid+'&session='+sess+'&R='+R;
    pendURL.push(url);
}
function acktip(sess,tipid)
{
    var R= Math.random();
	var url='/cgi-perl/c2tip.mpl?want=acktip&tipid='+tipid+'&session='+sess+'&R='+R;
    pendURL.push(url);
}
function forgetTips(sess)
{
    var R= Math.random();
	var url='/cgi-perl/c2tip.mpl?want=forgetTips&session='+sess+'&R='+R;
    pendURL.push(url);
}
function reqNextTip(tipguid,sess,query)
{
    if (tipguid>0)
    {
        try{
        document.getElementById('nexttip').innerHTML='<span class="loading">Loading...</span>';
        }
        catch (e){}
    }
    var R= Math.random();
	var url='/cgi-perl/c2tip.mpl?want=reqtip&fromnexttip='+tipguid+'&query='+query+'&R='+R+'&session='+sess;
    pendURL.push(url);
}
function reqSpecificTip(fromtipid,tipguid,sess,afterrequest)
{
    var R= Math.random();
	var url='/cgi-perl/c2tip.mpl?want=reqtip&forceid='+tipguid+'&session='+sess+'&R='+R+'&after='+encodeURIComponent(afterrequest)+'&parentid='+fromtipid;
    pendURL.push(url);
}
function changeToAck(tipid)
{
    try{
    document.getElementById('tipcontrol').innerHTML='<ul><li><a href="#" onclick="hidetip('+tipid+');return false;">Done</a></li></ul>';
    }
    catch (e)
    {
    }
    if (tipid==0)
    {
        try{
        document.getElementById('tipcontrol').innerHTML='';
        }
        catch (e)
        {
        }
    }
    acktip(gsess,tipid);
}
function prevTips(sess)
{
    var R= Math.random();
	var url='/cgi-perl/c2tip.mpl?want=prevtips&session='+sess+'&R='+R;
    pendURL.push(url);
}

function tipShowMe(thistipid,anchorname,offsetx,offsety)
{
    
    document.getElementById('tipcontrol').innerHTML='<ul><li class="lft"><a href="#" onclick="prevTips(\''+ gsess +'\');return false;">&laquo;&nbsp;Prev</a></li><li class="more"><a href="#" onclick="flytip(\'tip\',\''+anchorname+'\','+offsetx+','+offsety+');changeToAck('+thistipid+');return false;">Show me</a></li><li><div id="nexttip"><a href="#" onclick="reqNextTip('+thistipid+', \''+gsess+'\',0);return false;">Next&nbsp;&raquo;</a></div></li></ul>';
    
}
function changeToTip(fromtipid,nexttipid,anchorname,offsetx,offsety)
{
    try{
        document.getElementById('tipcontrol').innerHTML='<span class="loading">Loading...</span>';
    }
    catch (e){}
    
    var afterrequest='tipShowMe('+nexttipid+',\''+anchorname+'\','+offsetx+','+offsety+');';
    reqSpecificTip(fromtipid,nexttipid,gsess,afterrequest);
    
}
function tipShowMeNext(thistipid,nexttipid,anchorname,offsetx,offsety,label)
{
    document.getElementById('tipcontrol').innerHTML='<ul><li class="more"><a href="#" onclick="changeToTip('+thistipid+','+nexttipid+',\''+anchorname+'\','+offsetx+','+offsety+');flytip(\'tip\',\''+anchorname+'\','+offsetx+','+offsety+');changeToAck('+thistipid+');return false;">'+label+'</a></li></ul>';
        
}
function loadMonthlyReturns(sysid,retType)
{
    
    var R= Math.random();
	var url='/cgi-perl/c2systems.mpl?want=loadreturns&systemid='+sysid+'&type='+retType+'&session='+gsess+'&R='+R;
	new Effect.Opacity('monthEquity',{duration:.7, from:1, to:.2});
    pendURL.push(url);
}
function pausecomp(millis) 
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); } 
while(curDate-date < millis);
} 


function taKeyup()
{
   gLastTAPressDate=new Date();
   
   setTimeout('checkMAx();',6);
   if (gUnprocTA==0)
   {
	
      gUnprocTA=1;
      setTimeout('checkPendingTA();',10);
   }
}

function checkMAx()
{
    var c=document.getElementById('max').className;
    var l=document.getElementById('maentry').value.length;
    if (c==='closeXoff')
    {
        if (l>0) {document.getElementById('max').className='closeX';}
    }
    else if ((c==='closeX') && (l==0))
    {
        document.getElementById('max').className='closeXoff'
    }
}


    
function checkPendingTA()
{
	
   if (gUnprocTA)
   {
      var end=new Date();
      
      if ((document.getElementById('maentry').value.length>0) && (document.getElementById('maentry').value>gMinMA))
      {
        document.getElementById('maWarn').style.display="block";
        glowdiv('maWarn');
        gUnprocTA=0;
        return;
      }
      else if (document.getElementById('maWarn').style.display==='block')
      {
        fadediv('maWarn');
      }
      var msSinceKeyPress=end.getTime() - gLastTAPressDate.getTime();
      
      if (document.getElementById('maentry').value==1)
    	   {
    	       document.getElementById('mas').innerHTML='';
    	   }
    	   else
    	   {
    	       document.getElementById('mas').innerHTML='s';
    	   }
    	   
    	   
      if (msSinceKeyPress>580)
      {
	   
	   
	     var erased=0;
	     if ((gPriorTAval>0) && (document.getElementById('maentry').value.length==0))
	     {
	       erased=1;
	     }
         if ((document.getElementById('maentry').value>0)|| (erased))
    	 {
    	    var R= Math.random();
    	    var sendValue=document.getElementById('maentry').value;
    	    if (erased)
    	    {
    	       sendValue=0;
    	    }
    	    else
    	    {
    	       gPriorTAval=sendValue;
    	    }
    		var url='/cgi-perl/syscharts.mpl?want=changema&maval='+sendValue+'&systemid=' + gSystemID + '&width=520&height=300&session='+gsess+'&rand='+R;
        	pendURL.push(url);
        
            new Effect.Opacity('chartcontainer',{duration:.7, from:1, to:.2});
            
            gUnprocTA=0;
        	return (false);
	        
    		
    	 }
    	 else{
    		
    		
    		gUnprocTA=0;
    	 }
      }
      else
      {
         setTimeout('checkPendingTA();',10);
	 
      }
   }
  
}

function toggleVisibilOfClass(whichClass)
{
    var all = document.all ? document.all : document.getElementsByTagName('*');
    for (var e = 0; e < all.length; e++)
    {
        
        if (all[e].className==whichClass)
        {
           
            if ((all[e].style.display==='none')||(all[e].style.display===''))
        	{
        		all[e].style.display = "block";
        		
        	}
        	else
        	{
        		all[e].style.display = "none";
        	}
        } 
           
    }
}

function forceVisibilOfClass(whichClass,onOff)
{
    var all = document.all ? document.all : document.getElementsByTagName('*');
    for (var e = 0; e < all.length; e++)
    {
        
        if (all[e].className==whichClass)
        {
           
            if ((all[e].style.display==='none')||(all[e].style.display===''))
        	{
        		if (onOff==1) {all[e].style.display = "block";}
        		
        	}
        	else
        	{
        		if (onOff==0) {all[e].style.display = "none";}
        	}
        } 
           
    }
}

function intermittentflashDiv(el,periodms,newstate)
{
    if (newstate==0)
    {
        setTimeout("intermittentflashDiv('"+el+"',"+periodms+",1);",periodms);
        return;
    }
    
    var nextstate;
    if (newstate==1)
    {
        new Effect.Opacity(el,{duration:.3, from:1, to:0});
        nextstate=2;
    }
    else
    {
        new Effect.Opacity(el,{duration:.3, from:0, to:1});
        nextstate=1;
    }
    setTimeout("intermittentflashDiv('"+el+"',"+periodms+","+nextstate+");",periodms);
}
function intermittentglowDiv(el,numtimes)
{
    glowdiv(el);
    var nn=numtimes-1;
    if (nn>0)
    {
    setTimeout("intermittentglowDiv('"+el+"',"+nn+");",2000);
    }
}
function reqPM (msgid)
{
    fadeAndSnakeDiv('msg'+msgid); 
    var R= Math.random();
    var url='/cgi-perl/user/private_message.mpl?rm=readPrivateAjax&msg='+msgid+'&session='+gsess+'&R='+R;
    pendURL.push(url);

}
function selectTab (tabkind,whichtab)
{
    var R= Math.random();
    var url=gRespondingApp+'?want=selecttab&tabkind='+encodeURIComponent(tabkind)+'&whichtab='+encodeURIComponent(whichtab)+'&R='+R;
	pendURL.push(url);
}
function dropSeg(sid)
{
    Effect.DropOut('segment'+sid);
    if ((document.getElementById('dashRestoreAll').style.display==='none')||(document.getElementById('dashRestoreAll').style.display===''))
    {
        document.getElementById('dashRestoreAll').style.display = "block";
    }
    setSessionVal(gsess,'dashsyshide'+sid,1);
    glowdiv('dashRestoreAll');
}

function redrawDashSys(param)
{
    try
    {
        show(false,'c2popupframe');
	   document.getElementById('c2popupframe').style.display = 'none';
    }
    catch (err)
	{
	}
    var R= Math.random();
    var url='/cgi-perl/dashreceiver.mpl?want=refreshDashSys&session='+gsess+'&R='+R+'&param='+param;
    new Effect.Opacity('dashsystemwrapper',{duration:.7, from:1, to:.2});
    pendURL.push(url);
}

function regSystemSegmentForUpdates(sid,freqMS)
{
    var TR=Math.floor(Math.random()*6)*1000;
    setTimeout('reqSystemSeg('+sid+')',freqMS+TR);
}
function reqSystemSeg(sid)
{
    var R= Math.random();
    var url='/cgi-perl/dashreceiver.mpl?want=reqDashSys&session='+gsess+'&R='+R+'&sid='+sid;
    pendURL.push(url);
}

function processHelpRequest(wanthelp,sid,sess)
{
    var R= Math.random();
	var url='/cgi-perl/c2systems.mpl?want=reqat&sid='+sid+'&session='+sess+'&wanthelp='+wanthelp+'&na='+document.forms.autotradehelp.neveragain.value+'&name='+encodeURIComponent(document.forms.autotradehelp.personname.value)+'&tel='+encodeURIComponent(document.forms.autotradehelp.telephone.value)+'&email='+encodeURIComponent(document.forms.autotradehelp.email.value)+'&tz='+document.forms.autotradehelp.timezone.value+'&instru='+encodeURIComponent(document.forms.autotradehelp.instrument.value)+'&R='+R;
	
	pendURL.push(url);
	Effect.DropOut('genericPopup');
	
	if (wanthelp==1)
	{
	   setTimeout('alert(\'Okay, a human being AutoTrade Specialist will contact you by the end of one business day.\');',750);
	}
}

function anclick(tabclicked,currentselected)
{
    
    var R= Math.random();
    var url='/cgi-perl/my_analyst.mpl?want=selecttab&whichtab='+encodeURIComponent(tabclicked)+'&R='+R;
    pendURL.push(url);
}

function changeAnTo(cid,i)
{
    var changeTo='';
    if (i==1)
    {
        changeTo='not&nbsp;worth&nbsp;reading';
    }
    else if (i==2)
    {
        changeTo='worth&nbsp;a&nbsp;glance';
    }
    else if (i==3)
    {
        changeTo='good';
    }
    else if (i==4)
    {
        changeTo='very&nbsp;good';
    }
    else if (i==5)
    {
        changeTo='insightful';
    }
    document.getElementById('text'+cid).innerHTML=changeTo;
}

function changestars(cid,fromi,toi,picname)
{
    if ((fromi<6) && (toi>=fromi))
    {
        var i;
        for (i=fromi; i<=toi; i++)
        {
            document.getElementById('s'+cid+'s'+i).src='/images/'+picname;
        }
    }
}

function changeRating(cid,newrate)
{
    var R= Math.random();
    var url='/cgi-perl/my_analyst.mpl?want=changerate&cid='+cid+'&rate='+newrate+'&R='+R;
    pendURL.push(url);
}


function handleSystemPageTimePeriodSelect(drop,poolid,systemid)
{
    var tp=drop.value;
    var urienc=encodeURIComponent(tp);   
    R=Math.random();
    var url=SITE_BASE+'/cgi-perl/c2systems.mpl?cmd=reportTimePeriod&agg='+poolid+'&systemid='+systemid+'&R='+R+'&newsetting='+urienc;
    document.getElementById('loadstatus').innerHTML='Recalculating...';
    new Effect.Opacity('resultsHolder',{duration:.7, from:1, to:.2});
    pendURL.push(url);
}

function disableATbutton(bname)
{
    document.getElementById(bname).innerHTML='<a class="btnB h2"><span><span><span>Calculating...</span></span></span></a>';
}

