function defPosition(event) {
	   var x = y = 0;
	   var event = event || window.event;
	   if (document.attachEvent != null) { // Internet Explorer & Opera
	       x = window.event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
	       y = window.event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
	   } else if (!document.attachEvent && document.addEventListener) { // Gecko
	       x = event.clientX + window.scrollX;
	       y = event.clientY + window.scrollY;
	   } else {
	       // Do nothing
	   }
        return {x:x,y:y};
	}
function Cart_Blog(event,id,name,price)
{
	event=defPosition(event);
	PanelHtml(event.x,event.y,id)
	document.getElementById("catalog_cart_blog").style.display="block";
	document.getElementById("cart_blog_title").innerHTML=name;
	document.getElementById("cart_price").innerHTML=price;
}
function PanelHtml(x,y,id)
{
    document.getElementById('catalog_cart_blog').style.left=(x+10)+'px';
	document.getElementById('catalog_cart_blog').style.top=(y-25)+'px';
	var html = '';
	html += '<table border="0" cellspacing="0" cellpadding="0">';
		html += '<tr>';
			html += '<td height="52px" colspan="3" class="cart_blog_title">'+blog_title+'<br /><span id="cart_blog_title"></span></td>';
			html += '<td height="52px" rowspen="3" class="cart_cloce"><a onclick="javascript:document.getElementById(\'catalog_cart_blog\').style.display=\'none\';" title="close">x</a></td>';
		html += '</tr>';
		html += '<tr>';
			html += '<td class="blog_void_text" height="39px">'+blog_text_1+'</td>';
			html += '<td class="blog_void_text">'+blog_text_2+'</td>';
			html += '<td class="blog_void_text">'+blog_text_3+'</td>';
		html += '</tr>';
		html += '<tr>';
			html += '<td class="cart_blog_void_1"><div id="cart_price">0.00</div></td>';
			html += '<td class="cart_blog_void_2"><div><input name="cart_count" id="cart_count" type="text" value="1.00"></div></td>';
			html += '<td class="cart_blog_void_3"><img src="'+theme+'/images/cart_blog_add.gif" onclick="Cart_Add('+id+');" border="" alt=""></td>';
		html += '</tr>';
	html += '</table>';
   document.getElementById("catalog_cart_blog").innerHTML=html;

}



function Cart_Add(id)
{
    document.getElementById('catalog_cart_blog').style.display='none';
    var cart_count=document.getElementById("cart_count").value;
	showBusyLayer();
	var ajax = new dle_ajax();
	ajax.onShow (load_cart);
	ajax.setVar('id',id);
	ajax.setVar('cart_count',cart_count);
	ajax.requestFile = dle_root + "engine/ajax/cart.php";
	ajax.method = 'POST';
	ajax.element = 'cart_block';
	ajax.execute=true;
	ajax.onCompletion=DlePageCompleted;
	ajax.sendAJAX('');

}


function showBusyLayer()
{	var a=document.getElementById("busy_layer");
	if(window.innerHeight&&window.scrollMaxY)
	{		yScroll=window.innerHeight+window.scrollMaxY;
		var b=document.documentElement;
		var c=(b&&b.clientHeight)||document.body.clientHeight||window.innerHeight||self.innerHeight;
		yScroll-=(window.innerHeight-c)
	}
	else if(document.body.scrollHeight>document.body.offsetHeight||document.body.scrollWidth>document.body.offsetWidth)
	{		yScroll=document.body.scrollHeight
	}
	else
	{		yScroll=document.body.offsetHeight
	}
	if(a!=null)
	{		a.style.visibility="visible";
		a.style.height=yScroll
	}
};
function hideBusyLayer()
{	var a=document.getElementById("busy_layer");
	if(a!=null)
	{		a.style.visibility="hidden";a.style.height="0px"
	}
};
function _get_obj_toppos(a)
{	var b=a.offsetTop;
	while((a=a.offsetParent)!=null)
	{		b+=a.offsetTop
	}
	return b
};

function center_div(){this.divname='';this.divobj=''};center_div.prototype.clear_div=function(){try{if(!this.divobj){return}else{this.divobj.style.display='none'}}catch(e){return}};center_div.prototype.Ywindow=function(){var a=0;if(document.documentElement&&document.documentElement.scrollTop){a=document.documentElement.scrollTop}else if(document.body&&document.body.scrollTop){a=document.body.scrollTop}else if(window.pageYOffset){a=window.pageYOffset}else if(window.scrollY){a=window.scrollY}return a};center_div.prototype.move_div=function(){try{this.divobj=document.getElementById(this.divname)}catch(e){return}var a=0;var b=0;if(typeof(window.innerWidth)=='number'){a=window.innerWidth;b=window.innerHeight}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){a=document.documentElement.clientWidth;b=document.documentElement.clientHeight}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){a=document.body.clientWidth;b=document.body.clientHeight}this.divobj.style.position='absolute';this.divobj.style.display='block';this.divobj.style.zIndex=99;var c=parseInt(this.divobj.style.Height);var d=parseInt(this.divobj.style.Width);c=c?c:50;d=d?d:200;var f=this.Ywindow();var g=(a-d)/2;var h=(b-c)/2+f;g=(g<0)?0:g;h=(h<0)?0:h;this.divobj.style.left=g+"px";this.divobj.style.top=h+"px"};
function dle_ajax(p){this.AjaxFailedAlert="AJAX not supported.\n";this.requestFile=p;this.method="POST";this.URLString="";this.encodeURIString=true;this.execute=false;this.add_html=false;this.loading_fired=0;this.centerdiv=null;this.onLoading=function(){};this.onLoaded=function(){};this.onInteractive=function(){};this.onCompletion=function(){};this.onShow=function(a){if(!this.loading_fired){this.loading_fired=1;if(a){document.getElementById('loading-layer-text').innerHTML=a}this.centerdiv=new center_div();this.centerdiv.divname='loading-layer';this.centerdiv.move_div()}return};this.onHide=function(){try{if(this.centerdiv&&this.centerdiv.divobj){this.centerdiv.clear_div()}}catch(e){}this.loading_fired=0;return};this.createAJAX=function(){try{this.xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}catch(err){this.xmlhttp=null}}if(!this.xmlhttp&&typeof XMLHttpRequest!="undefined")this.xmlhttp=new XMLHttpRequest();if(!this.xmlhttp){this.failed=true}};this.setVar=function(a,b){if(this.URLString.length<3){this.URLString=a+"="+b}else{this.URLString+="&"+a+"="+b}};this.encVar=function(a,b){var c=encodeURIComponent(a)+"="+encodeURIComponent(b);return c};this.encodeURLString=function(a){varArray=a.split('&');for(i=0;i<varArray.length;i++){urlVars=varArray[i].split('=');if(urlVars[0].indexOf('amp;')!=-1){urlVars[0]=urlVars[0].substring(4)}varArray[i]=this.encVar(urlVars[0],urlVars[1])}return varArray.join('&')};this.encodeVAR=function(a){a=a.toString();var b=a.match(/[\x90-\xFF]/g);if(b){for(var i=0;i<i.length;i++){a=a.replace(b[i],'%u00'+(b[i].charCodeAt(0)&0xFF).toString(16).toUpperCase())}}return escape(a).replace(/\+/g,"%2B")};this.runResponse=function(){var a=new Date;var b=false;a=a.getTime();var c=/<script.*?>(.|[\r\n])*?<\/script>/ig;var d=c.exec(this.response);if(d!=null){var e=new Array(d.shift());var b=true;while(d){d=c.exec(this.response);if(d!=null)e.push(d.shift())}for(var i=0;i<e.length;i++){this.response=this.response.replace(e[i],'<span id="'+a+i+'" style="display:none;"></span>')}}if(this.add_html){this.elementObj.innerHTML+=this.response}else{this.elementObj.innerHTML=this.response}if(b){var f=/<script.*?>((.|[\r\n])*?)<\/script>/ig;for(i=0;i<e.length;i++){var g=document.getElementById(a+''+i);var h=g.parentNode;h.removeChild(g);f.lastIndex=0;var k=f.exec(e[i]);var l=h.appendChild(document.createElement('script'));l.text=k[1];var m=e[i].substring(e[i].indexOf(' ',0),e[i].indexOf('>',0));var n=m.split(' ');if(n.length>1){for(var j=0;j<n.length;j++){if(n[j].length>0){var o=n[j].split('=');o[1]=o[1].substr(1,(o[1].length-2));l.setAttribute(o[0],o[1])}}}}}};this.sendAJAX=function(b){this.responseStatus=new Array(2);if(this.failed&&this.AjaxFailedAlert){alert(this.AjaxFailedAlert)}else{if(b){if(this.URLString.length){this.URLString=this.URLString+"&"+b}else{this.URLString=b}}if(this.encodeURIString){var c=new Date().getTime();this.URLString=this.encodeURLString(this.URLString);this.setVar("rndval",c)}if(this.element){this.elementObj=document.getElementById(this.element)}if(this.xmlhttp){var d=this;if(this.method=="GET"){var f=this.requestFile+"?"+this.URLString;this.xmlhttp.open(this.method,f,true)}else{this.xmlhttp.open(this.method,this.requestFile,true)}if(this.method=="POST"){try{this.xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded')}catch(e){}}this.xmlhttp.send(this.URLString);this.xmlhttp.onreadystatechange=function(){switch(d.xmlhttp.readyState){case 1:d.onLoading();break;case 2:d.onLoaded();break;case 3:d.onInteractive();break;case 4:d.response=d.xmlhttp.responseText;d.responseXML=d.xmlhttp.responseXML;d.responseStatus[0]=d.xmlhttp.status;d.responseStatus[1]=d.xmlhttp.statusText;d.onHide();d.onCompletion();if(d.elementObj){var a=d.elementObj.nodeName;a=a.toLowerCase();if(a=="input"||a=="select"||a=="option"||a=="textarea"){if(d.response=='error'){alert('Access denied')}else{if(d.add_html){d.elementObj.value+=d.response}else{d.elementObj.value=d.response}}}else{if(d.response=='error'){alert('Access denied')}else{if(d.execute){d.runResponse()}else{if(d.add_html){d.elementObj.innerHTML+=d.response}else{d.elementObj.innerHTML=d.response}}}}}d.URLString="";break}}}}};this.createAJAX()};
