

//Object.extend(Prototype.Browser, {
//    IE6:     Prototype.Browser.IE && (typeof window.XMLHttpRequest == "undefined"),
 //   IE7:     Prototype.Browser.IE && (typeof window.XMLHttpRequest == "object")
//});

// Color

var ResID=null;

function swapCSS(name) {
	
    if (document.getElementById("thesheet").getAttribute("href") != "style_color_"+name+".css") {
       	// CSS aendern
        document.getElementById("thesheet").href = "style_color_"+name+".css";
        
        // Bilder aendern
        document.getElementById("logoimg").src = "images/frank_meyl-photography_"+name+".gif";
        
        if(document.getElementById("minusimg")) {
            document.getElementById("minusimg").src = "images/minus_"+name+"_n.gif";
            document.getElementById("plusimg").src = "images/plus_"+name+"_n.gif";
        }
        
        
        setColorSession(name);
    }
}

function setColorSession(color) {
	
	var query = "color=" + color;
    var xmlhttp = new ajaxRequest(
        server_root_path+"color.php?color=" + color + "&timestamp=" + new Date().getTime(),
        function()
        {
            var r = xmlhttp.req;
            if (r.readyState==4)
            {
            	pagecolor = r.responseText;
            }
        },
        "GET",
        query,
        ["Content-Type","application/x-www-form-urlencoded"]
    );
    xmlhttp.doRequest();
}

// PicNav
function onOver(id,name) {
	document.getElementById(id).src = "images/"+name+"_"+pagecolor+"_a.gif";
}

function onOut(id,name) {
	document.getElementById(id).src = "images/"+name+"_"+pagecolor+"_n.gif";
}

function onClick(id,name) {
	document.getElementById(id).src = "images/"+name+"_"+pagecolor+"_c.gif";
}

function getScreen() {
	var avail_w = 0;
    var avail_h = 0;
    if( typeof( window.innerWidth ) == "number" ) {
        //Non-IE
        avail_w = window.innerWidth - 80;
        avail_h = window.innerHeight - 70;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in "standards compliant mode"
        //alert("ie");
        avail_w = document.documentElement.clientWidth - 80;
        avail_h = document.documentElement.clientHeight - 70;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        avail_w = document.body.clientWidth - 80;
        avail_h = document.body.clientHeight - 70;
    }
    var avail = new Array();
    avail["w"] = avail_w;
    avail["h"] = avail_h;
    return avail;
}

// Screen
function initScreen(reload) {
	
    var avail = getScreen();
    
    if('.$firsttime.') {
    	//reload = 1;
        //alert("first");
        reload = 1;
    }
    
	setScreenSession(screen.availWidth,screen.availHeight,avail["w"],avail["h"],reload);
}

function setScreenSession(screen_w, screen_h, avail_w, avail_h,reload) {
	var query = "screen_w=" + screen_w + "&screen_h=" + screen_h + "&avail_w=" + avail_w  + "&avail_h=" + avail_h;
    var xmlhttp = new ajaxRequest(
        server_root_path+"screen.php?screen_w=" + screen_w + "&screen_h=" + screen_h + "&avail_w=" + avail_w  + "&avail_h=" + avail_h + "&timestamp=" + new Date().getTime(),
        function()
        {
            var r = xmlhttp.req;
            if (r.readyState==4)
            {
            	if(reload) {
                	document.location.reload(1);
                }
            }
        },
        "GET",
        query,
        ["Content-Type","application/x-www-form-urlencoded"]
    );
    xmlhttp.doRequest();
}

window.onresize = function() {
	if(ResID) clearTimeout(ResID);
	ResID = setTimeout("initScreen(1)",200);
}