//INIT

var BASEURL="";
var PEJI="accueil";
var MIRU="index";
var isIE=0;
if (navigator.appName=='Microsoft Internet Explorer') { isIE=1; }

function GetId(id) { return document.getElementById(id); }

function kOnLoadmain(baseurl,peji,miru) {
	BASEURL=baseurl; PEJI=peji; MIRU=miru;
	if (document.forms['f'])  {
		document.forms['f'].elements['q'].focus();
	}
	if(typeof window.kAOnLoad == 'function') {
		kAOnLoad();
	}
}

function kOnLoadpopup(baseurl,peji,miru) {
	BASEURL=baseurl; PEJI=peji; MIRU=miru;
	if(window.location.href == parent.window.location.href) {
		//var str=window.location.href ;
		//window.location.href =str.replace('/popup/','/');
		kAOnLoad();
	}else{
		if(typeof window.kAOnLoad == 'function') {
			kAOnLoad();
		}
		KimPopupResize();
	}
}

function KimPopupResize() {
	var height=$('#kimpop').height();
	var width=$('#kimpop').width();
	if(height > 300 && width > 500) {
		parent.$.fn.colorbox.resize({
			innerHeight:(height+'px'),
			innerWidth:(width+'px')
		});
	}else if(height > 300) {
		parent.$.fn.colorbox.resize({
			innerHeight:(height+'px'),
			innerWidth:('500px')
		});
	}else if(width > 500) {
		parent.$.fn.colorbox.resize({
			innerHeight:('300px'),
			innerWidth:(width+'px')
		});
	}
}


// k

function kLoad(id,href){
	var url=href.pathname;
	if(isIE) url='/'+url;
	if(BASEURL!="/") {
		url=BASEURL+'ajax'+url.replace(BASEURL,'/');
	}else{
		url='/ajax'+url;
	}
	$('#'+id).load(url);
	return false;
}

// coche ou decoche toutes les checkbox du form "liste"
function CheckAll() {
	for (i=0; i < document.liste.elements.length; i++) {
		if (document.liste.elements['checkall'].checked) {
			document.liste.elements[i].checked=1;
		}else{
			document.liste.elements[i].checked=0;
		}
	}
}


