// stripes

function striper(parentElementTag, parentElementClass, childElementTag, styleClasses)
{
	var i=0,currentParent,currentChild;
	if ((document.getElementsByTagName)&&(parentElementTag)&&(childElementTag)&&(styleClasses)) {
		var styles = styleClasses.split(',');
		var parentItems = document.getElementsByTagName(parentElementTag);
		while (currentParent = parentItems[i++]) {
			if ((parentElementClass == null)||(currentParent.className == parentElementClass)) {
				var j=0,k=0;
				var childItems = currentParent.getElementsByTagName(childElementTag);
				while (currentChild = childItems[j++]) {
					k = (j+(styles.length-1)) % styles.length;
					currentChild.className = currentChild.className+" "+styles[k];
				}
			}
		}
	}
}

function stripe() {
	striper('ul','striped','li','odd,even');
	striper('tbody','striped','tr','odd,even');
}

// popups

function preparePopUps() {
	if (!document.getElementsByTagName) return false;
	var lnks = document.getElementsByTagName("a");
	for (var i=0; i<lnks.length; i++) {
		if (lnks[i].className.indexOf("popup") == -1) continue;
		lnks[i].onclick = function() {
			window.open(this.href);
			return false;
		}
		lnks[i].onkeypress = lnks[i].onclick;
	}
}

// Div Collapse

function divCollapse()
{
	var strID, objHelp;
	
	if (document.getElementById && document.appendChild && document.removeChild)
	{
		var objDiv = document.getElementById('app');
		
		if (objDiv) {
		var objAnchors = objDiv.getElementsByTagName('a');
		for (var iCounter=0; iCounter<objAnchors.length; iCounter++)
		{
			//if (objAnchors[iCounter].className != 'leave')
			if (objAnchors[iCounter].className == 'collapse')
			{
				strID = getIDFromHref(objAnchors[iCounter].href);
				objHelp = document.getElementById(strID);
				objHelp.style.display = 'none';
				
		
				objAnchors[iCounter].onclick = function(event){return expandHelp(this, event);}
				objAnchors[iCounter].onkeypress = function(event){return expandHelp(this, event);}
		
				//objAnchors[iCounter].parentNode.appendChild(objHelp);
			}
		}
		
		//var objOldnode = document.getElementByID('objHelp');
		
		//objOldnode.parentNode.removeChild(objOldnode);
		
		// Release memory to prevent IE memory leak
		// Thanks to Mark Wubben <http://novemberborn.net/>
		// for highlightint the issue</span>
		
		objDiv = null;
		objHelp = null;
		objAnchors = null;
		}
	}
}

function getIDFromHref(strHref)
{
	var iOffset = strHref.indexOf('#') + 1;
	var iEnd = strHref.length;

	return strHref.substring(iOffset, iEnd);
}

function expandHelp(objAnchor, objEvent)
{
	var iKeyCode;

	if (objEvent && objEvent.type == 'keypress')
	{
		if (objEvent.keyCode)
			iKeyCode = objEvent.keyCode;
		else if (objEvent.which)
			iKeyCode = objEvent.which;
		
		if (iKeyCode != 13 && iKeyCode != 32)
			return true;
	}

	strID = getIDFromHref(objAnchor.href);
	objHelp = document.getElementById(strID);

	if (objHelp.style.display == 'none')
		objHelp.style.display = 'block';
	else
		objHelp.style.display = 'none';
	
	return false;
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(stripe);
addLoadEvent(preparePopUps);
addLoadEvent(divCollapse);

// Ultimate Fade-In Slideshow (v1.5): © Dynamic Drive (http://www.dynamicdrive.com)
// This notice MUST stay intact for legal use
// Visit http://www.dynamicdrive.com/ for this script and 100s more.
 
var fadebgcolor="white"
 
////NO need to edit beyond here/////////////
 
var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
 
var dom=(document.getElementById) //modern dom browsers
var iebrowser=document.all
 
function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
	this.pausecheck=pause
	this.mouseovercheck=0
	this.delay=delay
	this.degree=10 //initial opacity degree (10%)
	this.curimageindex=0
	this.nextimageindex=1
	fadearray[fadearray.length]=this
	this.slideshowid=fadearray.length-1
	this.canvasbase="canvas"+this.slideshowid
	this.curcanvas=this.canvasbase+"_0"
	if (typeof displayorder!="undefined")
		theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
	this.theimages=theimages
	this.imageborder=parseInt(borderwidth)
	this.postimages=new Array() //preload images
	for (p=0;p<theimages.length;p++){
		this.postimages[p]=new Image()
		this.postimages[p].src=theimages[p][0]
	}
 
	var fadewidth=fadewidth+this.imageborder*2
	var fadeheight=fadeheight+this.imageborder*2
 
	if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
		document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;-khtml-opacity:10;opacity:10;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);-moz-opacity:10;-khtml-opacity:10;opacity:10;background-color:'+fadebgcolor+'"></div></div>')
	else
		document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')
 
	if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
		this.startit()
	else{
		this.curimageindex++
		setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
	}
}

function fadepic(obj){
	if (obj.degree<100){
		obj.degree+=10
		if (obj.tempobj.filters&&obj.tempobj.filters[0]){
			if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
				obj.tempobj.filters[0].opacity=obj.degree
			else //else if IE5.5-
				obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
		}
		else if (obj.tempobj.style.MozOpacity)
			obj.tempobj.style.MozOpacity=obj.degree/101
		else if (obj.tempobj.style.KhtmlOpacity)
			obj.tempobj.style.KhtmlOpacity=obj.degree/100
		else if (obj.tempobj.style.opacity)
			obj.tempobj.style.opacity=obj.degree/100
	}
	else {
		clearInterval(fadeclear[obj.slideshowid])
		obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
		obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
		obj.populateslide(obj.tempobj, obj.nextimageindex)
		obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
		setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
	}
}
 
fadeshow.prototype.populateslide=function(picobj, picindex){
	var slideHTML=""
	if (this.theimages[picindex][1]!="") //if associated link exists for image
		slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
	slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
	if (this.theimages[picindex][1]!="") //if associated link exists for image
		slideHTML+='</a>'
	picobj.innerHTML=slideHTML
}
 
 
fadeshow.prototype.rotateimage=function(){
	if (this.pausecheck==1) //if pause onMouseover enabled, cache object
		var cacheobj=this
	if (this.mouseovercheck==1)
		setTimeout(function(){cacheobj.rotateimage()}, 100)
	else if (iebrowser&&dom||dom){
		this.resetit()
		var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
		crossobj.style.zIndex++
		fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
		this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
	}
	else{
		var ns4imgobj=document.images['defaultslide'+this.slideshowid]
		ns4imgobj.src=this.postimages[this.curimageindex].src
	}
	this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
}
 
fadeshow.prototype.resetit=function(){
	this.degree=10
	var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
	if (crossobj.filters&&crossobj.filters[0]){
		if (typeof crossobj.filters[0].opacity=="number") //if IE6+
			crossobj.filters(0).opacity=this.degree
		else //else if IE5.5-
			crossobj.style.filter="alpha(opacity="+this.degree+")"
	}
	else if (crossobj.style.MozOpacity)
		crossobj.style.MozOpacity=this.degree/101
	else if (crossobj.style.KhtmlOpacity)
		crossobj.style.KhtmlOpacity=this.degree/100
	else if (crossobj.style.opacity)
		crossobj.style.opacity=this.degree/101
}
 
 
fadeshow.prototype.startit=function(){
	var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
	this.populateslide(crossobj, this.curimageindex)
	if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
		var cacheobj=this
		var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
		crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
		crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}
	}
	this.rotateimage()
}

// calculate prices

function dollarFormat(amount) {
	string = "" + amount;
	dec = string.length - string.indexOf('.');
	if (string.indexOf('.') == -1)
		return string + '.00';
	if (dec == 1)
		return string + '00';
	if (dec == 2)
		return string + '0';
	if (dec > 3)
		return string.substring(0,string.length-dec+3);
		return string;
}

function calculate() {

	Setup = 0;
	FirstPay = 0; 
	TotalPay = 0;
	Additional = 0;
	Plan = 0;

	Sat256 = 59.95; 
	Sat512 = 89.95; 
	Sat1024 = 289.00;
	
	Sat512_500 = 29.95;
	Sat512_1000 = 49.95;
	Sat512_3000 = 149.95;
	Sat512_5000 = 219.95;
	
	Sat1024_500 = 59.95;
	Sat1024_1000 = 89.95;
	Sat1024_3000 = 189.95;
	Sat1024_5000 = 269.95;
	
	Sat2048_500 = 89.95;
	Sat2048_1000 = 199.95;
	Sat2048_3000 = 209.95;
	Sat2048_5000 = 299.95;
	
	Sky256C = 39.95;
	Sky256U = 59.95;
	Sky512U = 99.95;
	Sky1500U = 189.95;
   
	Smart256 = 29.95;
	Smart256P = 39.95;
	Smart512 = 59.95;
	Smart512V = 99.00;
	Smart512P = 169.00;
	Smart1024 = 219.00;
 

	if (document.ofrm.plan1.value == "Sat256") { Plan = Sat256; Install = 199; }
	if (document.ofrm.plan1.value == "Sat512") { Plan = Sat512; Install = 159; }
	if (document.ofrm.plan1.value == "Sat1024") { Plan = Sat1024; Install = 0; }
	
	
	if (document.ofrm.plan2.value == "Sat512_500") { Plan = Sat512_500; Install = 199; }
	if (document.ofrm.plan2.value == "Sat512_1000") { Plan = Sat512_1000; Install = 199; }
	if (document.ofrm.plan2.value == "Sat512_3000") { Plan = Sat512_3000; Install = 199; }
	if (document.ofrm.plan2.value == "Sat512_5000") { Plan = Sat512_5000; Install = 199; }
	
	if (document.ofrm.plan2.value == "Sat1024_500") { Plan = Sat1024_500; Install = 199; }
	if (document.ofrm.plan2.value == "Sat1024_1000") { Plan = Sat1024_1000; Install = 199; }
	if (document.ofrm.plan2.value == "Sat1024_3000") { Plan = Sat1024_3000; Install = 199; }
	if (document.ofrm.plan2.value == "Sat1024_5000") { Plan = Sat1024_5000; Install = 199; }
	
	if (document.ofrm.plan2.value == "Sat2048_500") { Plan = Sat2048_500; Install = 199; }
	if (document.ofrm.plan2.value == "Sat2048_1000") { Plan = Sat2048_1000; Install = 199; }
	if (document.ofrm.plan2.value == "Sat2048_3000") { Plan = Sat2048_3000; Install = 199; }
	if (document.ofrm.plan2.value == "Sat2048_5000") { Plan = Sat2048_5000; Install = 199; }
	
	if (document.ofrm.plan2.value == "Sky256C") { Plan = Sky256C; Install = 199; }
	if (document.ofrm.plan2.value == "Sky256U") { Plan = Sky256U; Install = 199; }
	if (document.ofrm.plan2.value == "Sky512U") { Plan = Sky512U; Install = 199; }
	if (document.ofrm.plan2.value == "Sky1500U") { Plan = Sky1500U; Install = 199; }
	
	if (document.ofrm.plan2.value == "Smart256") { Plan = Smart256; Install = 0; }
	if (document.ofrm.plan2.value == "Smart256P") { Plan = Smart256P; Install = 0; }
	if (document.ofrm.plan2.value == "Smart512") { Plan = Smart512; Install = 0; }
	if (document.ofrm.plan2.value == "Smart512V") { Plan = Smart512V; Install = 0; }
	if (document.ofrm.plan2.value == "Smart512P") { Plan = Smart512P; Install = 0; }
	if (document.ofrm.plan2.value == "Smart1024") { Plan = Smart1024; Install = 0; }
	
	if (document.ofrm.plan1.value == "" && document.ofrm.plan2.value == "") { Plan = 0; Install = 0; }

	FirstPay = Install + Plan;
	document.ofrm.firstpayment.value = "$"+dollarFormat(eval(FirstPay));
	
	TotalPay = Install + (Plan * 18);
	document.ofrm.totalpayment.value = "$"+dollarFormat(eval(TotalPay));
	
	if (Install == 0) {
		if (Plan != 0) {
			document.ofrm.installfee.value = "FREE";
		} else {
			document.ofrm.installfee.value = "";
		}
	} else {
		document.ofrm.installfee.value = "$"+dollarFormat(Install);
	}

}
