

function eid(n){return document.getElementById(n);}

if ('undefined'==typeof String.prototype.trim){String.prototype.trim=function() {return this.replace(/^\s+/, '').replace(/\s+$/, '');}}

function viewfblock(s,c){for(i=0;i<33;i++){bobj=document.getElementById('b'+i);if(bobj)bobj.style.background=c;curobj=document.getElementById('alf'+i);	if(curobj)curobj.style.display='none';}bobj2=document.getElementById('b'+s);curobj2=document.getElementById('alf'+s);bobj2.style.background='#fff';curobj2.style.display='block';}

function ÑhangeDisplayStyle(id, t){o=eid(id);if(o&&t=='block'){o.style.display='block';o.style.visibility='visible';}else if(o&&t=='none'){o.style.display='none';o.style.visibility='hidden';}else if(o){if(o.style.display=='block'||o.style.visibility=='visible') {o.style.display='none';o.style.visibility='hidden';}else if(o.style.display == 'none'||o.style.visibility=='hidden'){o.style.display='block';o.style.visibility='visible';}}}

xmlDoc=new Array();
function w2load(w2page,id) {if(typeof window.ActiveXObject!='undefined'){xmlDoc[id] = new ActiveXObject("Microsoft.XMLHTTP");xmlDoc[id].open("GET",w2page,true);   xmlDoc[id].send(null);xmlDoc[id].onreadystatechange=function(){if(xmlDoc[id].readyState!=4)return;document.getElementById(id).innerHTML=xmlDoc[id].responseText;}}else{xmlDoc[id]=new XMLHttpRequest();xmlDoc[id].open("GET",w2page,true);xmlDoc[id].send(null);xmlDoc[id].onload=function(){if(xmlDoc[id].readyState!=4)return;document.getElementById(id).innerHTML=xmlDoc[id].responseText;}}}

function addBookmark(title,url){if(window.sidebar){window.sidebar.addPanel(title, url,"");}else if(document.all){window.external.AddFavorite( url, title);}else if(window.opera&&window.print){return true;}}



fds=ÑhangeDisplayStyle;

/*function upbutton() {o = eid('but');if(o.className=='a')o.className='m'; else o.className='a';}*/


function show_shadow_form() {
	$("#bg_form").show();
	$("<div class='bg_body_form'></div>").appendTo("#body");
	$("#body").css("overflow", "hidden");
	$("#body").css("padding-right", "20px");
}

function hide_shadow_form() {
	$(".bg_body_form").attr("class", "");
	$('#bg_form').hide();
	$("#body").css("padding-right", "0px");
	$("#body").css("overflow", "auto");
}

function number_format( number, decimals, dec_point, thousands_sep ) {    // Format a number with grouped thousands
    var i, j, kw, kd, km;
    if( isNaN(decimals = Math.abs(decimals)) ){
        decimals = 2;
    }
    if( dec_point == undefined ){
        dec_point = ",";
    }
    if( thousands_sep == undefined ){
        thousands_sep = ".";
    }
    i = parseInt(number = (+number || 0).toFixed(decimals)) + "";
    if( (j = i.length) > 3 ){
        j = j % 3;
    } else{
        j = 0;
    }
    km = (j ? i.substr(0, j) + thousands_sep : "");
    kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep);
    kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : "");
    return km + kw + kd;
}

function set_input_data(data, id) {
	$("#"+id).attr("value", data);
	summa(data);
}
								
function display_status(answer){
	document.getElementById("status_info").innerHTML="<font style='font-size:14px;'>"+answer+"</font>";
}
function set_status(){						
	id = document.getElementById("order_status").value;
	var oXmlHttp = zXmlHttp.createRequest();
 	oXmlHttp.open("get", "/content/contentus/ajax_status.php?order=" + id, true);
	oXmlHttp.onreadystatechange = function () {
		if (oXmlHttp.readyState == 4) {
			if (oXmlHttp.status == 200) {
		        	display_status(oXmlHttp.responseText);
		        } 
		        else {
		            display_status("An error occurred: " + oXmlHttp.statusText); //statusText is not always accurate
				}
		}
	};
		oXmlHttp.send(null);
}
