


function popupwindow(url,name,width,height){
	return window.open(url,name,"left=100,top=100,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+width+",height="+height);
}


function confirmSubmit(text){
	var agree=confirm(text);
	if(agree){
		return true;
	}else{
		return false;
	}	
}



function obj(id){
	return document.getElementById(id);
}



function setValue(ID,newValue){
	// does not work well on FORM objects..
	document.getElementById(ID).value = newValue;
}



function scrolltotop(){
	window.scroll(0,0);
	document.scroll(0,0);
}



function cursor(newstyle){
	this.style.cursor = newstyle;
}




function format_money(num){
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num + '.' + cents);
}




function display_money(num){
	var num = format_money(num);
	if(num<0){
		return "- $"+num;
	}else{
		return "$"+num;
	}
}





function newsletter_subscribe(email){
	var newsletter_subscribe1 = document.createElement("script");
	newsletter_subscribe1.type = "text/javascript";
	newsletter_subscribe1.src = "https://www.telestial.com/gateway/?CMD=NEWSLETTER_SUBSCRIBE&EMAIL_ADDRESS="+escape(email);
	document.body.appendChild(newsletter_subscribe1);
}




function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}




function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}





function isNumberKey(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode
	if(charCode > 31 && (charCode < 48 || charCode > 57)){
		return false;
	}
	return true;
}







function show(id){
	try{
		document.getElementById(id).style.display='';
	}
	catch(e){};
}



function hide(id){
	try{
		document.getElementById(id).style.display='none';
	}
	catch(e){};
}




	
function toggleDisplay(id){
	if(document.getElementById(id).style.display=='none'){
		opacity(id,0,100,1000);
	}else{
		opacity(id,100,0,300);
	}
}



function swapDisplay(idShow,idHide,speed){
	opacity(idHide,100,0,50);
	setTimeout("opacity('"+idShow+"',0,100,'"+speed+"')",50);
}








function fadeIn(id,speed){
	opacity(id,0,100,speed);
}



function fadeOut(id,speed){
	opacity(id,100,0,speed);
}




function opacity(id,opacStart,opacEnd,millisec){
	var speed = Math.round(millisec/100);
	var browser=navigator.appName;
	if(browser.match("Mozilla")||browser.match("Netscape")){
		if(opacStart>opacEnd){
			var i=0;
			while((opacStart-i+1)>opacEnd){
				setTimeout("changeOpac('"+(opacStart-i)+"','"+id+"');",(i*speed));
				i++;
			}
		}
		if(opacStart<opacEnd){
			var i=0;
			while((opacStart+i-1)<opacEnd){
				setTimeout("changeOpac('"+(opacStart+i)+"','"+id+"');",(i*speed));
				i++;
			}
		}
		if(opacEnd>0){
			if(document.getElementById(id).style.display=='none'){
				setTimeout("document.getElementById('"+id+"').style.display='';",10);
			}
		}else{
			setTimeout("document.getElementById('"+id+"').style.display='none';",millisec);
		}
	}else{
		if(opacEnd>0){
			show(id);
		}else{
			hide(id);
		}
	}
}





function changeOpac(opacity,id){
	var browser=navigator.appName;
	if(browser.match("Mozilla")||browser.match("Netscape")){
		document.getElementById(id).style.opacity = (opacity/100);
		document.getElementById(id).style.MozOpacity = (opacity/100);
		//document.getElementById(id).style.KhtmlOpacity = (opacity/100);
	}
}















function showConversion(amount){
	tooltip.show("Loading..");
	loadurl("//www.telestial.com/gateway/?CMD=TOOLTIP_CONVERSION&AMOUNT="+amount+"","tooltip.show(response)");
}








var tooltip=function(){
	var id = 'tt';
	var top = -20;
	var left = 20;
	var maxw = 300;
	var speed = 10;
	var timer = 25;
	var endalpha = 100;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a=alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity='+alpha+')';
			}else{
				clearInterval(tt.timer);
				if(d==-1){tt.style.display='none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();


















































function is_numeric(sText){
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;
	for(i=0; i<sText.length && IsNumber==true; i++){ 
		Char = sText.charAt(i); 
		if(ValidChars.indexOf(Char)==-1){
			return false;
		}
	}
	return true;
}






















function loadurl(url,callback){
	var response;
	var req = false;
	if(window.XMLHttpRequest && !(window.ActiveXObject)) {
		try{
			req = new XMLHttpRequest();
		}catch(e){
			req = false;
		}
	}else if(window.ActiveXObject){
		try{
			req = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				req = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){
				req = false;
			}
		}
	}
	if(req){
		req.onreadystatechange = function(){
			if(req.readyState==4){
				var response = req.responseText;
				eval(""+callback+"");
			}
		}
		req.open('GET',url,true);
		req.send(null);
	}
}



function goto(URL){
	location.href = URL;
	return true;
}




function loadLink(URL){
	/* Displays a 'Please Wait' while the URL loads.. */
	var DIV = document.createElement("div");
	DIV.innerHTML = "<div style=\"position:fixed; left:0px; top:0px; width:100%; height:100%; background-image:url('https://www.telestial.com/images/fade_85.png');\"><table align=\"center\" cellspacing=\"0\" cellpadding=\"0\" style=\"margin-top:350px;\"><tr><td style=\"font-size:21px; font-weight:bold; color:#FFFFFF;\">Please Wait..</td></tr></table></div>";
	DIV.setAttribute('id','loadLink');
	document.body.appendChild(DIV);
	setTimeout("window.location.href='"+URL+"'",250);
}












function POST(target,vars,callback){
	var response;
	var req = false;
	
	if(window.XMLHttpRequest && !(window.ActiveXObject)) {
		try{
			req = new XMLHttpRequest();
		}catch(e){
			req = false;
		}
	}else if(window.ActiveXObject){
		try{
			req = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				req = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){
				req = false;
			}
		}
	}
	
	if(req){
		req.onreadystatechange = function(){
			if(req.readyState==4){
				var response = req.responseText;
				eval(""+callback+"");
			}
		}
		req.open('POST',target,true);
		req.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		req.setRequestHeader("Content-length",vars.length);
		req.setRequestHeader("Connection","close");
		req.send(vars);
	}
}































function showModalFrame(URL,WIDTH,HEIGHT,TITLE){
	showModal('<span><iframe src="'+URL+'" width="'+WIDTH+'" height="'+HEIGHT+'" frameborder="0"></iframe></span>',TITLE);
}

function showModal(INNERHTML,TITLE){
	var IMG_DIR = "/images/modal/";
	var HTML = '<div id="MODAL_C1" align="center" style="position:fixed; left:0px; top:0px; z-index:99999; background-image:url(\''+IMG_DIR+'/fade_65.png\');"></div>';
	
	HTML += '<div id="MODAL_C2" style="position:fixed; left:0px; top:0px; z-index:999999;">';
	HTML += '<table width="250" border="0" cellspacing="0" cellpadding="0">';
	HTML += '<tr><td>';
	HTML += '<table width="100%" border="0" cellpadding="0" cellspacing="0">';
	HTML += '<tr>';
	HTML += '<td width="25" align="left" valign="top"><img src="'+IMG_DIR+'/top_left.png" width="25" height="52" /></td>';
	HTML += '<td style="background-image:url(\''+IMG_DIR+'/top_middle.png\'); background-repeat:repeat-x; background-position:top;"><img src="'+IMG_DIR+'/spacer.png" height="52" width="52" /></td>';
	HTML += '<td width="25" align="right" valign="top"><img src="'+IMG_DIR+'/top_right.png" height="52" /></td>';
	HTML += '</tr>';
	HTML += '</table>';
	HTML += '</td>';
	HTML += '</tr>';
	HTML += '<tr>';
	HTML += '<td>';
	HTML += '<table width="100%" border="0" cellpadding="0" cellspacing="0">';
	HTML += '<tr>';
	HTML += '<td width="25" style="background-image:url('+IMG_DIR+'/middle_left.png); background-repeat:repeat-y; background-position:left;"><img src="'+IMG_DIR+'/spacer.png" alt="" width="25" height="25" /></td>';
	HTML += '<td bgcolor="#FFFFFF">'+INNERHTML+'</td>';			
	HTML += '<td width="25" style="background-image:url(\''+IMG_DIR+'/middle_right.png\'); background-repeat:repeat-y; background-position:right;"><img src="'+IMG_DIR+'/spacer.png" alt="" width="25" height="25" /></td>';
	HTML += '</tr>';
	HTML += '</table>';
	HTML += '</td>';
	HTML += '</tr>';
	HTML += '<tr>';
	HTML += '<td>';
	HTML += '<table width="100%" border="0" cellpadding="0" cellspacing="0">';
	HTML += '<tr>';
	HTML += '<td width="25" align="left" valign="bottom"><img src="'+IMG_DIR+'/bottom_left.png" alt="" width="25" height="25" /></td>';
	HTML += '<td style="background-image:url('+IMG_DIR+'/bottom_middle.png); background-repeat:repeat-x; background-position:bottom;"><img src="'+IMG_DIR+'/spacer.png" height="25" width="25" /></td>';
	HTML += '<td width="25" align="right" valign="bottom"><img src="'+IMG_DIR+'/bottom_right.png" alt="" width="25" height="25" /></td>';
	HTML += '</tr>';
	HTML += '</table>';
	HTML += '</td></tr>';
	HTML += '</table>';
	HTML += '</div>';
	
	if(TITLE){
		HTML += '<div id="MODAL_TITLE" align="left" style="position:fixed;height:18px;width:200px;overflow:hidden;white-space:nowrap;left:0px;top:0px;z-index:9999999;"><span style="color:#FFF; font-weight:600; text-shadow:#000 0px 0px 4px; font-face:Helvetica,Arial; font-size:12px;">'+TITLE+'</span></div>';
	}
	
	HTML += '<div id="MODAL_CLOSE" align="left" style="position:fixed; left:0px; top:0px; z-index:9999999;"><a href="#none" title="Close Window"><img src="'+IMG_DIR+'/close.png" border="0" onClick="hideModal();" onMouseOver="this.src=\''+IMG_DIR+'/close_on.png\';" onMouseOut="this.src=\''+IMG_DIR+'/close.png\';"></div>';
	
	
	var DIV = document.createElement("div");
	DIV.innerHTML = HTML;
	DIV.setAttribute('id','MODAL');
	document.body.appendChild(DIV);
	
	/* calculate window width and height */
	if(parseInt(navigator.appVersion)>3){
		if(window.innerHeight){
			ww = window.innerWidth;
			wh = window.innerHeight;
		}else{
			var ww = document.documentElement.clientWidth;
			var wh = document.documentElement.clientHeight;
		}
	}
	
	/* resize the MODAL_C1 div to fit the window */	
	obj('MODAL_C1').style.width = ww+'px';
	obj('MODAL_C1').style.height = wh+'px';
	
	/* calculate the size of the MODAL_C2 div */
	mw = obj('MODAL_C2').clientWidth;
	mh = obj('MODAL_C2').clientHeight;
	
	/* positon the MODAL_C2 div */
	if(wh>mh){
		obj('MODAL_C2').style.top = ((wh-mh)/2)+'px';
	}else{
		obj('MODAL_C2').style.top = '75px';
	}
	if(ww>mw){
		obj('MODAL_C2').style.left = ((ww-mw)/2)+'px';
	}else{
		obj('MODAL_C2').style.left = '50px';
	}
	
	/* position the MODAL_CLOSE div */
	obj('MODAL_CLOSE').style.left = (Number(obj('MODAL_C2').style.left.replace(/[^0-9.]/g,''))+mw-71)+'px';	
	obj('MODAL_CLOSE').style.top = 	(Number(obj('MODAL_C2').style.top.replace(/[^0-9.]/g,''))+16)+'px';

	/* position the MODAL_TITLE div */
	if(TITLE){
		obj('MODAL_TITLE').style.left = (Number(obj('MODAL_C2').style.left.replace(/[^0-9.]/g,''))+27)+'px';	
		obj('MODAL_TITLE').style.top = 	(Number(obj('MODAL_C2').style.top.replace(/[^0-9.]/g,''))+27)+'px';
		obj('MODAL_TITLE').style.width = (mw-124)+'px';
	} 
}

function hideModal(){
	document.body.removeChild(obj('MODAL'));
}
























function shrinkOut(ID,speed){
	var obj = document.getElementById(ID);
	if(obj){
		var w = obj.width;
		var h = obj.height;
		
		var i = 0;
		var offset = 0;
		while(i<50){
			var nw = Number(w-(w/100)*(i*2));
			var nh = Number(h-(h/100)*(i*2));
			try{
				setTimeout("document.getElementById('"+ID+"').style.width='"+nw+"px';",offset);
				setTimeout("document.getElementById('"+ID+"').style.height='"+nh+"px';",offset);
			}catch(e){}
			offset += ((speed*1000)/50);
			i++;
		}
		setTimeout("document.getElementById('"+ID+"').style.display='none';",(speed*1000));
	}
}


function blackOut(MESSAGE){
	/* Displays a 'Please Wait' while the URL loads.. */
	var DIV = document.createElement("div");

	/* calculate window width and height */
	if(parseInt(navigator.appVersion)>3){
		if(window.innerHeight){
			ww = window.innerWidth;
			wh = window.innerHeight;
		}else{
			var ww = document.documentElement.clientWidth;
			var wh = document.documentElement.clientHeight;
		}
	}
	
	voffset = (wh/2)-30;

	DIV.innerHTML = "<div style=\"position:fixed; left:0px; top:0px; width:100%; height:100%; background-image:url('https://www.telestial.com/images/fade_85.png'); line-height:1.6; padding-top:"+voffset+"px;\"><table align=\"center\" cellspacing=\"0\" cellpadding=\"0\"><tr><td align=\"center\" valign=\"middle\" style=\"font-size:21px; font-weight:bold; color:#FFFFFF;\">"+MESSAGE+"</td></tr></table></div>";
	DIV.setAttribute('id','C1');
	document.body.appendChild(DIV);
}


