function Elem(sObj){
	return(document.getElementById(sObj));
}

function moveSelection(iType){
	var oDivSmall=jQuery('#div_small');
	var oDivImg=jQuery('#div_img');
	var oDivCursor=jQuery('#div_cursor');
	if(oDivSmall.size()>0 && oDivImg.size()>0 && oDivCursor.size()>0){
		if(iType==0){
			oDivImg.css('display','none');
			oDivCursor.css('z-index','-10');
			oDivSmall.attr('class','img_main');
		}else{
			oDivSmall.attr('class','img');
			oDivCursor.css('z-index','10');
			oDivImg.css('display','block');
		}
	}
}

function getCursor(ev){
	var leftPos=0;
	var topPos=0;
	obj=jQuery('#div_small')[0];
	if(obj){
		while(obj!=null){
			leftPos+=obj.offsetLeft;
			topPos+=obj.offsetTop;
			obj=obj.offsetParent;
		}
		var X=eval(ev.clientX-leftPos+(document.documentElement.scrollLeft || document.body.scrollLeft)-document.documentElement.clientLeft);
		var Y=eval(ev.clientY-topPos+(document.documentElement.scrollTop || document.body.scrollTop)-document.documentElement.clientTop);
		var oDivImg=jQuery('#div_img');
		var oDivCursor=jQuery('#div_cursor');
		var TOP=0;
		var LEFT=0;
		var o=oDivCursor[0];
		while(o.parentNode && o.parentNode.nodeType==1){
			TOP+=o.parentNode.offsetTop;
			LEFT+=o.parentNode.offsetLeft;
			o=o.parentNode;
		}
		if(oDivImg.size()>0 && oDivCursor.size()>0){
			var iCursorWidth=oDivCursor[0].offsetWidth;
			var iCursorHeight=oDivCursor[0].offsetHeight;
			var iCursorParentWidth=oDivCursor.parent()[0].offsetWidth;
			var iCursorParentHeight=oDivCursor.parent()[0].offsetHeight;
			if(X<iCursorWidth/2){
				X=iCursorWidth/2;
			}
			if(X>iCursorParentWidth-iCursorWidth/2){
				X=iCursorParentWidth-iCursorWidth/2;
			}
			if(Y<iCursorHeight/2){
				Y=iCursorHeight/2;
			}
			if(Y>iCursorParentHeight-iCursorHeight/2){
				Y=iCursorParentHeight-iCursorHeight/2;
			}
			oDivCursor.css('background-position',Math.round(iCursorWidth/2-X-1)+'px '+Math.round(iCursorHeight/2-Y-1)+'px');
			oDivCursor.css('margin-left', Math.round(X-iCursorWidth/2)+'px');
			oDivCursor.css('margin-top', Math.round(Y-iCursorHeight/2)+'px');
			oDivImg.css('background-position',Math.round(iCursorWidth*1.5-X*iWidth/CursorWidth)+'px '+Math.round(iCursorHeight*1.5-Y*iHeight/CursorHeight)+'px');
		}
	}
}

function changeImage(url_cur,url_img,iNumNew,iType){
	switch(iType){
		case 0:
			jQuery('#img_small_'+iNum).attr('class','img_small');
			jQuery('#img_small_'+iNumNew).attr('class','img_small selected');
			iNum=iNumNew;
			var iTemp=iNum;
		break;
		case 1:
			jQuery('#img_small_'+iNumNew).attr('class','img_small selected');
			var iTemp=iNumNew;
		break;
		case 2:
			if(iNumNew!=iNum){
				jQuery('#img_small_'+iNumNew).attr('class','img_small');
			}
			var iTemp=iNum;
		break;
	}
	jQuery('#div_cursor').css('background','url('+url_cur.replace('/'+iNumNew+'_','/'+iTemp+'_')+') no-repeat 0px 0px');
	jQuery('#div_img').css('background','url('+url_img.replace('/'+iNumNew+'.','/'+iTemp+'.')+') no-repeat 0px 0px');
	jQuery('#div_small').css('background','url('+url_cur.replace('/'+iNumNew+'_','/'+iTemp+'_')+') no-repeat 0px 0px');
}