

// GENERAL VARS AND FUNCTIONS ////////////////////////////////////////////////////////////////////


// general IE catch
var IE = (navigator.appName == "Microsoft Internet Explorer" ? true : false);
        


// general popups
function poponclick(u,n,w,h,s) {
	popwin = window.open(u,n,"width="+w+",height="+h+",toolbar=no,menubar=no,directories=no,status=no,location=no,resize=yes,top=80,left=250,scrollbars="+s);
    popwin.moveTo(250,80);
    popwin.resizeTo(w,h);
    if (window.focus) {
        popwin.focus();
    }
}



// general full window popup
function fullpoponclick(url) {
    if ((Win) && (IE)) {
        fullpop = window.open(url,"fullpop_name","scrollbars=no","fullscreen=yes");
        fullpop.moveTo(0,0);
        fullpop.resizeBy(16,0);
    } else {
        /*fullpop = window.open(url,"fullpop_name","width=1000,height=750,toolbar=no,menubar=no,directories=no,status=no,location=no,resize=yes,scrollbars=no");*/
        fullpop = window.open(url,"fullpop_name","width="+screen.availWidth+",height="+screen.availHeight+",toolbar=no,menubar=no,directories=no,status=no,location=no,resize=yes,scrollbars=no");
        fullpop.moveTo(0,0);
        fullpop.resizeTo(screen.availWidth,screen.availHeight);
    }
    if (window.focus) {
        fullpop.focus();
    }
}



// general buttons rollovers
function rollon(o) {
    offPath=o.src;
    newPath=offPath.replace(/_off/, "_on");
    o.src=newPath;  
}
function rollonIEpng(o) {
    offPath=o.style.filter;
    newPath=offPath.replace(/_off/, "_on");
    o.style.filter=newPath;
}
function rolloff(o) {
    onPath=o.src;
    newPath=onPath.replace(/_on/, "_off");
    o.src=newPath;
}
function rolloffIEpng(o) {
    onPath=o.style.filter;
    newPath=onPath.replace(/_on/, "_off");
    o.style.filter=newPath;
}



// general text size function
function changefontsize(id, size) {
document.getElementById(id).style.fontSize = size + "px";
}



// Ajaxing
var Xhro = null;
var Id;

function XHR(a,b,c,d,e,f,g) {
	if (a == 'spec') {
		XHRspec(b,c,d,e);
	} else if (a == 'onel') {
		XHRonel(b,c,d,e,f,g);
	}
}

// general 'one element' ajaxing
function XHRonel(id,type,file,width,height,bgcolor) {
	Id = id;
// Create the XML request object
    if(window.XMLHttpRequest) { // Firefox, Opera...
		Xhro = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // MSIE
		Xhro = new ActiveXObject("Microsoft.XMLHTTP");
    } else {
		alert('Sorry, your browser does not support the data display system implemented here. Please update there :\n http://www.mozilla.org/products/firefox/');
		return; // Failed to create the request
	}

// Make the request
	Xhro.onreadystatechange = handleResponseText;
    Xhro.open ('GET','./general_ajaxonel.php5?id='+id+'&type='+type+'&file='+file+'&width='+width+'&height='+height+'&bgcolor='+bgcolor,true); // true for asynchronous
    Xhro.send (null); // null cuz GET method
}

// specific process ajaxing
function XHRspec(url,status,lang,id) {
	Id = id;
// Create the XML request object
    if(window.XMLHttpRequest) { // Firefox, Opera...
		Xhro = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // MSIE
		Xhro = new ActiveXObject("Microsoft.XMLHTTP");
    } else {
		alert('Sorry, your browser does not support the data display system implemented here. Please update there :\n http://www.mozilla.org/products/firefox/');
		return; // Failed to create the request
	}

// Make the request
	Xhro.onreadystatechange = handleResponseText;
    Xhro.open ('GET',url+'?status='+status+'&lang='+lang+'&id='+id,true);
    Xhro.send (null); // null cuz GET method
}

function handleResponseText() { // function to handle changed request states
	if (Xhro.readyState == 4) {
		//doSomethingWithData(Xhro.responseXML.getElementsByTagName('quote')[0].firstChild.data); // Retrieve the data between the <quote> tags
		document.getElementById(Id).innerHTML = Xhro.responseText;
	}
}

function xhrdivEmptier(id,yo) {
	document.getElementById(id).innerHTML = yo;
}






// SPECIFIC VARS AND FUNCTIONS ////////////////////////////////////////////////////////////////////


// managing centering in frame window
function manageCentering(){

	var framewinW = 0, framewinH = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		framewinW = window.innerWidth;
		framewinH = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		framewinW = document.documentElement.clientWidth;
		framewinH = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		framewinW = document.body.clientWidth;
		framewinH = document.body.clientHeight;
	}
	
    if (framewinW <= 820) { // stop centering and incidentally show scrollbars
		document.getElementById("container").style.marginLeft = "0px";
		document.getElementById("container").style.left = "0px";
	} else {
		document.getElementById("container").style.marginLeft  = "-410px";
		document.getElementById("container").style.left = "50%";
	}
	
}






