//// PIC SWITCHER 360 ° 
// custom
var active = 0;
var n_img;
var o_img;
function switch_img(active) {
		n_img = clear_img_str(document.getElementById('c_imgt'+active).src);
		o_img = clear_img_str(document.getElementById('c_img').src);
		document.getElementById('c_img').src=n_img;
		document.getElementById('c_imgt'+active).src=o_img+"&w=192&h=114";
}
function clear_img_str(v) {
	if(v.indexOf("&")=="-1") return v;
	return v.substr(0,v.indexOf("&"));
}

function _submit(action,_id,del) {
	var not_submit;
	if(del) {
		if(!confirm('')) not_submit = 1;
	}
	switch(action) {
	case 'save' :   document.form1.target="_self";
					document.form1.action.value="_edit";
					break;
	case 'close' :  document.form1.target="_self";
					document.form1.action.value="";
					break;
	default :		document.form1.target="_self";
					document.form1.action.value=action;
					if(document.form1.sub_id) document.form1.sub_id.value=_id;
					break;
	}
	if(!not_submit)document.form1.submit();
}


// scripts 4 pictures layer
function pop_pic_open(pic_name,print) {
	document.getElementById('pop_pic_div').style['visibility']='visible';
 	document.images['pop_pic_img'].src='http://www.tischlerei-hofer.it/grafiken/loading.gif';
	document.getElementById('pop_pic_img').src=pic_name;
	
	if(print==1) document.getElementById('print_link').style['visibility']='visible';
	else document.getElementById('print_link').style['visibility']='hidden';
	pop_pic_move();
}

function pop_pic_close () {
	document.getElementById('pop_pic_div').style['visibility']='hidden';
}

function pop_pic_resize() {
	document.getElementById('pop_pic_div').style['width']=document.getElementById('pop_pic_img').width+'px';
	document.getElementById('pop_pic_div').style['height']=getpop_pic_div_height()+'px';
}
function pop_pic_move() {
	document.getElementById('pop_pic_div').style['right']='30px';	
	document.getElementById('pop_pic_div').style['top']= '30px';
//	document.getElementById('pop_pic_div').style['top']= getpop_pic_div_top()+'px';	

}

function getpop_pic_div_top() {
	return document.body.scrollTop + 30;
}

function getpop_pic_div_height() {
	return document.getElementById('pop_pic_img').height + document.getElementById('pop_pic_div_content').height;
}


// SEND REG (ajax)
	var params = "";
	var container = "";
	function send_req(container,params) {
		var not_submit;
		// set default container
		//alert(container+"\n"+params);		
		if(!not_submit) {
			new Ajax.Updater(container,'http://www.tischlerei-hofer.it/admin/set_sort.php',{asynchronous:true, 
								evalScripts:true,method:'post',
								parameters:params});
		}
	 // return false;
	}
	
// TOOLTIP
	wmtt = null;
	var position='1';
	function showT(c,position) {
		if(!position) position = 1;
		wmtt = document.getElementById('tooltip'+position);
		wmtt.style.display = "block"
			wmtt.style.left = (m_x + 20) + "px";
			wmtt.style.top = (m_y + 20) + "px";
		wmtt.innerHTML = '<img src="http://www.tischlerei-hofer.it/admin/img/info.png" style="margin-right:5px;" align="left">'+c;
	}
	function hideT() {
		onover = 0;
		if(wmtt) {
			wmtt.style.display = "none";
			wmtt.innerHTML = "";
		}
	}
/// GET X AND Y MAUS
	document.onmousemove = updateMousePosition;
	function updateMousePosition(e) {
		m_x = (document.all) ? window.event.clientX + document.documentElement.scrollLeft : e.pageX;
		m_y = (document.all) ? window.event.clientY + document.documentElement.scrollTop  : e.pageY;
		if (wmtt != null) {
				wmtt.style.left = (m_x + 20) + "px";
				wmtt.style.top 	= (m_y + 20) + "px";
		}
	}

