var path_img = "../../../../app/webroot/img/";

function check_format()
{
tmpfic = document.getElementById('my_new_img').value ;
candid = tmpfic.split('.');
if (candid[(candid.length)-1] != 'jpg' && candid[(candid.length)-1] != 'gif' )
	{
	alert("Required format : .JPG or .GIF !");
	return false;
	}
	
document.forms['img_item'].submit(); 
}

function Show(div)
{
document.getElementById(div).style.visibility = "visible";
document.getElementById(div).style.display = "block";
}

function Hide(div)
{
document.getElementById(div).style.visibility = "hidden";
document.getElementById(div).style.display = "none";
}

function HideAll(v_arr)
{
// Hide every divs
for (i=0;i<v_arr.length;i++)
	{
	Hide(v_arr[i]);
	}
}

function displayHide(id,v_arr)
{
// Hide every divs
HideAll(v_arr);

// active the right div
Show(id);
}

function fh_img_viewer(id,img)
{
document.img = eval('document.getElementById("'+id+'")');
document.img.src = "./images/"+img;
}

function extendReduce(id,bt)
{
if (document.getElementById(id).style.visibility == "visible")
	{
	Hide(id);
	document.getElementById(bt).src = path_img+"extended.png";
	writecookie(id, 'hide');
	}
	else
	{
	Show(id);
	document.getElementById(bt).src = path_img+"reduce.png";
	writecookie(id, '');
	}
}

function redirect(url)
{
window.location.replace(url);
}

function writecookie(nom, valeur)
{
var argv=writecookie.arguments;
var argc=writecookie.arguments.length;
var expires=(argc > 2) ? argv[2] : null;
var path=(argc > 3) ? argv[3] : null;
var domain=(argc > 4) ? argv[4] : null;
var secure=(argc > 5) ? argv[5] : false;
document.cookie=nom+"="+escape(valeur)+
((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
((path==null) ? "" : ("; path="+path))+
((domain==null) ? "" : ("; domain="+domain))+
((secure==true) ? "; secure" : "");
}
