// JavaScript Document


function ajax_action (url, _res)
{
		//alert(url) ;
		
		if(window.XMLHttpRequest) // Firefox
			xhr_object = new XMLHttpRequest();
		else if(window.ActiveXObject) // Internet Explorer
			xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		else 
			return;
		
		xhr_object.open("GET", url);		
		
		xhr_object.onreadystatechange = function handleHttpResponse() {
			if (xhr_object.readyState == 4) {
				var res = $(_res) ;
				//alert(xhr_object.responseText) ;
				if (res) 	res.innerHTML  =  xhr_object.responseText;
			}
		}
		xhr_object.send(null);		
}


function ajax_insert(pid, oid, _vid, _res)
{
	var vid = document.getElementById(_vid) ;
	if (!vid) return ;
	//alert(vid.value) ;
	if (!pid ||!oid || !vid.value) return ;
	
	url = "categories_ajax.php?action=option_insert&pid=" + pid + "&oid="  + oid+"&vid=" + vid.value ;
	ajax_action (url, _res) ;
}

function ajax_delete(pid, oid, _vid, _res)
{
	var vid = document.getElementById(_vid) ;
	if (!vid) return ;
	//alert(vid.value) ;
	if (!pid ||!oid || !vid.value) return ;
	
	url = "categories_ajax.php?action=option_delete&pid=" + pid + "&oid=" + oid +"&vid=" + vid.value ;
	ajax_action (url, _res) ;
}


function js_image_detail (src,pid , _res) {
		href = ' href="product_zoom.php?products_id='+pid+'" title="" ' 
			+' onclick="Modalbox.show(this.href, {title:\'\',padTop:0, width:518, closeString:\'Fermer\'});return false;" ' ;
			
		js_image (src, " width='312' height='312' hspace='2' border='0' ", href , _res) ;
}

function js_image (src, param, href, _res ) {
	
		var res = document.getElementById (_res); if (!res) return ;
		
		html = "<img src='"+src+"' "+param +">" ;
		
		if (href !='')
			html = "<a "+href +">" + html + "</a>" ;
			
		res.innerHTML = html;
}

var zoomOverTimer	= 0 ;
var zoomOutTimer	= 0 ;

function zoom_over (ms, href, title) {
	if (zoomOverTimer)	 return;
	zoomOverTimer = setInterval ("delay_over('"+href+"','"+title+"')", ms) ;
	
}
		function delay_over (href, t) {
			
			if (zoomOverTimer)	{ 
				
				clearInterval(zoomOverTimer) ;
				zoomOverTimer =0 ;
			}
			Modalbox.show(href, {title:'',padTop:122, width:550, closeString:'Fermer'}) ;
			
		}


function zoom_out (ms) {
	//if (zoomOverTimer)	  clearInterval(zoomOverTimer) ;
	if (zoomOutTimer)	return;	
	zoomOutTimer = setInterval ("delay_out()", ms) ;
	
}
		function delay_out () {	
			
			if (zoomOverTimer)	clearInterval(zoomOverTimer) ;zoomOverTimer = 0;			
			if (zoomOutTimer)	clearInterval(zoomOutTimer) ; zoomOutTimer =  0;
		}
