// JavaScript Document
function ShowArt(folder,lang){
var loc = 'index.php?S=4&Folder='+folder+'&L='+lang;	
location.href=loc;
}

function ShowNws(ce,tc){
	if(ce>0 && tc>0){
		for(i=1;i<=tc;i++){
		getE('frstlstn'+i).style.display = 'none';	
		getE('dotlink'+i).className = 'dotlink';
		}
		
		getE('frstlstn'+ce).style.display = '';	
		getE('dotlink'+ce).className = 'dotlinkon';
		getE('dotlink'+ce).blur();
	}	
}



function getY(obj){
        return (obj.offsetParent ? obj.offsetTop + getY(obj.offsetParent) : obj.y ? obj.y : 0);
    }
	
	  function getX(obj){
		 
		if(!obj){ return 0; }
        return obj.offsetLeft + (obj.offsetParent ? getX(obj.offsetParent) : obj.x ? obj.x : 0);
    }
	
	
	
	var DIRECTION = 0;
var movingdir;
var movingdir2;
var rightlimit;

function getrightlimit(){
l = document.getElementById('rollerend');
f2 = document.getElementById('imageholder');
limits = getX(l);
limits2 = getX(f2) + parseInt(f2.offsetWidth);
	if(limits<limits2){
	stopmove();	
	}
	
}

function moveleft(){
if(DIRECTION=0){ return ""; }
f = document.getElementById('rollingdiv');
f2 = document.getElementById('imageholder');

l = parseInt(f.style.left);

if(l>-2){ 
stopmove();
return ""; 
}
f.style.left = (parseInt(l)+2)+'px';
}

function moveright(){
getrightlimit();
if(DIRECTION==0){ return ""; }
f = document.getElementById('rollingdiv');
l = parseInt(f.style.left);
f.style.left = (parseInt(l)-2) +'px';
}


function moveright2(){
	
	l = getE('rollerend');
	f = getE('rollingdiv');
	f2 = getE('imageholder');
	
	limits = getX(l);
	limits2 = getX(f2) + parseInt(f2.offsetWidth);
	
	if(limits<limits2){
	stopmove();	
	return "";
	}
	

	l = parseInt(f.style.left);
	f.style.left = (parseInt(l)-15) +'px';	
	

	
}

function moveleft2(){
	
	f = document.getElementById('rollingdiv');
	f2 = document.getElementById('imageholder');

	l = parseInt(f.style.left);
	
	if(l>-2){ 
	f.style.left = 0+'px';
	stopmove();
	return ""; 
	}
		
	l = parseInt(f.style.left);
	f.style.left = (parseInt(l)+15) +'px';	
}

function moveit(direction){

	if(direction=='left' || direction=='right'){
		DIRECTION = 'moving'+direction;
		if(direction=='left'){
		movingdir = setInterval('moveleft()',1);
		}else if(direction=='right'){
		movingdir = setInterval('moveright()',1);
		}
	}
}

function stopmove(){
clearInterval(movingdir);
DIRECTION = 0;

}

function handle(delta) {
	
	
	if (delta < 0){
		/* something. */;
		var DIRECTION = 'movingleft';		
		moveright2();		
	} else {
				
		/* something. */;		
		DIRECTION = "right";			
		moveleft2();
			
	}
	
}
function wheel2(){
	
}

function wheel(event){
	var delta = 0;
	if (!event) event = window.event;
	if (event.wheelDelta) {
		delta = event.wheelDelta/120; 
		if (window.opera) delta = -delta;
	} else if (event.detail) {
		delta = -event.detail/3;
	}
	if (delta)
		handle(delta);
        if (event.preventDefault)
        event.preventDefault();
        event.returnValue = false;
}

/* Initialization code. */
function AddLM(){
if (window.addEventListener && getE('rollingdiv'))
	window.addEventListener('DOMMouseScroll', wheel, false);
	window.onmousewheel = document.onmousewheel = wheel;
}

function RemoveLM(){
	if (getE('rollingdiv').removeEventListener){
	getE('rollingdiv').removeEventListener('DOMMouseScroll', wheel, false);
	}else{
	
	}
}




function AddToCartCustom(){
	if(getE('ADDTOCARTFORM')){
	document.ADDTOCARTFORM.submit();
	}
}

function returcartnajax(r){
	
}


function RemoveArticleFromCart(itemid){
	d = document.CartMainForm;
	d.ID.value = itemid;
	d.Action.value = 'RemoveFromCart';
	d.FolderAction.value = 'Ajax';
	if(getE('CartItem'+itemid)){
	RemoveElement('CartItem'+itemid);
	}
	ajax.submitwithfunction(basename,returcartnajax, $('CartMainForm'));
	d = document.CartMainForm;
	d.FolderAction.value = '';
}


function UpdateCart(){
	d = document.CartMainForm;
	d.ID.value = "0";
	d.Action.value = 'UpdateCart';
	d.FolderAction.value = '';
	d.submit();
}

function CheckOutCart(){
	d = document.CartMainForm;
	d.ID.value = "0";
	d.Action.value = 'PreCheckOut';
	d.FolderAction.value = '';
	d.submit();
}

function CheckOutFinal(){
	d = document.CartMainForm;
	d.ID.value = "0";
	d.Action.value = "CheckOut";
	d.FolderAction.value = "CheckOut";
	d.submit();
}

function UpdatePrice(el,currecysymbol,whatid){
	if(el.value && el.getAttribute('price')){
	var v = parseInt(el.value);		
	var artprice = parseInt(el.getAttribute('price'));
	
		if(!isNaN(v) && !isNaN(artprice) ){
		getE('totaltopaycart').innerHTML = '--';
		var v = (el.value);		
		var artprice = (el.getAttribute('price'));
		var original = (v * artprice);
		var results =  (Math.round(original*100)/100);	
			if(!isNaN(results)){
			getE('PRC'+whatid+'a').innerHTML =  results+ ' ' + currecysymbol;
			}
		}
	}
}

function CloseW(){
getE('floatdcart').style.display = 'none';	
}