

/*
function HTTPRead(URL){
	var oFEF = FindObjById("FromExchangeFrame");
	oFEF.src = URL;
	var iframeDocument = oFEF.contentWindow ? oFEF.contentWindow.document : oFEF.contentDocument;
	var root = iframeDocument.documentElement || iframeDocument.body;
	return root.innerHTML;
}
*/

function HTTPRead(URL){
	var testFrame = document.createElement("IFRAME");
	testFrame.id = "FromExchangeFrame";
	testFrame.src = URL;
	testFrame.height = 0;
	testFrame.width = 0;
	testFrame.FRAMEBORDER = 0;
	document.body.appendChild(testFrame);

	var oFEF = FindObjById("FromExchangeFrame");
	oFEF.src = URL;
	var iframeDocument = oFEF.contentWindow ? oFEF.contentWindow.document : oFEF.contentDocument;
	//Wait while page loads
	while(iframeDocument==null){
		pausecomp(25);
		iframeDocument = oFEF.contentWindow ? oFEF.contentWindow.document : oFEF.contentDocument;		
	}
	var root = iframeDocument.documentElement || iframeDocument.body;
	var HTML = root.innerHTML;
	document.body.removeChild(testFrame);
	return HTML;
}


function pausecomp(millis){
	var date = new Date();
	var curDate = null;
	
	do { curDate = new Date(); }
	while(curDate-date < millis);
}

var IFrameObj; // our IFrame object

function callToServer(URL) {
	//alert("calltoserver = "+URL);

  if (!document.createElement) {return true};
  var IFrameDoc="";
  //var URL = 'server.html';
  if (!IFrameObj && document.createElement) {
    // create the IFrame and assign a reference to the
    // object to our global variable IFrameObj.
    // this will only happen the first time 
    // callToServer() is called
   try {
      var tempIFrame=document.createElement('iframe');
      tempIFrame.setAttribute('id','RSIFrame');
      tempIFrame.style.border='0px';
      tempIFrame.style.width='0px';
      tempIFrame.style.height='0px';
      IFrameObj = document.body.appendChild(tempIFrame);
      
      if (document.frames) {
        // this is for IE5 Mac, because it will only
        // allow access to the document object
        // of the IFrame if we access it through
        // the document.frames array
        IFrameObj = document.frames['RSIFrame'];
      }
    } catch(exception) {
      // This is for IE5 PC, which does not allow dynamic creation
      // and manipulation of an iframe object. Instead, we'll fake
      // it up by creating our own objects.
      iframeHTML='\<iframe id="RSIFrame" style="';
      iframeHTML+='border:0px;';
      iframeHTML+='width:0px;';
      iframeHTML+='height:0px;';
      iframeHTML+='"><\/iframe>';
      document.body.innerHTML+=iframeHTML;
      IFrameObj = new Object();
      IFrameObj.document = new Object();
      IFrameObj.document.location = new Object();
      IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
      IFrameObj.document.location.replace = function(location) {
        this.iframe.src = location;
      }
    }
  }
  
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    // we have to give NS6 a fraction of a second
    // to recognize the new IFrame
    setTimeout('callToServer()',10);
    return false;
  }
  
  if (IFrameObj.contentDocument) {
    // For NS6
    IFrameDoc = IFrameObj.contentDocument; 
  } else if (IFrameObj.contentWindow) {
    // For IE5.5 and IE6
    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    // For IE5
    IFrameDoc = IFrameObj.document;
  } else {
    return true;
  }
  
  IFrameDoc.location.replace(URL);
  return false;
}



function BuildImageScroller(){

	var ImageScrollerObj = FindObjById("Image_Scroll_Window");
	var ImgObjArray = ImageScrollerObj.getElementsByTagName('img');
	var ix = ImgObjArray.length;

	while(ix--){
		//alert(ImgObjArray[ix].src.toLowerCase().indexOf('_thumb.'));
		if(ImgObjArray[ix].src.toLowerCase().indexOf('_thumb.') != -1){
			//ImgObjArray[ix].setAttribute('onmouseover', 'this.style.cursor="hand"');
			ImgObjArray[ix].onmouseover = new Function ("evt", "this.style.cursor='pointer'");

			//alert("cur hand set");
			var MainImg = ImgObjArray[ix].src.toLowerCase().replace('_thumb','');
			//alert("MainImg = "+MainImg);
			var	preload_image = new Image(25,25); 
			var PopCmd = "ImgPopUp('" + MainImg + "');";
			preload_image.src=MainImg; 
			ImgObjArray[ix].onclick = new Function ("evt", PopCmd);
			//ImgObjArray[ix].setAttribute('onClick', PopCmd);
			//alert("onClick = "+ImgObjArray[ix].getAttribute('onclick'));
		
		}
	
	}
}

function ImgPopUp(t){
	//alert("Popup - "+t);
	var oFlashContainer1 = FindObjById("FlashContainer_1");
	var oFlashContainer2 = FindObjById("FlashContainer_2");
	var oNewFlashWindow = FindObjById("NewFlashWindow");
	//var oOrgFlashWindow = FindObjById("OrgFlashWindow");
	
	ChangeOpacityById("FlashContainer_2", 0);
	oNewFlashWindow.src = t;
	oFlashContainer2.style.visibility = "";
	FadeInImageById("FlashContainer_2");
	ExecAfterFadeIn("FlashContainer_2", "ImgPopUpSwitch()");	//Copy forground img to background img to be ready for next fadeover (fadein)
}

function ImgPopUpSwitch(){
	var oNewFlashWindow = FindObjById("NewFlashWindow");
	if(FindObjById("OrgFlashWindow")){
		var oOrgFlashWindow = FindObjById("OrgFlashWindow");
		oOrgFlashWindow.src = oNewFlashWindow.src;
	}
	else{
		var oFlashContainer1 = FindObjById("FlashContainer_1");
		oFlashContainer1.innerHTML = '<img src="../Images/Services/Services_main_image.jpg" alt="" name="OrgFlashWindow" id="OrgFlashWindow" border="0" style="visibility: hidden;">';
		var oOrgFlashWindow = FindObjById("OrgFlashWindow");
		oOrgFlashWindow.src = oNewFlashWindow.src;
	}

	

}
