﻿function $(o) {
	return document.getElementById(o);
}	

function Xfer(o) {
	o = $(o);
	o.disabled = true;
	o.value=Xfer_transfer;
}

function SelectAllText(o) {
	o.focus();
	o.select();
}

function CtrlC(o) {
	var v=$(o);
	v.focus();
	v.select();
		
	t=v.createTextRange();
	t.execCommand("Copy");
}

function ShowHide(o) {
	if($(o).style.display=='')
		$(o).style.display='none';
	else
		$(o).style.display='';
}

function showMail(name, mail, domain) {
	if(name.length == 0) {name =  mail + '@' + domain;	}
	document.write('<a href="mailto:' + mail + '@' + domain + '">' + name + '</a>');
}

function click_submit(k){
	w=$(k);
	w.click();
	w.focus();
}

function chkExt(o) {
	var ext = o.value.substr(o.value.length - 3,3).toLowerCase();
	switch (ext) {
	case 'bmp':
	case 'gif':
	case 'jpg':
	case 'peg':
	case 'png':
	case 'tif':
	case 'iff':
		$('upbutton').disabled=false;
		$('upbutton').value=chkExt_host;
		break;
	case '':
		$('upbutton').disabled=true;
		$('upbutton').value=chkExt_select;
		break;
	default:
		$('upbutton').disabled=true;
		$('upbutton').value=chkExt_type;
		break;
	}
}

var imgWidth = 1024;
var imgHeight = 768;

function WindowWidth() {
	if ( typeof window.innerWidth != 'undefined' )	return window.innerWidth;
	if ( document.documentElement && typeof document.documentElement.clientWidth!='undefined' && document.documentElement.clientWidth != 0 ) return document.documentElement.clientWidth;
	if ( document.body && typeof document.body.clientWidth != 'undefined' )	return document.body.clientWidth;
	return -1;
}

function imgResize(o) {	
	o=$('zodimage');
	if (o.width ==  imgWidth){
		o.width = WindowWidth() * 0.95;
	}
	else{
		o.width = imgWidth;
	}
}

function imgInit(o) {
	o=$('zodimage');
	imgWidth = o.width;
	imgHeight = o.height;

	if (imgWidth > WindowWidth()-10)
		imgResize();
}


function SetCookie(name, value) {
	var argv = SetCookie.arguments;
	var argc = SetCookie.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 = name + "=" + escape(value) +
	((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
	((path==null) ? "" : ("; path="+path))+
	((domain==null) ? "" : ("; domain="+domain))+
	((secure==true) ? "; secure" : "");
}

function setLang(lcid) {
	var d = new Date();
	d = new Date(d.getFullYear()+1, d.getMonth(), d.getDay());

	SetCookie("lcid", lcid, d, null, ".zod.fr");
	window.location.reload(true);
}