/**
* TemplatePlazza.com 
**/
function dropcart(dastat){
	var wh			= getheight();
	var dc			= wh-30;
	var cname	= "showhidetpdrag";
	var cget	= Cookie.get(cname);
	if(cget == false){ cget = dastat; }
	Cookie.set("showhidetpdrag", cget, {path:'/', duration: 1});
	setshowhide("");
	$("showhidecart").setStyle("top", Math.ceil((wh-100)/2)+"px");
	
	var droparea	= document.getElementById('dropcart');
	if(droparea){
		var drop 		= $('dropcart');
		$('dropcart').setStyle("height", dc+"em");
		$('dropcartborder').setStyle("height", wh+"em");
		$$('.itemcart').each(function(item){
			item.addEvent('mousedown', function(e){
				e 		= new Event(e).stop();
				formid	= $$("#"+item.id+" form").getProperty('id')[0];
				var clone = this.clone()
					.setStyles(this.getCoordinates())
					.setStyles({'opacity': 1, 'position': 'absolute'})
					.addEvent('emptydrop', function(){
						this.remove();
						drop.removeEvents();
					}).inject(document.body);
				drop.addEvents({
					"drop":		function(){
						drop.removeEvents();
						clone.remove();
						handleAddToCart( formid );
					}
				});
				var drag = clone.makeDraggable({ droppables: [drop] });
				drag.start(e);
			});
		});
	}
	
	var checkcart	= document.getElementById('myminicart');
	var	mmcheight	= (checkcart) ? dc-200 : 0;
	var bordert		= 10;
	var borderw		= $$(".thumbscart").getStyle("height");
	var totalitem	= new Array();
	for(i=0; i<borderw.length; i++){
		totalitem.push(parseInt((i+1)));
		bordert 	+= parseInt(borderw[i]);
	}
	$$("#myminicart .minicartinner").setStyle("height", bordert+"px");
	$$('#myminicart').setStyle('height', mmcheight+"px");
	
	//scroller
	if($('minicartinner')){
		var hs2 = new noobSlide({
			box: $('minicartinner'),
			mode: 'vertical',
			size: 70,
			items: totalitem,
			interval: 3000,
			fxOptions: {
				duration: 1000,
				transition: Fx.Transitions.Sine.easeOut,
				wait: false
			},
			buttons:{
				previous: $('cartleft'),
				next: $('cartright')
			}
		});
	}
	
	if(window.ie6){
		$$('#dropcartborder').setStyle('position', "absolute");
	}
	
	//showhide
	$('showhidecart').addEvent('click', function(event){
		var cget	= Cookie.get(cname);
		var bb		= (cget == "active") ? "notactive" : "active";
		Cookie.set(cname, bb, {path:'/', duration: 7});
		setshowhide("fx");
	});
	
	function setshowhide(fxs){
		var cget	= Cookie.get(cname);
		var stat	= (cget == "active") ? 0 : -130;
		var fx 		= new Fx.Styles($('dropcartborder'),{duration: 200,wait: false,transition: Fx.Transitions.Quad.easeOut });
		if(fxs){
			fx.start({ 'right': [parseInt($("dropcartborder").getStyle("right")), stat] });
		}else{
			if($("dropcartborder")){
				$("dropcartborder").setStyle("right", stat+"px");
			}
		}
	}
	
	function getheight(){
		var y = 0;
		if(self.innerHeight){
			y = self.innerHeight;
		}else if (document.documentElement && document.documentElement.clientHeight){
			y = document.documentElement.clientHeight;
		}else if (document.body){
			y = document.body.clientHeight;
		}
		return y;
		}
	}

function dropcartscroll(){
	if(window.ie6){
		var dropbarea	= document.getElementById('dropcartborder');
		if(dropbarea){
			var bodyheight	= document.body.offsetHeight;
			var property	= window.getSize();
			var top			= property['scroll']['y']-20;
			if(top < bodyheight){
				$('dropcartborder').setStyle("top", top+"px");
			}
		}
	}
}