/************************************************************************************************************
Ajax dynamic content
Copyright (C) 2006  DTHMLGoodies.com, Alf Magne Kalleland

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

Dhtmlgoodies.com., hereby disclaims all copyright interest in this script
written by Alf Magne Kalleland.

Alf Magne Kalleland, 2006
Owner of DHTMLgoodies.com


************************************************************************************************************/	

var enableCache = false;
var jsCache = new Array();

var dynamicContent_ajaxObjects = new Array();

function ajax_showContent(divId,ajaxIndex,url)
{
	var targetObj = document.getElementById(divId);
	
	targetObj.innerHTML = dynamicContent_ajaxObjects[ajaxIndex].response;
	if(enableCache){
		jsCache[url] = 	dynamicContent_ajaxObjects[ajaxIndex].response;
	}
	dynamicContent_ajaxObjects[ajaxIndex] = false;
	
	var longueur = document.getElementById('DHTMLSuite_modalBox_contentDiv').innerHTML.length;
	/* alert(longueur);  */
	var h;
	//alert(longueur);
	<!-- EXTREMEMENT MOCHE : fonction à trouver par la suite (calculer chaque élément, etc. cf prototype) -->
	<!-- PS : mais ça marche -->
	<!-- PS2 : (~) -->
	longueur = longueur - 592;
	if(navigator.appName == 'Microsoft Internet Explorer')
	{
		if (longueur < 1000) h = 165;
		else if (longueur < 2000) h = 395;
		else if (longueur < 2500) h = 420;
		else if (longueur < 3000) h = 445;
		else if (longueur < 3500) h = 485;
		else if (longueur < 4000) h = 525;
		else if (longueur < 5000) h = 400;
		else if (longueur < 8700) h = 425;
		else if (longueur < 8800) h = 425;
		else if (longueur < 8900) h = 430;
		else if (longueur < 9000) h = 475;
		else if (longueur < 9100) h = 480;
		else if (longueur < 9200) h = 492;
		else if (longueur < 9300) h = 500;
		else if (longueur < 9400) h = 510;
		else if (longueur < 9500) h = 520;
		else if (longueur < 9600) h = 535;
		else if (longueur < 9700) h = 550;
		else if (longueur < 9800) h = 565;
		else if (longueur < 9900) h = 580;
		else if (longueur < 10000) h = 595;
		else h = 605;		
	}
	else
	{
		if (longueur < 1000) h = 165;
		else if (longueur < 2000) h = 395;
		else if (longueur < 2500) h = 420;
		else if (longueur < 3000) h = 445;
		else if (longueur < 3500) h = 485;
		else if (longueur < 4000) h = 525;
		else if (longueur < 5000) h = 400;
		else if (longueur < 9700) h = 425;
		else if (longueur < 9800) h = 425;
		else if (longueur < 9900) h = 430;
		else if (longueur < 10000) h = 475;
		else if (longueur < 10100) h = 480;
		else if (longueur < 10200) h = 492;
		else if (longueur < 10300) h = 500;
		else if (longueur < 10400) h = 510;
		else if (longueur < 10500) h = 520;
		else if (longueur < 10600) h = 535;
		else if (longueur < 10700) h = 550;
		else if (longueur < 10800) h = 565;
		else if (longueur < 10900) h = 580;
		else if (longueur < 11000) h = 595;
		else h = 605;
	}
	h = h + 70;
	var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
	if (is_chrome) {
		h = h + 50;
	}
	<!-- FIN A NE PAS FAIRE :) -->
	messageObj.setSize(620,h);
	messageObj.__resizeDivs();
	ajax_parseJs(targetObj);

}

function ajax_loadContent(divId,url)
{
	if(enableCache && jsCache[url]){
		document.getElementById(divId).innerHTML = jsCache[url];
		return;
	}
	
	var ajaxIndex = dynamicContent_ajaxObjects.length;
	document.getElementById(divId).innerHTML = '<p align="center" style="margin-top:50px; font-size:14px;"><strong>Nous récupérons les informations de ce membre...</strong><center>';
	dynamicContent_ajaxObjects[ajaxIndex] = new sack();
	dynamicContent_ajaxObjects[ajaxIndex].requestFile = url;	// Specifying which file to get
	dynamicContent_ajaxObjects[ajaxIndex].onCompletion = function(){ ajax_showContent(divId,ajaxIndex,url); };	// Specify function that will be executed after file has been found
	dynamicContent_ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function	
	
	
}

function ajax_parseJs(obj)
{
	var scriptTags = obj.getElementsByTagName('SCRIPT');
	var string = '';
	var jsCode = '';
	for(var no=0;no<scriptTags.length;no++){	
		if(scriptTags[no].src){
	        var head = document.getElementsByTagName("head")[0];
	        var scriptObj = document.createElement("script");
	
	        scriptObj.setAttribute("type", "text/javascript");
	        scriptObj.setAttribute("src", scriptTags[no].src);  	
		}else{
			if(navigator.userAgent.indexOf('Opera')>=0){
				jsCode = jsCode + scriptTags[no].text + '\n';
			}
			else
				jsCode = jsCode + scriptTags[no].innerHTML;	
		}
		
	}

	if(jsCode)ajax_installScript(jsCode);
}


function ajax_installScript(script)
{		
    if (!script)
        return;		
    if (window.execScript){        	
    	window.execScript(script)
    }else if(window.jQuery && jQuery.browser.safari){ // safari detection in jQuery
        window.setTimeout(script,0);
    }else{        	
        window.setTimeout( script, 0 );
    } 
}	
	
	