
/* name to index 
hosting, email, contenthelp, content, seo1, seo2, seo3, merchant, imagecreate, imageedit, logo, flash, blog, chat, printables */
var prices  = new Array(60, 24, 99, 599, 299, 899, 1999, 1299, 39, 29, 69, 199, 499, 399, 299);
var numberofpages = new Array(4, 5, 25, 50, 150);
var hostArr = new Array(0, 0, 1, 1, 1);   //included or not
var imageArr = new Array(0, 0, 5, 10, 20); //# image created allowed 
var photoArr = new Array(0, 0, 7, 15, 30); //# photo edition allowed
var logoArr = new Array(0, 1, 3, 6, 10); //
var flashArr = new Array(0, 0, 1, 2, 4); //is flash included? how many?
var merchantArr = new Array(0, 0, 0, 0, 1);
var helpArr = new Array(0, 0, 0, 1, 1);
var blogArr = new Array(0, 0, 1, 1, 1);
var chatArr = new Array(0, 0, 0, 1, 1);
var printArr = new Array(0, 0, 0, 0, 1);
var basic = new Array(199, 499, 2499, 4999, 7999);


var hosting = 0;
var email = 1;
var contenthelp = 2;
var content = 3;
var seo1 = 4;
var seo2 = 5;
var seo3 = 6;
var merchant = 7;
var image = 8;
var photo = 9;
var logo = 10;
var flash = 11;
var blog = 12;
var chat = 13;
var printables = 14;
var oldType = 1;
var type = 0;
function inicial(t){
	var mhost = document.pricerFm.hostr;
	var nemail = document.pricerFm.emailr;
	//var nhelp = document.pricerFm.helpr;
	var nmerchant = document.pricerFm.merchantr;
	var ncreation = document.pricerFm.creationr;
	var nlogo= document.pricerFm.logor;
	var nflash= document.pricerFm.flashr;
	var nblog= document.pricerFm.blogr;
	//var nchat= document.pricerFm.chatr;
	//var nprint = document.pricerFm.printr;
	if(hostArr[t] != 0){//hosting and email included
		mhost[0].checked = true; 
		mhost[0].disabled=true;
		mhost[1].disabled=true;
		
		nemail[0].checked =true; 
		nemail[0].disabled=true;
		nemail[1].disabled=true;
		
	}
	else{// restore values
		mhost[1].checked = true;
		mhost[0].disabled = false;
		mhost[1].disabled = false;
		
		nemail[1].checked = true; 
		nemail[0].disabled=false;
		nemail[1].disabled=false;
	}
	
	if(helpArr[t] != 0){//content help and chat included 
		//nhelp[0].checked = true; 
		//nhelp[0].disabled=true;
		//nhelp[1].disabled=true;
		
		//nchat[0].checked = true; 
		//nchat[0].disabled=true;
		//nchat[1].disabled=true;
	}
	else{// restore values
		//nhelp[1].checked = true;
		//nhelp[0].disabled = false;
		//nhelp[1].disabled = false;
		
		//nchat[1].checked = true;
		//nchat[0].disabled = false;
		//nchat[1].disabled = false;
		
	}
	if(merchantArr[t] != 0){//content creation, merchant and printables included
		nmerchant[0].checked = true; 
		nmerchant[0].disabled=true;
		nmerchant[1].disabled=true;
		
		ncreation[0].checked = true; 
		ncreation[0].disabled=true;
		ncreation[1].disabled=true;
		
		//nprint[0].checked = true; 
		//nprint[0].disabled=true;
		//nprint[1].disabled=true;
	}
	else{// restore values
		nmerchant[1].checked = true;
		nmerchant[0].disabled = false;
		nmerchant[1].disabled = false;
		
		ncreation[1].checked = true; 
		ncreation[0].disabled=false;
		ncreation[1].disabled=false;
		
		//nprint[1].checked = true; 
		//nprint[0].disabled=false;
		//nprint[1].disabled=false;
	}
	
	if(logoArr[t] != 0){//logo included 
		nlogo[0].checked = true; 
		nlogo[0].disabled=true;
		nlogo[1].disabled=true;
	}
	else{// restore values
		nlogo[1].checked = true;
		nlogo[0].disabled = false;
		nlogo[1].disabled = false;
	}
	
	if(flashArr[t] != 0){// flash and blog included
		nflash[0].checked = true; 
		nflash[0].disabled=true;
		nflash[1].disabled=true;
		nblog[0].checked = true; 
		nblog[0].disabled=true;
		nblog[1].disabled=true;
	}
	else{// restore values
		nflash[1].checked = true;
		nflash[0].disabled = false;
		nflash[1].disabled = false;
		
		nblog[1].checked = true;
		nblog[0].disabled = false;
		nblog[1].disabled = false;
		
	}
	
	
	//document.pricerFm.photosr.selectedIndex=photoArr[t];
	//document.pricerFm.imagesr.selectedIndex=imageArr[t];
}
function updatePrice()
{
	
	var total = 0;
	var discount = 0;
	
	type = document.pricerFm.pages.value;
	
	if (type != "")
	{
		total = basic[type];
		var mseo = document.pricerFm.seor.value;
		if(mseo != 0){
		total = total + prices[mseo];
		}
		
		/*var mimages = document.pricerFm.imagesr.value;
		if(mimages != 0 && mimages > imageArr[type]){
			total = total + ((mimages - imageArr[type])* prices[image]);
		}
		
		var mphotos = document.pricerFm.photosr.value; 
		if(mphotos != 0 && mphotos > photoArr[type]){
			total = total + ((mphotos - photoArr[type])* prices[photo]);
		}*/
		
		var mhost = document.pricerFm.hostr;
		if(mhost[0].checked == true && hostArr[type]==0){
			total = total + prices[hosting];
		}
		
		var memail = document.pricerFm.emailr;
		if(memail[0].checked == true && hostArr[type]==0){
			total = total + prices[email];
			}
		
		/*var mhelp = document.pricerFm.helpr;
		if(mhelp[0].checked== true && helpArr[type]==0)
			total = total + prices[contenthelp];*/
			
		var mcreation = document.pricerFm.creationr;
		if((mcreation[0].checked) == true && hostArr[type]==0){
			total = total + prices[content];
			}
			
		var mmechant = document.pricerFm.merchantr;
		if((mmechant[0].checked== true) && merchantArr[type]==0){
			total = total + prices[merchant];
		}
		
		var mlogo = document.pricerFm.logor; 
		if(mlogo[0].checked== true && logoArr[type]==0)
			total = total + prices[logo];
			
		var mflash = document.pricerFm.flashr;
		if(mflash[0].checked== true && flashArr[type]==0)
			total = total + prices[flash];
			
		var mblog = document.pricerFm.blogr
		if(mblog[0].checked== true && blogArr[type]==0)
			total = total + prices[blog];
			
		/*var mchat = document.pricerFm.chatr
		if(mchat[0].checked== true && chatArr[type]==0)
			total = total + prices[chat];
			
		var mprint = document.pricerFm.printr
		if(mprint[0].checked== true && printArr[type]==0)
			total = total + prices[printables];*/
		
		if(oldType != type){
		oldType = type;
		inicial(type);
		}
	//given discounts according to the total 
		if(total > 2000 && total < 3001)
			discount = 250;
		else if(total > 3000 && total < 4001)
			discount = 500;
		else if(total > 4000 && total < 6001)
			discount = 700;
		else if(total > 6000 && total < 8001)
			discount = 900;
		else if(total > 8000)
			discount = 1200;
			

		document.getElementById('show_discount').innerHTML = discount+'.00';
		
		document.getElementById('show_total').innerHTML = total+'.00';
	}
	else{
				
	 document.getElementById('show_total').innerHTML = 'please choose number of pages';
	 }
}
