// JavaScript Document
function postcomments(idarray,replybox){
	var url = "post_data.php";
	
	var params = "";
	
	http = GetXmlHttpObject();
	
	
	for (i=0;i<idarray.length;i++){
		idname = document.getElementById(idarray[i]).name;
		idvalue = document.getElementById(idarray[i]).value;
		params += idname + '=' + idvalue + '&';
	}
	params = params.substr(0,params.length-1);
	
	http.open("POST", url, true);
	
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	
	http.onreadystatechange = function() {//Call a function when the state changes.
		if(http.readyState == 4 && http.status == 200) {
			//alert(http.responseText);
			document.getElementById(replybox).innerHTML = http.responseText;
		}
	}
	http.send(params);

}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

function writetext (add,t1){
	var first = 'ma';
	var second = 'il';
	var third = 'to:';
	
	var d1 = 'web500'; 
	var d2 = '';
	var ext = 'co.za'; 
	document.write('<a href="');
	document.write(first+second+third);
	document.write(add);
	document.write('&#64;');
	document.write(d1+d2);
	document.write('.');
	document.write(ext); 
	document.write('">'); 
	document.write(t1+'&#64;'+d1+'.'+ext+'</a>');
}

function showhide(show,hide){
	showid = document.getElementById(show);
	hideid = document.getElementById(hide);
	if (show.length > 0 ) {
		showid.setAttribute("class", "showit");
		showid.setAttribute("className", "showit");
	}
	if (hide.length > 0 ){
		hideid.setAttribute("class", "hideit");
		hideid.setAttribute("className", "hideit");
	}
	//alert("Yup");
	return true;
}

function quote(){
	var pricem = 0; //monthly cost
	var pricey = 0; // yearly cost
	var price = 0; // once-off cost
	var pppage = 250;
	if (document.getElementById('domainy').checked) {	
		var domain = 1;	
	} else {
		var domain = 0;
	}
	if (domain == 0) {
		var ext = document.getElementById('tld').value;
		if (ext == 228){
			price += ext;
		} else {
			price += ext;
			pricey += ext;
		}
	}
	if (document.getElementById('hostingy').checked) {	
		var hosting = 1;	
	} else {
		var hosting = 0;
	}
//	var hosting = document.getElementById('hosting').value;
	if (hosting == 0){
		var hostingoption = document.getElementById('plan').value;
		
		if (document.getElementById('periody').checked) {	
			var advance = 1;	
		} else {
			var advance = 0;
		}
		alert(advance);
//		var advance = document.getElementById('period').value;
		if (advance == 1){
			if (hostingoption = 'Mini'){ pricey += 220;}
			if (hostingoption = 'MiniPro'){ pricey += 530;}
			if (hostingoption = 'Basic'){ pricey += 1260;}
			if (hostingoption = 'BasicPro'){ pricey += 1840;}
			if (hostingoption = 'Master'){ pricey += 3470;}
			if (hostingoption = 'MasterPro'){ pricey += 5550;}
		} else {
			if (hostingoption = 'Mini'){ pricem += 21;}
			if (hostingoption = 'MiniPro'){ pricem += 50;}
			if (hostingoption = 'Basic'){ pricem += 120;}
			if (hostingoption = 'BasicPro'){ pricem += 175;}
			if (hostingoption = 'Master'){ pricem += 330;}
			if (hostingoption = 'MasterPro'){ pricem += 530;}
		}
	}
	//alert(price+"\r\n"+pricem+"\r\n"+pricey);
	var pages = document.getElementById('pages').value;
	if (pages == 'more') {
		pages = document.getElementById('morepages').value;
	}
	price += pppage*(pages-1);
	//alert(price+"\r\n"+pricem+"\r\n"+pricey);
	if (document.getElementById('animationy').checked) {	
		var animation = 1;	
	} else {
		var animation = 0;
	}
//	var animation = document.getElementById('animation').value;
//	alert(animation);
	if (animation == '1'){
		price += 4000;
	} else {
		price += 1500;
	}
	//alert(domain+'-'+ext+'-'+hosting+'-'+advance+'-'+pages+'-'+animation);
	document.getElementById('price').value = price;
	document.getElementById('pricem').value = pricem;
	document.getElementById('pricey').value = pricey;
	//alert("Once-off Charge: R"+price+".00\r\n"+'Monthly Charge: R'+pricem+".00\r\n"+'Yearly Charge: R'+pricey+'.00');
	
}
