
function HttpRequest(method,target,argsList,echoElement,responseFunction,arguments){
	this.responseFunction=responseFunction||null;
	this.element=echoElement||null;
	this.arguments=arguments||null;
	
	this.request=null;
	try{this.request=new ActiveXObject('Msxml2.XMLHTTP');}
	catch(e){
	try {this.request=new ActiveXObject('Microsoft.XMLHTTP');}
	catch(e){
	this.request=new XMLHttpRequest();
	}}
	
	
	
	this.getResponse=function(thisInstance){
	return function(){
		if(typeof(thisInstance.responseFunction)!='function'){	
		thisInstance.element=(typeof(thisInstance.element)!='object')?document.getElementById(thisInstance.element):thisInstance.element;
	if(thisInstance.request.readyState<4){thisInstance.element.innerHTML="Зареждене...";}
	else if(thisInstance.request.readyState==4 || thisInstance.request.readyState=='complete'){	thisInstance.element.innerHTML=thisInstance.request.responseText;}
		}
		else if(typeof(thisInstance.responseFunction)=='function'){
			
			thisInstance.responseFunction(thisInstance.request,thisInstance.arguments);
		}//else
		}
	}
	
	if(method.toUpperCase()=='GET'){
		
		
		this.url=target+'?'+argsList;
		this.request.open('GET',this.url,true);
		this.request.onreadystatechange=this.getResponse(this);
	    this.request.send(null);
	}
	
	
	if(method.toUpperCase()=='POST'){
		
	this.url=target;
	this.request.open('POST',this.url,true);
	this.request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	this.request.setRequestHeader("Content-length", argsList.length);
	this.request.setRequestHeader("Connection", "close");
	this.request.onreadystatechange=this.getResponse(this);
	this.request.send(argsList);
		
	}
	

}



// JavaScript Document
//for the summary
var GLOBAL_USER_DISCOUNTS={"DOMAIN_DISCOUNT":0,"HOSTING_DISCOUNT":0,"SERVER_DISCOUNT":0};
var GLOBAL_USER_NUM_PACKETS=0;
var mouseX;
var mouseY;


var globalDiscounts={"numHostings":0,"numDomains":0,"numServers":0,"domainPrepay":0,"hostingPrepay":0,"serverPrepay":0,"numPackets":0};


function reverseJSON(object)
{
	var tmpArr=new Array();
	var tmpObj={};
	for(var obj in object)
	{
		tmpArr.push(obj);
	}
	tmpArr.reverse();
	for(var i=0;i<tmpArr.length;i++)
	{
		tmpObj["'"+tmpArr[i]+"'"]=object[tmpArr[i]];
	}
	return tmpObj;
}


function getDiscount(type,period,numPackets){
	
	var numPackets=numPackets || 0;
	var acountDiscount;
	var discount=0;
	switch(type)
	{
		case "domain":
		case "5":
			numPackets=globalNumDomains;
			var discountMatrix={
				0:{1:0,2:0,3:0,4:0,5:5,6:5,7:5,8:5,9:5,10:5},
				5:{1:5,2:5,3:5,4:5,5:9.75,6:9.75,7:9.75,8:9.75,9:9.75,10:9.75}
			};
		break;
		
		case "hosting":
		case "9":
		case "10":
		case "12":
		
			var discountMatrix={
			0:{1:-20,3:-10,6:-5,12:0,24:5,36:10,48:10,60:20},
			1:{1:-20,3:-10,6:-5,12:0,24:5,36:10,48:10,60:20},
			2:{1:-20,3:-10,6:-5,12:0,24:5,36:10,48:10,60:20},
			3:{1:-20,3:-10,6:-5,12:5,24:9.75,36:14.5,48:14.5,60:24},
			5:{1:-20,3:-10,6:-5,12:10,24:14.5,36:19,48:19,60:28},
			10:{1:-20,3:-10,6:-5,12:15,24:19.25,36:23.5,48:23.5,60:32},
			20:{1:-20,3:-10,6:-5,12:20,24:24,36:28,48:28,60:36},
			30:{1:-20,3:-10,6:-5,12:25,24:28.75,36:32.5,48:32.5,60:40},
			50:{1:-20,3:-10,6:-5,12:30,24:33.5,36:37,48:37,60:44}
			};
		break;
		
		case "server":
		case "19":
		case "20":
		case "21":
			var discountMatrix={0:{1:0,3:5,6:10,12:15}};
		break;
		
		case "VPS":
		case "13":
		case "14":
		case "15":
			var discountMatrix={0:{1:0,3:0,6:5,12:10,24:15}};
		break;
		
		default:
			var discountMatrix={
				0:{1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0}};
		
	}
	
	discountMatrix=reverseJSON(discountMatrix);
	for(var obj in discountMatrix)
	{
		obj=parseInt(obj.replace(/'/g,""));

		if(obj<=numPackets)
		{
			acountDiscount=obj;
			break;
		}
	}

	var testObj=reverseJSON(discountMatrix["'"+acountDiscount+"'"]);
	for(var obj in testObj)
	{	
		numobj=parseInt(obj.replace(/'/g,""));
	
		if(numobj<=period)
		{
			discount=testObj[obj];
			break;
		}
	}
	

	return discount;

}

	
function getGlobals(){
	new HttpRequest("post","/bg/cart/update/",argList,null,function(request){
		if(request.readyState==1){}
		if(request.readyState==4){
			eval(request.responseText);
		
		   }																  
					  });
}


// SHOPPING CART FUNCTIONS






function showCartEditBox(prodNum,element){
	//var orderContainer=document.getElementById('');
	document.getElementById('infobox'+prodNum).style.display='block';
	document.getElementById('closebtn'+prodNum).style.display='block';
	element.style.backgroundPosition="center bottom";
	
}

function hideCartEditBox(prodNum,element){
	document.getElementById('infobox'+prodNum).style.display='none';
	element.style.display='none';
	document.getElementById('changebtn'+prodNum).style.backgroundPosition="center top";
}

function displayCart(){
	
	var smallCartContainer=document.getElementById('shoppingcartdiv');
	var smallCart=document.getElementById('inner_shoppingcartdiv');
	var argList="";
	new HttpRequest("post","/bg/cart/display/",argList,null,function(request){
		if(request.readyState==1){
			if(document.getElementById('inner_shoppingcartcontainer'))document.getElementById('inner_shoppingcartcontainer').innerHTML="<img src='/images/loadingbig/loading.gif' />";
			}
		if(request.readyState==4){
		   if(document.getElementById('inner_shoppingcartcontainer'))document.getElementById('inner_shoppingcartcontainer').innerHTML=request.responseText;
		   smallCart.innerHTML=request.responseText;
		   
		   var As=smallCart.getElementsByTagName('a');
		   for(var i=0;i<As.length;i++){
			   if(As[i].className=='left button-change') As[i].style.display='none';
		   }
		    var smallCartDivs=smallCart.getElementsByTagName('div');
		   for(var i=0;i<smallCartDivs.length;i++){
			   smallCartDivs[i].style.width="";
		   }
		   }
																			   
																			   
																			   });
}

function showSmallCart(){
	if(!document.getElementById('inner_shoppingcartcontainer'))displayCart();
	var smallCartContainer=document.getElementById('shoppingcartdiv');
	var smallCart=document.getElementById('inner_shoppingcartdiv');
	var btn=document.getElementById('cart-button');
	if(smallCartContainer.className=='shopping-cart-container hide'){
	   smallCartContainer.className=smallCartContainer.className.replace(/ hide/g,"");
	   smallCartContainer.style.zIndex='1000';
	   btn.className='relative shopping-cart-on pointer';
	}
	else{
	smallCartContainer.className='shopping-cart-container hide'	
	btn.className='relative shopping-cart pointer';
	}
}
	
	
function hideSmallCart(){
	
	var smallCartContainer=document.getElementById('shoppingcartdiv');
	var btn=document.getElementById('cart-button');

	if(smallCartContainer.className.search(/shopping-cart-container$/)!=-1){
	smallCartContainer.className='shopping-cart-container hide'	
	btn.className='relative shopping-cart pointer';

	}
}


function saveToCart(redirect){
	var orderContainer=document.getElementById('inner_shoppingcartcontainer');
	var hasBG=false;
	//var addToCart=document.getElementById('orderaddtocard').value;
	var newDomain;
	for(var i=1;i<=2;i++){
		if(document.getElementById('checkbox-domain-tab'+i) && document.getElementById('checkbox-domain-tab'+i).checked){
			newDomain=document.getElementById('checkbox-domain-tab'+i).value;
		}
	}
	
	var hasDomain=document.getElementById('hasadomaininp').value;
	var sendDomain=new Array();
	var domainPeriods=new Array();
	var tlds=getTLDs();
	for(var i=0;i<tlds.length;i++)
	{
		if(document.getElementById('check_'+tlds[i]) && document.getElementById('check_'+tlds[i]).checked )
		{
			sendDomain.push(document.getElementById('check_'+tlds[i]).value);
			domainPeriods.push(document.getElementById('domperiodsel'+tlds[i]).value);
			if(tlds[i]=="bg")
				hasBG=true;
		}
	}
	var hostingPlan;
	for(var i=0;i<=4;i++){
		if(document.getElementById('hosting'+i) && document.getElementById('hosting'+i).checked){
			hostingPlan=document.getElementById('hosting'+i).value;
		}
	}
	var serverPlan
	for(var i=1;i<=3;i++){
		if(document.getElementById('server'+i) && document.getElementById('server'+i).checked){
			serverPlan=document.getElementById('server'+i).value;
		}
	}
	
	var vpsPlan
	for(var i=1;i<=3;i++){
		if(document.getElementById('vps'+i) && document.getElementById('vps'+i).checked){
			vpsPlan=document.getElementById('vps'+i).value;
		}
	}



	var hostingPeriod=(document.getElementById('hostperiod'+hostingPlan))?document.getElementById('hostperiod'+hostingPlan).value:0;
	var serverPeriod=(document.getElementById('serverperiod'+serverPlan))?document.getElementById('serverperiod'+serverPlan).value:0;
	var vpsPeriod=(document.getElementById('vpsperiod'+vpsPlan))?document.getElementById('vpsperiod'+vpsPlan).value:0;
	var useHosting;
	for(i=1;i<=3;i++){
		if(document.getElementById('checkbox-hosting-tab'+i) && document.getElementById('checkbox-hosting-tab'+i).checked){
			useHosting=document.getElementById('checkbox-hosting-tab'+i).value;
		}
	}
	
	
	var argList='hasdomain='+hasDomain+'&newdomain='+newDomain+'&send_domain='+sendDomain+'&domperiod='+domainPeriods+'&usehosting='+useHosting+'&hosting='+hostingPlan+'&hostperiod='+hostingPeriod+'&server='+serverPlan+'&serverperiod='+serverPeriod+'&vps='+vpsPlan+'&vpsperiod='+vpsPeriod;
	//alert(argList);
	
	if(hasBG)
	{
		var valid=true;
		var with_reason=(document.getElementById('bg_checkbox-domain-tab1').checked)?0:1;
		var identity_doc=document.getElementById('bg_docs_1').value;
		var reason_doc=document.getElementById('bg_docs_2').value;
		argList+="&bg_with_reason="+with_reason+"&bg_identity_doc="+identity_doc+"&bg_reason_doc="+reason_doc;
		
		if(!document.getElementById('bg_terms').checked)
		{
			document.getElementById('bg_terms').parentNode.style.color='red';
			valid=false;
		}
		if(!document.getElementById('bg_grant').checked)
		{
			document.getElementById('bg_grant').parentNode.style.color='red';
			valid=false;
		}
		if(!valid) return;
	}	
	
	
	
	new HttpRequest("post","/bg/cart/save/",argList,null,function(request){
		if(request.readyState==1){orderContainer.innerHTML="<center><img src='/images/loadingbig/loading.gif' /><center>";}
		if(request.readyState==4){
			if(redirect==1)window.location="/bg/order/step2";
			else{
			orderContainer.innerHTML=request.responseText;
			displayCart();
			getCartCount();
			updateTabs();
			document.getElementById('checkdom1').innerHTML='';
			document.getElementById('hosting4').click();
			}
		}
															 });
	
	
}


function validateOrderForm(callerId){
	var hasDomainInp=document.getElementById('hasadomaininp').value;
	var useHosting;
	var sendDomain=new Array();
	var tlds=getTLDs();
	for(var i=0;i<tlds.length;i++){
		if(document.getElementById('check_'+tlds[i]) && document.getElementById('check_'+tlds[i]).checked ){
			sendDomain.push(document.getElementById('check_'+tlds[i]).value);
		}
	}
	for(i=1;i<=3;i++){
		if(document.getElementById('checkbox-hosting-tab'+i) && document.getElementById('checkbox-hosting-tab'+i).checked){
			useHosting=document.getElementById('checkbox-hosting-tab'+i).value;
		}
	}
	
	
if(callerId=='savetocartlink'){
	if(sendDomain.length>0)saveToCart(0);
	else if(hasDomainInp!="")
	{
		var pattern=/^[a-z0-9_\-]+\.[a-z]{2,4}/;
		if(!pattern.test(hasDomainInp))
			return
		else saveToCart(0);
	}
	else alert("Трябва да изберете домейн име(на) за продължение!");
}
if(callerId=='saveorderlink'){
	if(sendDomain.length>0)saveToCart(1);
	else if(hasDomainInp!="")
	{
		var pattern=/^[a-z0-9_\-]+\.[a-z]{2,4}/;
		if(!pattern.test(hasDomainInp))
			return
		else saveToCart(1);
	}
	else alert("Трябва да изберете домейн име(на) за продължение!");
}
	
}

function planOnChange(element,prodNum){
	document.getElementById('plan'+prodNum).value=element.value;
	var prodContainer=document.getElementById('mycart_itemdiv'+prodNum);
	var spans=prodContainer.getElementsByTagName('span');
	for(var i=0;i<spans.length;i++){
		if(spans[i].className=='checked') spans[i].style.display='none';
	}
	//element.parentNode.firstChild.style.display=='block';
	
	updateCart(prodNum);
}

function periodOnChange(element,prodNum){
	var elementId=element.id.split("_");
	var check_id="mycartplan"+elementId[3]+"-"+elementId[2];

	document.getElementById('period'+prodNum).value=element.value;
	updateCart(prodNum);
	
}
	
	
	
	






function updateCart(prodNum){
	var orderContainer=document.getElementById('inner_shoppingcartcontainer');
	var smallCartContainer=document.getElementById('shoppingcartdiv');
	var smallCart=document.getElementById('inner_shoppingcartdiv');
	
	var prodContainer=document.getElementById('mycart_itemdiv'+prodNum);
	var rowId=document.getElementById('orderid'+prodNum).value;
	var plan=document.getElementById('plan'+prodNum).value;
	var period=document.getElementById('period'+prodNum).value;
	var price=document.getElementById('price'+prodNum).value;
	var discount_price=document.getElementById('discount_price'+prodNum).value;
	var discount_percent=document.getElementById('discount_percent'+prodNum).value;
	var exists=document.getElementById('exists'+prodNum).value;
	var options=document.getElementById('options'+prodNum).value;
	
	var argList="rowId="+rowId+"&plan="+plan+"&period="+period+"&price="+price+"&discount_price="+discount_price+"&discount_percent="+discount_percent+"&exists="+exists+"&options="+options;
	new HttpRequest("post","/bg/cart/update/",argList,null,function(request){
		if(request.readyState==1){
			orderContainer.innerHTML="<center><img src='/images/loadingbig/loading.gif' /></center>";
			//document.body.style.cursor='wait';
			document.getElementById('mycartdoorderbtn').style.display='none';
			}
		if(request.readyState==4){
			getCartCount();
		   orderContainer.innerHTML=request.responseText;
		   smallCart.innerHTML=request.responseText;
		   
		   var As=smallCart.getElementsByTagName('a');
		   
		   for(var i=0;i<As.length;i++){
			   if(As[i].className=='left button-change') As[i].style.display='none';
		   }
		   
		   
		   	//document.body.style.cursor='';
			document.getElementById('mycartdoorderbtn').style.display='block';
				if(document.getElementById('domain-tab1') && document.getElementById('domain-tab2') && document.getElementById('domain-tab3')){
					updateTabs();																									   
				}
		   }																  

																			  
																			  });
}





function generateOrderSummary(){

	var domainPrices=new Array();
	domainPrices['price']=new Array();
	domainPrices['discount_price']=new Array();
	var hostingPrices;
	var hostingDiscountPrices;
	var serverPrices;
	var serverDiscountPrices;
	var vpsPrices;
	var vpsDiscountPrices;
	var sumPrice;
	var sumDiscountPrice;
	
	var newDomain;
	for(var i=1;i<=2;i++){
		if(document.getElementById('checkbox-domain-tab'+i) && document.getElementById('checkbox-domain-tab'+i).checked){
			newDomain=document.getElementById('checkbox-domain-tab'+i).value;
		}
	}
	
	var hasDomain=document.getElementById('hasadomaininp').value;
	var sendDomain=new Array();
	var domainPeriods=new Array();
	var tlds=getTLDs();
	for(var i=0;i<tlds.length;i++){
		if(document.getElementById('check_'+tlds[i]) && document.getElementById('check_'+tlds[i]).checked ){
			sendDomain.push(document.getElementById('check_'+tlds[i]).value);
			domainPeriods.push(document.getElementById('domperiodsel'+tlds[i]).value);
		}
	}
	var hostingPlan;
	for(var i=0;i<=4;i++){
		if(document.getElementById('hosting'+i) && document.getElementById('hosting'+i).checked){
			hostingPlan=document.getElementById('hosting'+i).value;
		}
	}
	var serverPlan
	for(var i=1;i<=3;i++){
		if(document.getElementById('server'+i) && document.getElementById('server'+i).checked){
			serverPlan=document.getElementById('server'+i).value;
		}
	}
	var vpsPlan
	for(var i=1;i<=3;i++){
		if(document.getElementById('vps'+i) && document.getElementById('vps'+i).checked){
			vpsPlan=document.getElementById('vps'+i).value;
		}
	}

	var hostingPeriod=(document.getElementById('hostperiod'+hostingPlan))?document.getElementById('hostperiod'+hostingPlan).value:0;
	var serverPeriod=(document.getElementById('serverperiod'+serverPlan))?document.getElementById('serverperiod'+serverPlan).value:0;
	var vpsPeriod=(document.getElementById('vpsperiod'+vpsPlan))?document.getElementById('vpsperiod'+vpsPlan).value:0;
	var useHosting;
	for(i=1;i<=3;i++){
		if(document.getElementById('checkbox-hosting-tab'+i) && document.getElementById('checkbox-hosting-tab'+i).checked){
			useHosting=document.getElementById('checkbox-hosting-tab'+i).value;
		}
	}
	
	var freeDomain=true;
	var extaFreeDomain=1;
	for(i=0;i<sendDomain.length;i++){
		var freeDomainUsed=false;
		var domname=sendDomain[i].split(".");
		var price=productPlans[5][domname[1]];
		var dscPercent=getDiscount('domain',domainPeriods[i]);
		var dscPrice=price-price*(dscPercent/100);
		price*=domainPeriods[i];
		singleDscPrice=dscPrice;
		dscPrice*=domainPeriods[i];
		//if(domname[1]=="eu"){price-=9.10; dscPrice-=(9.10-(8.90*(dscPercent/100)));}
		if(domname[1]=="bg"){dscPrice=price;}
		
		/*
		if(hostingPeriod>=12 && useHosting==1 && freeDomain && domname[1]!="bg" ){
			dscPrice-=singleDscPrice*(hostingPeriod/12);
			//if(domname[1]=="eu")dscPrice+=(9.10-(8.90*(dscPercent/100)));
			freeDomain=false;
			freeDomainUsed=true;
			
		}
		*/
		//alert(hostingPlan);
		//alert(extaFreeDomain);
		//alert(sendDomain.length);
		if(hostingPlan==12 && extaFreeDomain>0 && sendDomain.length>1 && hostingPeriod>=12 && !freeDomainUsed && domname[1]!="bg"){
			dscPrice-=singleDscPrice*(hostingPeriod/12);
			//if(domname[1]=="eu")dscPrice+=(9.10-(8.90*(dscPercent/100)));
			extaFreeDomain--;
		}
		
		
		if(dscPrice<0)dscPrice=0;
		domainPrices['price'].push(price);
		domainPrices['discount_price'].push(dscPrice);
		
		
	}

	if(typeof(hostingPlan)=="undefined") hostingPlan=9;
	if(typeof(serverPlan)=="undefined") serverPlan=19;
	if(typeof(vpsPlan)=="undefined") vpsPlan=13;
	hostingPrices=productPlans[hostingPlan]*hostingPeriod;
	hostingDiscountPrices=hostingPrices-hostingPrices*(getDiscount('hosting',hostingPeriod)/100);
	serverPrices=productPlans[serverPlan]*serverPeriod;
	serverDiscountPrices=serverPrices-serverPrices*(getDiscount('server',serverPeriod)/100);
	vpsPrices=productPlans[vpsPlan]*vpsPeriod;
	vpsDiscountPrices=vpsPrices-vpsPrices*(getDiscount(0,0,0,GLOBAL_USER_NUM_PACKETS,GLOBAL_USER_DISCOUNTS.SERVER_DISCOUNT)/100);
	
	var hostOrServerDsc;
	var hostOrServer;
	if(useHosting==1){
	  hostOrServer=hostingPrices;
	  hostOrServerDsc=hostingDiscountPrices;
	}
	if(useHosting==2){
	  hostOrServer=serverPrices;
	  hostOrServerDsc=serverDiscountPrices;
	}
	if(useHosting==3){
	  hostOrServer=vpsPrices;
	  hostOrServerDsc=vpsDiscountPrices;
	}

	var domainDscPrice=sum(domainPrices['discount_price']);
	
	var saveDomain=(sum(domainPrices['price'])-domainDscPrice);
	if(sum(domainPrices['price'])==0)saveDomain=0;
	if(saveDomain>sum(domainPrices['price']))saveDomain=sum(domainPrices['price']);

	

	if(useHosting==1){document.getElementById('hiddenProductPlan').value=hostingPlan;document.getElementById('hiddenProductPeriod').value=hostingPeriod;}
	if(useHosting==2){document.getElementById('hiddenProductPlan').value=serverPlan;document.getElementById('hiddenProductPeriod').value=hostingPeriod;}
	if(useHosting==3){document.getElementById('hiddenProductPlan').value=vpsPlan;document.getElementById('hiddenProductPeriod').value=hostingPeriod;}

//отстъпки от ваучери

	if(typeof(voucher)!="undefined" && (voucher['product_id']==hostingPlan || voucher['group_id']==1))
	{
	  if(voucher['type']=="percent")hostingDiscountPrices=hostOrServer-hostOrServer*(voucher['value']/100);
	  if(voucher['type']=="value")hostingDiscountPrices=hostOrServer-voucher['value'];
	  if(voucher['type']=="period")hostingDiscountPrices=hostOrServer-productPlans[hostingPlan]*voucher['value'];
	}

	if(typeof(voucher)!="undefined" && (voucher['product_id']==serverPlan || voucher['group_id']==2))
	{
	  if(voucher['type']=="percent")hostingDiscountPrices=hostOrServer-hostOrServer*(voucher['value']/100);
	  if(voucher['type']=="value")hostingDiscountPrices=hostOrServer-voucher['value'];
	  if(voucher['type']=="period")hostingDiscountPrices=hostOrServer-productPlans[hostingPlan]*voucher['value'];
	}
	
	if(typeof(voucher)!="undefined" && (voucher['product_id']==vpsPlan || voucher['group_id']==3))
	{
	  if(voucher['type']=="percent")hostingDiscountPrices=hostOrServer-hostOrServer*(voucher['value']/100);
	  if(voucher['type']=="value")hostingDiscountPrices=hostOrServer-voucher['value'];
	  if(voucher['type']=="period")hostingDiscountPrices=hostOrServer-productPlans[hostingPlan]*voucher['value'];
	}
//край на ваучерите
	if(hostingDiscountPrices<0)hostingDiscountPrices=0;
	

	
	if(useHosting==1){sumPrice=sum(domainPrices['price'])+hostingPrices;sumDiscountPrice=domainDscPrice+hostingDiscountPrices;}
	if(useHosting==2){sumPrice=sum(domainPrices['price'])+serverPrices;sumDiscountPrice=domainDscPrice+serverDiscountPrices;}
	if(useHosting==3){sumPrice=sum(domainPrices['price'])+vpsPrices;sumDiscountPrice=domainDscPrice+vpsDiscountPrices;}

	
	document.getElementById('order_pricedom1').innerHTML=sum(domainPrices['price']).toFixed(2);
	if(useHosting==1)document.getElementById('order_pricehosting1').innerHTML=hostingPrices.toFixed(2);
	if(useHosting==2)document.getElementById('order_pricehosting1').innerHTML=serverPrices.toFixed(2);
	if(useHosting==3)document.getElementById('order_pricehosting1').innerHTML=vpsPrices.toFixed(2);
	document.getElementById('order_pricedomhosting1').innerHTML=sumPrice.toFixed(2);
	document.getElementById('order_promodomnames1').innerHTML=saveDomain.toFixed(2);
	document.getElementById('order_discounthosting1').innerHTML=(hostOrServer-hostOrServerDsc).toFixed(2);
	document.getElementById('order_minusdomhosting1').innerHTML=(sumPrice-sumDiscountPrice).toFixed(2);
	document.getElementById('order_pricefull1').innerHTML=sumDiscountPrice.toFixed(2);
}


function sum(arr){
	var sum=0;
	for(var i=0;i<arr.length;i++){
		sum+=arr[i];
	}
	return sum;
}

function getCartCount(){
	var argList="";
	new HttpRequest("post","/bg/cart/getnum/",argList,"shoppingcartcount");
}
// JavaScript Document
function showPopUpWindow(infoAction,article){
var containerBox=document.getElementById('trypopup');
var contentBox=document.getElementById('popup_container');
var overlay=document.getElementById('popup_overlay');
overlay.style.display='block';
containerBox.style.display='block';
var argList="";

if(typeof(article)!="undefined") argList="&id="+article;
new HttpRequest("post","/bg/info/"+infoAction+"/",argList,contentBox);
placePopUp();
}


function placePopUp() {
  var winWidth = 0, winHeight = 0;
  var scrOfX = 0, scrOfY = 0;
  var win=document.getElementById('trypopup');
  if( typeof( window.innerWidth ) == 'number' ) {
    winWidth = window.innerWidth;
    winHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    winWidth = document.documentElement.clientWidth;
    winHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    winWidth = document.body.clientWidth;
    winHeight = document.body.clientHeight;
  }
 
  if( typeof( window.pageYOffset ) == 'number' ) {
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }


 win.style.top=(scrOfY+30)+'px';
 win.style.left=(winWidth/2-450)+'px';
 
}


function hidePopUp(){
document.getElementById('popup_overlay').style.display='none';
document.getElementById('trypopup').style.display='none';
}



function getMouseCoords(e)
{
	var IE = document.all?true:false;
	if (!IE) document.captureEvents(Event.MOUSEMOVE)
	var tempX = 0;
	var tempY = 0;
	if (IE)
	{ 
		mouseX = event.clientX + document.documentElement.scrollLeft;
		mouseY = event.clientY + document.documentElement.scrollTop;
	}
	else 
	{  
		mouseX = e.pageX;
		mouseY = e.pageY;
	}  

	
}


function smallInfoBox(info)
{

	var infoBox=document.getElementById('infoBox');
	infoBox.innerHTML=info;
	infoBox.style.left=mouseX+2+"px";
	infoBox.style.top=(mouseY+2)+"px";
	infoBox.style.display='block';
	infoBox.style.zIndex="100";
}


function hideInfoBox()
{
	var infoBox=document.getElementById('infoBox');
	infoBox.style.display='none';
}
