﻿// JScript File
// todo: locate poup refs and consolidate

// pop up window 1
var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=no,resizable=no,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

// pop up window 2  used for tutorials TODO:phase out in favor of popUpWindow (flexability)
function popup_window( url, id, width, height )
{
popup = window.open( url, id, 'toolbar=no,scrollbars=no,location=no,top=10,left=10,statusbar=no,menubar=no,resizable=no,width=' + width + ',height=' + height + '' );
popup.focus();
}

// image swap
function swap( img, isrc )
{
  if( !document.images ) return;
  document.images[img].src = isrc;
} // swap()


// drop shadow for images
function CallImage(img){
  pic1= new Image();
  pic1.src=(img);
  imgcontrol(img);
}
function imgcontrol(img){
  if((pic1.width!=0)&&(pic1.height!=0)){
    viewImg(img);
  }
  else{
    EW="imgcontrol('"+img+"')";
    IV=setTimeout(EW,20);
  }
}
function viewImg(img){
  imgwidth=pic1.width+20;
  imgheight=pic1.height+20;
  imgstr="width="+imgwidth+",height="+imgheight;
  fin=window.open(img,"",imgstr);
}

// START Function
// creates popup window [like overlib style]
// <a href="javascript:void(0);" onclick="notes(1, this)" style="color:#666;">LINK</a>
function notes(pState, pObj) {
		oSideNote = document.getElementById("accucharts-desc")
		
		if(pState==0){
			oSideNote.style.visibility = "hidden";
		} else {
			
			//first fine the x and y of the passed in imageID		
			calcXY(pObj)
			
			//now set the position...
			oSideNote.style.left = (gX + 90)+"px"
			oSideNote.style.top = (gY - 100)+"px"
			oSideNote.style.visibility = "visible"
		}
	}
	
	function calcXY(pObj) {

		var l_objElement = pObj
				
		var rd = {x:0, y:0}

		do
		{
			rd.x += l_objElement.offsetLeft
			rd.y += l_objElement.offsetTop
			l_objElement = l_objElement.offsetParent
		}
		while (l_objElement)
	
		gX = rd.x
		gY = rd.y
				
	}
	// END Function

//        <div id="accucharts-desc">
//		  <img src="/images/getting_started/practice_confirmation/accu-charts.gif" style="float:left;margin:0 10px 5px 0; border:1px solid #000;" />
//		  <p class="medium"><strong>What is FX AccuCharts?</strong><br />FX AccuCharts is an industry leading charting package designed to provide Forex traders the best possible experience with their technical analyses.</p>
//		  <span class="medium" style="text-align:right; display:block;"><a href="javascript://" onclick="notes(0, this)">Close</a></span>
//		  </div>	
