"use strict";if(!this.JSON){this.JSON={};}
(function(){function f(n){return n<10?'0'+n:n;}
if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+
partial.join(',\n'+gap)+'\n'+
mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
return str('',{'':value});};}
if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('JSON.parse');};}}());


function concise(){concise.url='js.oilexpress.info';o=document.getElementsByTagName("object");for(var i=0;i<o.length;i++){o[i].outerHTML=o[i].outerHTML;}}
concise.g=function(i){if(document.getElementById(i)){return document.getElementById(i);}else{return false}}
concise.safeurl=function(i){i=i.replace('&','%26');i=encodeURIComponent(i);return i;}
concise.disable=function(i){if(concise.g(i).disabled){concise.g(i).disabled=true;}else{concise.g(i).setAttribute('disabled',true);}}
concise.enable=function(i){concise.g(i).disabled=false;}
concise.GetXmlHttpObject=function(){var xmlHttp=null;try{/*Firefox, Opera 8.0+, Safari*/xmlHttp=new XMLHttpRequest();}catch(e){/*Internet Explorer*/try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}}return xmlHttp;}
concise.addChart=function(u,i,a){
	if(u.substring(0,concise.url.length)==concise.url){
	concise.g("chartId"+i).style.display='none';
	concise.g("loading"+i).style.display='block';
	var xmlHttp=concise.GetXmlHttpObject();
	if(xmlHttp==null){
		alert("Browser does not support HTTP Request");
	}else{
		var amount=concise.g("amount"+i).value;
		if(parseInt(amount)>0&&parseInt(i)>0){
			var url=u+"&basket_id="+parseInt(i)+"&amount="+parseInt(amount)+"&"+Math.random()+"/";
			xmlHttp.open("GET",url,true);
			xmlHttp.onreadystatechange=function(){
				if(xmlHttp.readyState!=4) return;
				if(xmlHttp.status!=200) return;
				var r=JSON.parse(xmlHttp.responseText);
		    concise.g("basketMsg").innerHTML=""+r['result'];
		    concise.g("chartId"+i).style.display='block';
		    concise.g("loading"+i).style.display='none';
		    /*if(r['status']!='1'){concise.addChart(u,i,a);}*/
			}
			xmlHttp.send(null);
			
		}else{
			alert(a);
			concise.g("chartId"+i).style.display='block';
			concise.g("loading"+i).style.display='none';
		}
	}
	}
}
concise.increase=function(i,s,t){
	var xmlHttp=concise.GetXmlHttpObject();
	if(xmlHttp==null){
		alert("Browser does not support HTTP Request");
	}else{
		var url=concise.url+'/&before_init='+((t==0)?'increase':'decrease')+'&basket_id='+parseInt(i)+'&size='+s+'/';
		xmlHttp.open("GET",url,true);
		xmlHttp.onreadystatechange=function(){
			if(xmlHttp.readyState!=4) return;
			if(xmlHttp.status!=200) return;
			var r=JSON.parse(xmlHttp.responseText);
			if(r.p==0){
				if(!window.location.reload()){
					window.location.href=window.location.href;
				}
			}else{
				if(parseInt(r.a)>=0){
					concise.g("amount"+i).innerHTML=parseFloat(r.a);
					concise.g("priceCount"+i).innerHTML=parseFloat(r.c);
				}else{
					concise.g("productContainer"+i).innerHTML='';
					concise.g("productContainer"+i).style.display='none';
				}
				concise.g("priceTotal").innerHTML=parseFloat(r.t);
			}
		}
		xmlHttp.send(null);
	}
}
concise.deleteProduct=function(i,s,t){
	var xmlHttp=concise.GetXmlHttpObject();
	if(xmlHttp==null){
		alert("Browser does not support HTTP Request");
	}else{
		var url=concise.url+'/&before_init=deleteProduct&basket_id='+parseInt(i)+'&size='+s+'/';
		xmlHttp.open("GET",url,true);
		xmlHttp.onreadystatechange=function(){
			if(xmlHttp.readyState!=4) return;
			if(xmlHttp.status!=200) return;
			var r=JSON.parse(xmlHttp.responseText);
			if(r.p==0){
				if(!window.location.reload()){
					window.location.href=window.location.href;
				}
			}else{
				if(parseInt(r.a)>=0){
					concise.g("amount"+i).innerHTML=parseFloat(r.a);
					concise.g("priceCount"+i).innerHTML=parseFloat(r.c);
				}else{
					concise.g("productContainer"+i).innerHTML='';
					concise.g("productContainer"+i).style.display='none';
				}
				concise.g("priceTotal").innerHTML=parseFloat(r.t);
			}
		}
		xmlHttp.send(null);
	}
}
concise.useBonus=function(i){
	var xmlHttp=concise.GetXmlHttpObject();
	if(xmlHttp==null){
		alert("Browser does not support HTTP Request");
	}else{
		if(concise.g(i).checked==true){var j=1;}else{var j=0;}
		var url=concise.url+'/&before_init=useBonus&checked='+parseInt(j)+'/';
		xmlHttp.open("GET",url,true);
		xmlHttp.onreadystatechange=function(){
			if(xmlHttp.readyState!=4) return;
			if(xmlHttp.status!=200) return;
			var r=JSON.parse(xmlHttp.responseText);
			concise.g("priceTotal").innerHTML=parseFloat(r.t);
		}
		xmlHttp.send(null);
	}
}
concise.useDiscount=function(i,j){
	var xmlHttp=concise.GetXmlHttpObject();
	if(xmlHttp==null){
		alert("Browser does not support HTTP Request");
	}else{
		concise.g("loadingDiscount").style.display='block';
		var url=concise.url+'/&before_init=useDiscount&code='+concise.safeurl(concise.g(i).value)+'/';
		xmlHttp.open("GET",url,true);
		xmlHttp.onreadystatechange=function(){
			if(xmlHttp.readyState!=4) return;
			if(xmlHttp.status!=200) return;
			var r=JSON.parse(xmlHttp.responseText);
			concise.g(j).innerHTML=parseFloat(r.d)+' %';
			concise.g("priceTotal").innerHTML=parseFloat(r.t);
			concise.g("loadingDiscount").style.display='none';
		}
		xmlHttp.send(null);
	}
}
concise.shipping=function(i){
	var xmlHttp=concise.GetXmlHttpObject();
	if(xmlHttp==null){
		alert("Browser does not support HTTP Request");
	}else{
		var url=concise.url+'/&before_init=shipping&basket_shipping_id='+parseInt(i)+'/';
		xmlHttp.open("GET",url,true);
		xmlHttp.onreadystatechange=function(){
			if(xmlHttp.readyState!=4) return;
			if(xmlHttp.status!=200) return;
			var r=JSON.parse(xmlHttp.responseText);
			
			concise.g("priceTotal").innerHTML=parseFloat(r.t);
			
		}
		xmlHttp.send(null);
	}
}
concise.checkCompany=function(v,i){
	if(concise.g(v).value==1){
		concise.g(i).style.display='block';
	}else{
		concise.g(i).style.display='none';
	}
}
concise.showDiv=function(v,s){
	if(concise.g(s)){
		if(concise.g(v).checked==true){
			concise.g(s).style.display='block';
		}else{
			concise.g(s).style.display='none';
		}
	}
}
concise.passwordChange=function(menu_name,p,pn,pc){
	concise.g("statusBigLoading").style.display='block';
	concise.g("statusBigText").style.display='none';
	concise.disable("buttonSubmit");
	var xmlHttp=concise.GetXmlHttpObject();
	if(xmlHttp==null){
		alert("Browser does not support HTTP Request");
	}else{
		var password=concise.safeurl(concise.g(p).value);
		var password_new=concise.safeurl(concise.g(pn).value);
		var password_new_confirm=concise.safeurl(concise.g(pc).value);
		var url=concise.url+"/"+menu_name+"&before_init=try-change-password&password="+password+"&password_new="+password_new+"&password_new_confirm="+password_new_confirm+"&"+Math.random()+"/";
		xmlHttp.open("GET",url,true);
		xmlHttp.onreadystatechange=function(){
			if(xmlHttp.readyState!=4) return;
			if(xmlHttp.status!=200) return;
			concise.g("statusBigLoading").style.display='none';
     	//var r=eval('(' + xmlHttp.responseText + ')');
     	var r=JSON.parse(xmlHttp.responseText);
	    concise.g("statusBigText").innerHTML='';
  	  for(var i in r['result']){
      	concise.g("statusBigText").innerHTML=concise.g("statusBigText").innerHTML+"<p>"+r['result'][i]+"</p>";
     	}
			concise.g("statusBigText").style.display='block';
			concise.enable("buttonSubmit");
			if(r.status==1){
				concise.g("password").value="";
				concise.g("password_new").value="";
				concise.g("password_new_confirm").value="";
			}
			concise.enable("buttonSubmit");
		}
		xmlHttp.send(null);
	}
}
concise.submitForm=function(n){
	if(document.forms[n].submit()){document.forms[n].submit();}
}
concise.checkEnter=function(myfield,e){
	var keycode;
	if(window.event){
		keycode=window.event.keyCode;
	}else if (e){
		keycode=e.which;
	}else{
		return true;
	}
	if(keycode==13){
		myfield.form.submit();
		return false;
	}else{
		return true;
	}
}
this.concise();
var conciseCms=function(){
	var url='http://js.oilexpress.info';
//***
	function tryBlur(v,i,c){if(concise.g(i).value==''){concise.g(i).value=v;concise.g(i).className=c;}}
//***
	function tryClick(v,i,c){if(concise.g(i).value==v){concise.g(i).value='';concise.g(i).className='';}}
//***
	return {
		tryBlur:function(v,i,c){tryBlur(v,i,c);},
		tryClick:function(v,i,c){tryClick(v,i,c);}
	}
}();
