// JavaScript Documentfunction
function print_r(obj) {
  win_print_r = window.open('about:blank', 'win_print_r');
  win_print_r.document.write('<html><body>');
  r_print_r(obj, win_print_r);
  win_print_r.document.write('</body></html>');
 }

 function r_print_r(theObj, win_print_r) {
  if(theObj.constructor == Array ||
   theObj.constructor == Object){
   if (win_print_r == null)
    win_print_r = window.open('about:blank', 'win_print_r');
   }
   for(var p in theObj){
    if(theObj[p].constructor == Array||
     theObj[p].constructor == Object){
     win_print_r.document.write("<li>["+p+"] =>"+typeof(theObj)+"</li>");
     win_print_r.document.write("<ul>")
     r_print_r(theObj[p], win_print_r);
     win_print_r.document.write("</ul>")
    } else {
     win_print_r.document.write("<li>["+p+"] =>"+theObj[p]+"</li>");
    }
   }
  win_print_r.document.write("</ul>")
 }
function writeCookie(nom, valeur)
	{
	//alert('cookie '+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==0) ? "" : ("; expires="+expires.toGMTString()))+
	((path==null) ? ("; path=/") : ("; path="+path))+
	((domain==null) ? "" : ("; domain="+domain))+
	((secure==true) ? "; secure" : "" );
	}
function getCookieVal(offset)
	{
	var endstr=document.cookie.indexOf (";", offset);
	if (endstr==-1) endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
	}
function readCookie(nom)
	{
	var arg=nom+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while (i<clen)
		{
		var j=i+alen;
		if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
		i=document.cookie.indexOf(" ",i)+1;
		if (i==0) break;
		}
	return null;
	}

function submit_parent(element)
	{
	if(stop_event_all) return;
	if(element.className)
		{
		classnames = element.className.split(' ');
		for(var i = 0; i < classnames.length; i++)
			{
			if(classnames[i] == 'disabled')
				{
				return false;
				}
			}
		}
	submit_name = element.name;
	if(element.nodeName == "A")
		{
		var hidden_input = null;
		if(submit_name != "")
			{
			hidden_input = document.createElement("input");
			hidden_input.type = "hidden";
			hidden_input.name = submit_name;
			hidden_input.value = "1";
			}
		}
	form = null;
	while(element)
		{
		if(typeof(element) != "object") return false;
		if(element.nodeName == 'FORM')
			{
			form = element;
			break;
			}
		element = element.parentNode;
		}
	if(form)
		{
		if(hidden_input)
			{
			form.appendChild(hidden_input);
			}
		if(typeof form.onsubmit == 'function')
			{
			form.onsubmit();
			}
		else
			{
			form.submit();
			}
		}
	}
function WindowSizeWidth()
	{
	return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
	}
function WindowSizeHeight()
	{
	return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
	}
function WindowPosLeft()
	{
	return (document.all)?window.screenLeft:window.screenX;
	//return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
	}
function WindowPosTop()
	{
	return (document.all)?window.screenTop:window.screenY;
	//return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
	}
function WindowPosRight()
	{
	return WindowPosLeft()+WindowSizeWidth();
	}
function WindowPosBottom()
	{
	return WindowPosTop()+WindowSizeHeight();
	}
var stop_event_all = false;
function StopEvent(pE)
	{
	stop_event_all = true;
	if (!pE)
	if (window.event)
	pE = window.event;
	else
	return;
	if (pE.cancelBubble != null)
	pE.cancelBubble = true;
	if (pE.stopPropagation)
	pE.stopPropagation();
	if (pE.preventDefault)
	pE.preventDefault();
	if (window.event)
	pE.returnValue = false;
	if (pE.cancel != null)
	pE.cancel = true;
	return false;
	}
function include_js(file, complete) {
    var html_doc = document.getElementsByTagName('head')[0];
    js = document.createElement('script');
    js.setAttribute('type', 'text/javascript');
    js.setAttribute('src', file);
    html_doc.appendChild(js);

    js.onreadystatechange = function () {
        if (js.readyState == 'complete') {
        }
    }

    js.onload = function () {
		if(complete)
			{
			complete(file);
			}
    }
    return false;
}
