
function getElement(id) { 
return document.getElementById? document.getElementById(id) : document.all? document.all(id) : null; 
} 
function getIFRAME_doc_height(oIframe) { 
return document.body && document.body.scrollHeight? oIframe.document.body.scrollHeight : oIframe.document.height? oIframe.document.height : null; } 

function IFRAME_size_to_content(iframe_id) {
var oIframe = frames[iframe_id]; 
if (typeof oIframe!= 'undefined') {
var wid = getElement(iframe_id).offsetWidth; 
var hgt = getIFRAME_doc_height(oIframe); if (wid && hgt) oIframe.resizeTo(wid,hgt); 
} 
}
/* PLEASE REMOVE THIS - AND TEST */
function resetAllIframes() {
try
{
if (document.getElementById('snap1')){IFRAME_size_to_content('snap1'); }
if (document.getElementById('snap2')){IFRAME_size_to_content('snap2'); }
if (document.getElementById('snap3')){IFRAME_size_to_content('snap3'); }
if (document.getElementById('snap4')){IFRAME_size_to_content('snap4'); }
if (document.getElementById('snap5')){IFRAME_size_to_content('snap5'); }
if (document.getElementById('snap6')){IFRAME_size_to_content('snap6'); }
if (document.getElementById('snap7')){IFRAME_size_to_content('snap7'); }
if (document.getElementById('snap8')){IFRAME_size_to_content('snap8'); }
if (document.getElementById('snap9')){IFRAME_size_to_content('snap9'); }
if (document.getElementById('snap10')){IFRAME_size_to_content('snap10'); }
if (document.getElementById('snap11')){IFRAME_size_to_content('snap11'); }
if (document.getElementById('snap12')){IFRAME_size_to_content('snap12'); }
if (document.getElementById('snap13')){IFRAME_size_to_content('snap13'); }
if (document.getElementById('snap14')){IFRAME_size_to_content('snap14'); }
if (document.getElementById('snap15')){IFRAME_size_to_content('snap15'); }
if (document.getElementById('snap16')){IFRAME_size_to_content('snap16'); }
if (document.getElementById('snap17')){IFRAME_size_to_content('snap17'); }
if (document.getElementById('snap18')){IFRAME_size_to_content('snap18'); }
if (document.getElementById('snap19')){IFRAME_size_to_content('snap19'); }
if (document.getElementById('snap20')){IFRAME_size_to_content('snap20'); }
if (document.getElementById('snap21')){IFRAME_size_to_content('snap21'); }
if (document.getElementById('snap22')){IFRAME_size_to_content('snap22'); }
if (document.getElementById('snap23')){IFRAME_size_to_content('snap23'); }
if (document.getElementById('snap24')){IFRAME_size_to_content('snap24'); }
if (document.getElementById('snap25')){IFRAME_size_to_content('snap25'); }

}

catch(err) {
	return;
	}
}

function resetIframe(iframe_id) {IFRAME_size_to_content(iframe_id);}

/* The following was added for new snapshot capability */
//var pid="";
//var apid=["MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","MICROSOFT.XMLHTTP.1.0","MICROSOFT.XMLHTTP.1","MICROSOFT.XMLHTTP"];
var canrun = false;
//if (document.all){
//	alert(1);
//	for (var i=0; i < apid.length; i++) {
//		try {
//			var obj = new ActiveXObject(apid[i]);
//			pid=apid[i];
//			break;
//		} catch (ex){}
//	} 
//	if (pid!=""){
//		canrun=true;
//	}
//}
//else{
	try {
		var obj=new XMLHttpRequest();
		canrun=true;
	}catch(ex){}
//}

function GoURL(url){
	if (canrun) 
	{
		var req=new XMLHttpRequest();
		req.open("GET", url, false);
		req.send(null);
		return req.responseText;
	}
	else 
	{
		return "";
	}
}
var indexors = new Object;

function NL(ctlname, fwd) {
	var divname=ctlname; 
	var arr=eval("arr"+ctlname);
	var indexor=indexors[ctlname]; 
		
	if (fwd&&indexor!=arr.length-1) 
		indexor++;
		
	if (!fwd&&indexor!=0) 
		indexor--;
	var d=document; 
	var o, nb, pb, snp, img; 
	if(d.all) 
	{	
		o=d.all[divname]; 
		nb=d.all[ctlname+'N'];	
		pb=d.all[ctlname+'P'];
		snp=d.all[ctlname+'SNP'];
	}
	else 
	{	
		o=d.getElementById(divname); 
		nb=d.getElementById(ctlname+'N');
		pb=d.getElementById(ctlname+'P');
		snp=d.getElementById(ctlname+'SNP');
	}
	o.innerHTML=arr[indexor].replace('$atemail$', '@'); 		
	indexors[ctlname]=indexor;
	//pb.style.display=(HP(ctlname))?"":"";
	//nb.style.display=(HN(ctlname))?"":"";
	
	pb.disabled=(HP(ctlname))?"":"true";
	pb.style.cursor = (HP(ctlname))?"hand":"default"
	pb.style.textDecoration = (HP(ctlname))?"underline":"none"
	nb.disabled=(HN(ctlname))?"":"true";
	nb.style.cursor=(HN(ctlname))?"hand":"default";
	nb.style.textDecoration = (HN(ctlname))?"underline":"none"
	
	
	//snp.style.display=((HP(ctlname)) && (HN(ctlname)))?"":"none";
	// Hide the Pipe if only one or none of Prev-Next are shown, show the pipe otherwise (if both are shown)
	if(pb.style.display== "none" || nb.style.display== "none")
		snp.style.display="none";
	else
		snp.style.display="";	
	
	//Set SnapShot Image
	setTimeout("SetSnapImage('img_"+ctlname+"_"+indexor+"')",1);
}
function SetSnapImage(imgid){
	var img;
	if(document.all) 
	{
		img = document.all[imgid];
	}
	else 
	{
		img = document.getElementById(imgid);
	}
	
	if(img != null){
		img.src = ImageRoot + "/btn/takesnapshot.gif"
		
		}
}

function ShowCurrent(ctlname, fwd) {
	var divname=ctlname; 
	var arr=eval("arr"+ctlname);
	var indexor=indexors[ctlname]; 
	var d=document; 
	var o, nb, pb, snp; 
	if(d.all) 
	{
		o=d.all[divname]; 
		nb=d.all[ctlname+'N'];	
		pb=d.all[ctlname+'P'];
		snp=d.all[ctlname+'SNP'];}
	else 
	{
		o=d.getElementById(divname); 
		nb=d.getElementById(ctlname+'N');
		pb=d.getElementById(ctlname+'P');
		snp=d.getElementById(ctlname+'SNP');		
	}
	
	//var re = new RegExp ('\$atemail\$', 'g') ;
	o.innerHTML=arr[indexor].replace('$atemail$', '@');
	o.innerHTML=o.innerHTML.replace('$atemail$', '@'); 
	o.innerHTML=o.innerHTML.replace('$atemail$', '@'); 
	o.innerHTML=o.innerHTML.replace('$atemail$', '@'); 
	o.innerHTML=o.innerHTML.replace('$atemail$', '@'); 
	indexors[ctlname]=indexor;
	if (HP(ctlname) == false && HN(ctlname) == false)
	{
		pb.style.display = "none";
		nb.style.display = "none";
	}
	
	//pb.style.textDecoration=(HP(ctlname))?"":"none";
	
	////////////////////////////
	if (HP(ctlname) == false)
	{
		pb.style.textDecoration = 'none';
		pb.style.cursor = 'default';
		pb.disabled = true;
	}
	else
	{
		pb.style.textDecoration = 'underline';
		pb.style.cursor = 'hand';
		pb.disabled = false;
	}
	
	if (HN(ctlname) == false)
	{
		nb.style.textDecoration = 'none';
		nb.style.cursor = 'default';
		nb.disabled = true;
	}
	else
	{
		nb.style.textDecoration = 'underline';
		nb.style.cursor = 'hand';
		nb.disabled = false
	}
	

	
	// When the snapshots are loaded, hide the pipe if only one or none of the Prev-Next are visible.
	if(pb.style.display== "none" || nb.style.display== "none")
		snp.style.display="none";
	else
		snp.style.display="";
	}
function HN(ctlname) {
var arr=eval("arr"+ctlname);
var indexor=indexors[ctlname];
if (indexor<arr.length-1) return true;
else return false;}

function HP(ctlname) {
	var indexor=indexors[ctlname];
	if (indexor>0) return true;
	else return false;
	}

function sendssreq(url,obj,arr,index) {
	obj.style.cursor  = "progress";
	if(GoURL(url)!=""){
		obj.style.display ="none";
		var item=arr[index];
		var x=item.indexOf('<img');
		var l=item.indexOf('>',x)+1;
		item=item.substr(0,x)+item.substr(l);arr[index]=item;
	}
	else{
		window.location=url;
	}
 }
