try {
var loupiote_debug = 0;

function debug_alert_no_ping(str)
{
    if (loupiote_debug) {
        alert(str);
    }
}

function debug_alert(str)
{
    if (loupiote_debug) {
        alert(str);
    }
    //loupiote_ping_async('debug-alert-' + escape(str));
    loupiote_ping_async('debug-alert-' + str);
}

function debug_show(variable, str)
{
    var value;
    if (loupiote_debug) {
	if (typeof variable == 'undefined') {
	    alert(variable + ' is undefined');
	} else {
	    if (typeof 'str' == 'undefined') {
		str = '';
	    }
	    if (!str) {
		str = '';
	    }
	    if (str) {
		str = ' ' + str;
	    }
	    alert(variable + str + ' = "' + eval(variable) + '"');
	}
    }
}

try {
    if (0 && (REMOTE_ADDR == '167.117.144.7' || (0 && REMOTE_ADDR == SERVER_ADDR && String(document.location.href).match(/(search|download)\.cgi/))) && loupiote_page_type != 'framed') {

    loupiote_debug = 1;
    debug_alert_no_ping('loupiote_debug = 1');
}
} catch (err) {
    debug_alert_no_ping('x=debug-catch-' + err);
}



	} catch (err) {debug_alert('x=catch-all-1-' + err);}
try {

//debug_alert('loading ajax.js');

loupiote_ie6 = 0;

if (0) {
    try {
	loupiote_ie6 = 0;
	
	//    if (window.external && typeof ('window.XMLHttpRequest') != 'undefined') {
	// Safari/525.20.1 does not have window.external ?
	//if (typeof('XMLHttpRequest') != 'undefined') {
	new XMLHttpRequest(); 
	//}
	
    } catch (err) {
	debug_alert('new XMLHttpRequest failed: ' + err);
	loupiote_ie6 = 1;
    }
    if (typeof('loupiote_ie6') == 'undefined') {
	loupiote_ie6 = 1;
    }
}


function loupiote_url_is_local(url) {
    //    if (String(url).match(/^http:\/\/[-a-z.]*loupiote\.com\/facebook$/i)) {
    //	return false;
    //}

    if (String(url).match(/^http:\/\/blog\.loupiote/i)) {
       	return false;
    }

    if (String(url).match(/^(http:\/\/[-a-z.]*(loupiote(-photography)?\.com|playa-dust\.com|dog-meat\.net|pockettv\.com|mpegtv\.com))/i)) {
       	return true;
    } else {
	return false;
   }
}


function loupiote_create_XMLHttpRequest()
{
    if (typeof loupiote_url_is_local != 'undefined' && ! loupiote_url_is_local(location.href)) {
//    if (! String(location.href).match(/^(http:\/\/[-a-z.]*(loupiote\.com|playa-dust\.com|dog-meat\.net))/)) {
       	return 0;
    }
    //    if (loupiote_ie6) {
	// ajax call is causing ie6 to abort!
	//debug_alert_no_ping('ie6');
	//return 0;
    //}

    try {
    // Provide the XMLHttpRequest class for IE 5.x-6.x:
    if(typeof XMLHttpRequest == "undefined" ) {
        //  alert('XMLHttpRequest not defined');
        try { 
            //  alert('trying Msxml2.XMLHTTP.6.0');
            return new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch(e) {
            try {
                //   alert('trying Msxml2.XMLHTTP.3.0');
                return new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch(e) {
                try {
                    //    alert('trying Msxml2.XMLHTTP');
                    return new ActiveXObject("Msxml2.XMLHTTP") } catch(e) {
                    try {
                        //     alert('trying Microsoft.XMLHTTP');
                        return new ActiveXObject("Microsoft.XMLHTTP") } catch(e) {
                        //  throw new Error( "This browser does not support XMLHttpRequest." )
			//                        if( typeof XMLHttpRequest != "undefined" ) {
                            //         alert('new XMLHttpRequest');
			//                            return new XMLHttpRequest(); 
			//                        } else {
			loupiote_ie6 = 1;
			debug_alert_no_ping('loupiote_create_XMLHttpRequest failed');
                            return 0;
			    //                        }
                    }
                }
            }
        }
    } else {
        //alert('new XMLHttpRequest');
        return new XMLHttpRequest(); 
    }
    } catch (err) {
	debug_alert_no_ping('loupiote_create_XMLHttpRequest error: ' + err);
	loupiote_ie6 = 1;
    }
}


function loupiote_makeRequest(onreadystatechange_callback, url, post_data, async, method) { 

    try {

    if (typeof async == "undefined") {
	async = true;
    }

    if (typeof method == "undefined") {
	if (post_data) {
	    method = 'POST';
	} else {
	    method = 'GET';
	}
    }

    //    alert(location.href);

    if (typeof loupiote_url_is_local != 'undefined' && !loupiote_url_is_local(document.location.href)) {
//    if (! String(location.href).match(/^(http:\/\/[a-z.]*(loupiote\.com|playa-dust\.com|dog-meat\.net))/)) {
	//loupiote_ping_async('loupiote_makeRequest-cross-url-not-local-' + document.location.href);
	debug_alert_no_ping('loupiote_makeRequest: url not local ' + document.location.href);
       	return null;
    }

    try {
    // (poor) work around spurious security warning in IE7 when accessing our domain
    // with ajax from a frame while the parent frame is another domain
    if (window.parent && window.parent.location && window.parent.location.href && ! loupiote_url_is_local(window.parent.location.href)) {

	//loupiote_ping_async('loupiote_makeRequest-cross-domain-warning-' + window.parent.location.href);
	debug_alert_no_ping('loupiote_makeRequest: cross domain warning');
       	return null;
    }
    } catch (err) {
	debug_alert_no_ping('loupiote_makeRequest: cross domain test failed, error: ' + err);
    }

    //alert(0);
    var http_request = loupiote_create_XMLHttpRequest(); 


    if (!http_request) { 
        //      alert('Giving up :( Cannot create an XMLHTTP instance'); 
	debug_alert_no_ping('loupiote_makeRequest: http_request not available');
        return null; 
    }

    http_request.onreadystatechange = function() {
	if (onreadystatechange_callback) {
	    onreadystatechange_callback(http_request);
	}
    };

    http_request.open(method, url, async); 
    if (method == 'POST') {

        http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        http_request.send(post_data); 
    } else {
        http_request.send(null); 
    }

    } catch (err) {
	//loupiote_ping_async('loupiote_makeRequest-failed-' + err);
	debug_alert_no_ping('loupiote_makeRequest failed, error: ' + err);
	return null;
    }

    return http_request;
}

function loupiote_get_url(url) {
    try {

	//debug_alert('loupiote_get_url ' + url);

    var callback = function(req) {
	//loupiote_ping('loupiote_get_url req.readyState = ' + req.readyState + ', req.status = ' + req.status + ', req.statusText = ' + req.statusText + ', req.responseText = ' + req.responseText);
    }
    var req;

    //    alert(domain);

    //req = loupiote_makeRequest(callback, url, '', false, 'GET');
    req = loupiote_makeRequest(null, url, '', false, 'GET');

    if (!req) {
	debug_alert('loupiote_get_url-failed ' + url);
	return '';
    }
	
    if (req.status == 200) {
	//debug_alert('loupiote_get_url returns: ' + req.responseText);
	return req.responseText;
    } else {
	debug_alert('loupiote_get_url-failed-status-' + req.status + '-' + req.statusText + ', url: ' + url);
	return '';
    }

    } catch (err) {
	//loupiote_ping_async('loupiote_get_url-failed-catch-' + err);
	debug_alert('loupiote_get_url error: ' + err + ', url: ' + url);
	return '';
    }
}

function loupiote_get_url_async(url, callback) {
    try {

	//debug_alert('loupiote_get_url_async ' + url);

    var req;

    //    alert(domain);
	//req = loupiote_makeRequest(callback, url, '', false, 'GET');
    req = loupiote_makeRequest(callback, url, '', true, 'GET');

    if (!req) {
	//loupiote_ping_async('loupiote_get_url_async-failed');
	debug_alert('loupiote_get_url_async failed');
    } else {
	//loupiote_ping_async('loupiote_get_url_async-success');
	//debug_alert('loupiote_get_url_async success');
    }
    } catch (err) {
	//loupiote_ping_async('loupiote_get_url_async-catch-failed-' + err);
	debug_alert('loupiote_get_url_async error: ' + err);
    }
}

function loupiote_ping_async(query_string) {
    //        return;
    //    if (loupiote_ie6) {
	// this asynchronous ajax call is causing ie6 to abort!
    //	return;
    //    }

    //debug_alert('ping_async ' + query_string);

    var domain = '';
    if (document.domain) {
	domain = 'http://' + document.domain;
    }

    //debug_alert('loupiote_ping_async domain = ' + domain);

    //var callback = function(req) {
    //loupiote_ping('req.readyState = ' + req.readyState + ', req.status = ' + req.status + ', req.statusText = ' + req.statusText + ', req.responseText = ' + req.responseText);
    //}

    //    alert(domain);
    try {
//	loupiote_makeRequest(null, domain + '/cgi-bin/ping.cgi?x=' + escape(query_string), '', true, 'HEAD');
	loupiote_makeRequest(null, domain + '/cgi-bin/ping.cgi?x=' + query_string, '', true, 'HEAD');
	// loupiote_makeRequest(0, domain + '/cgi-bin/ping.cgi?' + query_string, '', true, 'GET');
	// loupiote_makeRequest(0, '/cgi-bin/ping.cgi?' + query_string, '', true, 'HEAD');
    } catch (err) {
	debug_alert_no_ping('ping_sync error: ' + err);
    }
}

function loupiote_ping(query_string) {
    //       return;
    //    alert();

    //debug_alert('ping ' + query_string);

    var domain = '';
    if (document.domain) {
	domain = 'http://' + document.domain;
    }

    //debug_alert('loupiote_ping domain = ' + domain);

    try {
	//    loupiote_test_url_synchronously('http://www.loupiote.com/cgi-bin/ping.cgi?' + query_string);
	loupiote_makeRequest(0, domain + '/cgi-bin/ping.cgi?x=' + escape(query_string), '', false, 'HEAD');
	// loupiote_makeRequest(0, domain + '/cgi-bin/ping.cgi?' + query_string, '', false, 'GET');
	// loupiote_makeRequest(0, '/cgi-bin/ping.cgi?' + query_string, '', false, 'HEAD');
    } catch (err) {}
}

function loupiote_load_script_new(url, callback, element, onerror){
    //return;

    //debug_alert('loupiote_load_script_new ' + url);
    try {

	if (!element) {
	    element = document.getElementsByTagName("head")[0];
	}
	//    alert(1);
	var script = document.createElement("script")
	script.type = "text/javascript";
	script.async = true;

	//if (callback != null) {
	if (1) {

	    if (script.readyState){  //IE
		script.onreadystatechange = function(){
		    try {
		    //debug_alert('loupiote_load_script_new ' + url + ' onreadystatechange = ' + script.readyState);
		    if (script.readyState == "loaded" ||
			//              script.readyState == "interactive" ||
			script.readyState == "complete"){

			script.onreadystatechange = null;
			script.onload = null;
			//                  loupiote_ping_async('activation-in-onreadystatechange-' + script.readyState);

			//debug_alert('loupiote_load_script_new ' + url + ' loaded, calling callback');
			if (callback) {
			    callback(script);
			}
			if (script.retry) {
			    loupiote_ping_async('loupiote_load_script_new-onreadystatechange-retry-' + script.retry + '-' + url);
			}
		    }
		    } catch (err) {
			debug_alert('loupiote_load_script_new-onreadystatechange-catch-' + url + '-err-' + err);
		    }
		};
	    }
	    //Others
	    if (!isdefined('script.onload')) {
		//      loupiote_ping_async('activation-onload-undefined');
	    }
	    script.onload = function(obj){
		try {
		if (script.readyState){  //IE or Opera
		    //              loupiote_ping_async('activation-onload-over-readstate');
		    script.onreadystatechange = null;
		}
		script.onload = null;
		//          loupiote_ping_async('activation-in-onload');

       		//debug_alert('loupiote_load_script_new onload ' + url);
		if (callback) {
		    callback(script);
		}
		if (script.retry) {
		    loupiote_ping_async('loupiote_load_script_new-onload-retry-' + script.retry + '-' + url);
		}
		} catch (err) {
		    debug_alert('loupiote_load_script_new-onload-catch-' + url + '-err-' + err);
		}
	    };
	    script.onerror = function(event){
		try {
		//script.onerror = null;
		//          loupiote_ping_async('activation-in-onload');

		var dump_event = '';
		if (0) {
		dump_event = ' dump-event: ';
		for (var key in event) {
		    		    if (event.hasOwnProperty(key)) {
			/* useful code here */
			//debug_alert(key + '=' + event[key]);
			dump_event += key + '=' + event[key] + ',';
			}
		}
		}
       		debug_alert('loupiote_load_script_new onerror ' + url + dump_event);

		if (onerror) {
		    onerror(script, event);
		}
		loupiote_load_script(url, callback);

		if (0) {
		    if (0) {
			var dump_string = '';
			for (var key in script) {
			    if (script.hasOwnProperty(key)) {
				/* useful code here */
				//debug_alert(key + '=' + event[key]);
				dump_string += key + '=' + script[key] + ',';
			    }
			}
		    }
		    if (!script.retry) {
			script.retry = 0;
		    }
		    loupiote_ping_async('loupiote_load_script_new-onerror-retry-' + script.retry + '-' + url);
		    
		    if (script.retry < 5) {
			if (1) {
			    var new_script = document.createElement("script")
				new_script.type = "text/javascript";
			    new_script.onreadystatechange = script.onreadystatechange;
			    new_script.onload = script.onload;
			    new_script.onerror = script.onerror;
			    new_script.retry = script.retry + 1;
			    new_script.url = url;
			    element.removeChild(script);
			    delete script;
			    script = new_script;
			    element.appendChild(script);
			} else {
			    script.url = url;
			}
			loupiote_ping_async('loupiote_load_script_new-onerror-retrying-' + url);
		    }
		}
		} catch (err) {
		    debug_alert('loupiote_load_script_new-onerror-catch-' + url + '-err-' + err);
		}
	    };
	}
	script.src = url;
	element.appendChild(script);

    } catch (err) {
	//loupiote_ping_async('catch-load-script-' + err);
	debug_alert('loupiote_load_script_new failed: ' + url + ' error: ' + err);
    }

}

function loupiote_load_script(url, callback) {

//    debug_alert('loupiote_load_script ' + url);

    try {

    var script = document.createElement("script");
    script.type = 'text/javascript';
    script.src = url;
    script.async = false;
    script.onerror = function(event){
	script.onload = null;
       	debug_alert('loupiote_load_script onerror ' + url);
    };
    script.onload = function(obj){
	try {
		script.onload = null;
		if (callback) {
		    callback(script);
		}
//       		debug_alert('loupiote_load_script onload ' + url);
	} catch (err) {
		    debug_alert('loupiote_load_script-onload-catch-' + url + '-err-' + err);
	}
    };
    document.getElementsByTagName('head')[0].appendChild(script);

    if (script.onload) {
        script.onload(script);
    }    
    //debug_alert('loupiote_load_script loaded ' + url);
    //    alert('loading ' + url);

    } catch (err) {
	//loupiote_ping_async('catch-load-script-' + err);
	debug_alert('loupiote_load_script failed: ' + url + ' error: ' + err);
    }

}


//debug_alert('loaded ajax.js');


        } catch (err) {debug_alert('x=catch-all-2-' + err); loupiote_ie6 = 1;}
try {
/*
Script Name: Javascript Cookie Script
Author: Public Domain, with some modifications
Script Source URI: http://tech.ratmachines.com/downloads/browser_detection.php
Version 1.0.0
Last Update: 30 May 2004

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.  
*/

// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	
	var value;
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	
//	alert("Get_Cookie(" + name + ")");
//	alert("document.cookie: " + document.cookie);

	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
	{
//		alert("Get_Cookie: returns null");
		return null;
	}
	if ( start == -1 ) {
//		alert("Get_Cookie: returns null");
		return null;
	}
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	value = unescape( document.cookie.substring( len, end ) );
//	alert("Get_Cookie: returns " + value);
	return value;
}

/*
only the first 2 parameters are required, the cookie name, the cookie
value. Cookie time is in milliseconds, so the below expires will make the 
number you pass in the Set_Cookie function call the number of days the cookie
lasts, if you want it to be hours or minutes, just get rid of 24 and 60.

Generally you don't need to worry about domain, path or secure for most applications
so unless you need that, leave those parameters blank in the function call.
*/
function Set_Cookie( name, value, expires, path, domain, secure ) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	// if the expires variable is set, make the correct expires time, the
	// current script below will set it for x number of days, to make it
	// for hours, delete * 24, for minutes, delete * 60 * 24
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
//		expires = expires * 1000 * 60;
	}
	//alert( 'today ' + today.toGMTString() );// this is for testing purpose only
	var expires_date = new Date( today.getTime() + (expires) );
	//alert('expires ' + expires_date.toGMTString());// this is for testing purposes only

	document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
//	alert("Set_Cookie " + document.cookie);// this is for testing purposes only
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

// test if cookies are available
function Have_Cookies(domain) {
	var value;
	Set_Cookie( 'test', 'none', '', '/', domain, '' );
	// if Get_Cookie succeeds, cookies are enabled, since
	//the cookie was successfully created.
	if ( Get_Cookie( 'test' ) ) {
		value = 1;
	} else {
		value = 0;
	}
	Delete_Cookie( 'test', '/', domain);
	return value;
}


	} catch (err) {loupiote_ping_async('x=catch-all-3-' + err);}
try {
function getQuerystring(key, default_)
{
    if (default_==null) default_=""; 
    key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
    //var qs = regex.exec(window.location.href);
    var qs = regex.exec(document.location.href);
    if(qs == null)
        return default_;
    else
        return qs[1];
}

	} catch (err) {loupiote_ping_async('x=catch-all-7-' + err);}
try {
var loupiote_layout_light = 0;
var loupiote_layout_light_wide = 0;
var loupiote_browser_width = 0;
var loupiote_screen_width = 0;


function loupiote_set_screen_width_and_browser_width()
{
    //loupiote_browser_width = 0;
    //loupiote_screen_width = 0;

    try {
	var sw = 0;
	var saw = 0;
	try {
	    saw = screen.availWidth;
	} catch (err) {
	    loupiote_ping_async('screen-width-failed-screen.availWidth');
	}
	if (saw) {
	    //loupiote_ping_async('screen-width-screen.availWidth-' + saw);
	}
	if (!saw) {
	    //loupiote_ping_async('screen-width-failed-zero-screen.availWidth');
	}
	
	try {
	    sw = screen.width;
	} catch (err) {
	    loupiote_ping_async('screen-width-failed-screen.width');
	}
	if (sw) {
	    //loupiote_ping_async('screen-width-screen.width-' + sw);
	}
	if (!sw) {
	    //loupiote_ping_async('screen-width-failed-zero-screen.width');
	}
	if (!saw) {
	    saw = sw;
	}
	if (!saw) {
	    //loupiote_ping_async('screen-width-failed-all');
	}
	loupiote_screen_width = saw;
	
	var w = 0;
	try {
	    w = window.innerWidth;
	} catch (err) {
	    //loupiote_ping_async('browser-width-failed-window.innerWidth');
	}
	if (w) {
	    //loupiote_ping_async('browser-width-using-window.innerWidth-' + w);
	} else {
	    //loupiote_ping_async('browser-width-failed-zero-window.innerWidth');
	}
	if (!w) {
	    try {
		w = document.documentElement.clientWidth;
	    } catch (err) {
		//loupiote_ping_async('browser-width-failed-document.documentElement.clientWidth');
	    }
	}
	if (w) {
	    //loupiote_ping_async('browser-width-using-document.documentElement.clientWidth-' + w);
	} else {
	    //loupiote_ping_async('browser-width-failed-zero-document.documentElement.clientWidth');
	}
	if (!w) {
	    try {
		w = document.body.clientWidth;
	    } catch (err) {
		//loupiote_ping_async('browser-width-failed-document.body.clientWidth');
	    }
	}
	if (w) {
	    //loupiote_ping_async('browser-width-using-document.body.clientWidth-' + w);
	} else {
	    //loupiote_ping_async('browser-width-failed-zero-document.body.clientWidth');
	}
	if (!w) {
	    try {
		w = document.body.offsetWidth;
	    } catch (err) {
		//loupiote_ping_async('browser-width-failed-document.body.offsetWidth');
	    }
	}
	if (w) {
	    //loupiote_ping_async('browser-width-using-document.body.offsetWidth-' + w);
	} else {
	    //loupiote_ping_async('browser-width-failed-zero-document.body.offsetWidth');
	}
	if (w) {
	    loupiote_browser_width = w;
	} else {
	    //loupiote_ping_async('browser-width-failed-all');
	    if (loupiote_screen_width) {
		// this happens when our pages are loaded in an iframe, e.g. the psa-replacement ads
		//loupiote_ping_async('browser-width-falling-back-to-screen-width-' + loupiote_screen_width);
	    }
	    //loupiote_browser_width = loupiote_screen_width;
	}
	//if (!loupiote_screen_width) {
	    //loupiote_screen_width = loupiote_browser_width;
	//}
	if (loupiote_browser_width > loupiote_screen_width) {
	    //loupiote_ping_async('browser-width-larger-than-screen-width-' + loupiote_browser_width + '-' + loupiote_screen_width);
	} else {
	    //loupiote_ping_async('browser-width-smaller-than-screen-width-' + loupiote_browser_width + '-' + loupiote_screen_width);
	}
	//debug_alert(loupiote_browser_width + '-' + loupiote_screen_width);

    } catch (err) {
	debug_alert('loupiote_set_screen_width_and_browser_width-failed-catch-err-' + err);
	loupiote_ping_async('loupiote_set_screen_width_and_browser_width-failed-catch-err-' + err);
    }
}

function loupiote_set_layout_light()
{
    //loupiote_layout_light = 0;
    //loupiote_layout_light_wide = 0;

    try {

	if (loupiote_screen_width && loupiote_screen_width < 728) {
	//if (loupiote_screen_width && loupiote_screen_width <= 510) {
	//if (loupiote_screen_width && loupiote_screen_width <= 840) {
	//if (loupiote_screen_width && loupiote_screen_width < 800) {
	    loupiote_layout_light = 1;
	} else {
	    loupiote_layout_light = 0;
	}

	// those user-agents should be treated "light" if screen width unknown (0).
	if (String(navigator.userAgent).match(/(iPod|iPhone|Android|IEMobile|Opera Mini|Opera Mobi|^LGE-|BlackBerry|Nokia|SonyEricsson|Mobile|SAMSUNG|^LG-|T-Mobile|^Cricket|KDDI-|SymbOS|^sam-)/i)
	    && !String(navigator.userAgent).match(/(iPad)/i)) {

	    // those user-agents should be treated "light" regardless of the screen width (i.e. even if >= 728)
	    if (!loupiote_screen_width || String(navigator.userAgent).match(/(sam-r900|Googlebot-Mobile|iPhone|IEMobile|BlackBerry)/i)) {
	    //if (1) {
		if (!loupiote_layout_light) {
		    loupiote_layout_light = 1;
		    loupiote_ping_async('layout-light-overwrite-1-' + loupiote_screen_width + '-by-user-agent-' + String(navigator.userAgent));
		}
	    }
	    // if screen width is known, we rely on it to decide if they are "light"
	    if (!loupiote_layout_light) {
		loupiote_ping_async('layout-light-kept-0-' + loupiote_screen_width + '-for-user-agent-' + String(navigator.userAgent));
	    }

	// those user-agents should be treated "heavy" regardless of the screen width (i.e. even if >= 728)
	} else if (loupiote_layout_light && String(navigator.userAgent).match(/(^Mozilla\/.* \(compatible; MSIE .\.0|^Mozilla\/.* \(Windows; U; Windows NT|Nintendo Wii|^Opera\/.* \(Windows NT|Media Center PC)/i)) {
	    loupiote_layout_light = 0;
	    loupiote_ping_async('layout-light-overwrite-0-' + loupiote_screen_width + '-by-user-agent-' + String(navigator.userAgent));
	}
	if (loupiote_layout_light && String(navigator.userAgent).match(/Mac OS X/) && !String(navigator.userAgent).match(/like Mac OS X/)) {
	    // this is a mac, but not a mobile apple device
	    loupiote_layout_light = 0;
	    loupiote_ping_async('layout-light-overwrite-0-' + loupiote_screen_width + '-by-user-agent-' + String(navigator.userAgent));
	}

	if (loupiote_debug) {	
	    //loupiote_layout_light = 1;
	}
	    var query_string_light = getQuerystring('light');
	    if (query_string_light == '0' || getQuerystring('fotomoto') == '1') {
	    loupiote_ping_async('layout-light-overwrite-0-' + loupiote_screen_width + '-by-query-string');
	    loupiote_layout_light = 0;
	}
	if (query_string_light == '1') {
	    loupiote_ping_async('layout-light-overwrite-1-' + loupiote_screen_width + '-by-query-string');
	    loupiote_layout_light = 1;
	}

	if (loupiote_layout_light && loupiote_screen_width && loupiote_screen_width >= 600) {
	    // For wide mobile decices like iPad
	    //loupiote_ping_async('layout-light-wide-' + loupiote_screen_width);
	    loupiote_layout_light_wide = 1;

	    if ((String(navigator.userAgent).match(/(BlackBerry)/i) || query_string_light == '1')) {
		// useful for testing admob mobile ads with FF, since we use an adsense banner
		// when loupiote_layout_light_wide
		loupiote_layout_light_wide = 0;
		loupiote_ping_async('layout-light-wide-overwrite-0-' + loupiote_screen_width + '-by-user-agent-' + String(navigator.userAgent));
	    }

	} else {
	    loupiote_layout_light_wide = 0;
	}
	if (loupiote_debug) {
	    loupiote_layout_light_wide = 0;
	    debug_show('loupiote_layout_light_wide');
	}

	//debug_alert('loupiote_layout_light = ' + loupiote_layout_light);
	//if (loupiote_layout_light) {
	//loupiote_ping_async('layout-light-' + loupiote_layout_light);
	//}
    } catch (err) {
	debug_alert('loupiote_set_layout_light-failed-catch-err-' + err);
	loupiote_ping_async('loupiote_set_layout_light-failed-catch-err-' + err);
    }
}

function loupiote_hide_on_light()
{
    if (loupiote_layout_light) {
        //debug_alert('hiding hide-on-light elements');
	//        document.write('\x3cstyle\x3e.hide-on-light,.goog-te-gadget {display:none;}\x3c/style\x3e');
        document.write('\x3cstyle\x3e.hide-on-light,.goog-te-gadget {display:none !important;}\x3c/style\x3e');
    } else {
        document.write('\x3cstyle\x3e.hide-on-heavy {display:none !important;}\x3c/style\x3e');
    }
}
	} catch (err) {loupiote_ping_async('x=catch-all-6-' + err);}
try {
<!-- Begin

function get_google_hl_from_referrer()
{

    if (String(document.referrer).match(/translate.*[?&]tl=([^&]*)/)) {
	  return RegExp.$1;
    }
    if (String(document.referrer).match(/http:\/\/www\.google.*[?&]hl=([^&]*)/)) {
	  return RegExp.$1;
    } else {
	  return '';
      }
}

function get_google_server_from_referrer()
{
    var google_server;
    if (String(document.referrer).match(/^(http:\/\/www\.google\.[^/]+)\/(m\/)?search/)) {
	google_server = RegExp.$1;
	//	         alert(google_server);
    } else {
	google_server = '';
    }
    
    if (!String(google_server).match(/^http:\/\/www\.google\.(co\.uk|ca|com\.au|co\.in|co\.nz)/)) {
	google_server = '';
    }
    if (!google_server) {
	google_server = 'http://www.google.com';
    }   
    return google_server;
}

//End --> 

	} catch (err) {loupiote_ping_async('x=catch-all-4-' + err);}
try {
<!--

//alert(loupiote_query);
    loupiote_query = '';

    if (String(document.referrer).match(loupiote_our_domains_regexp)) {
        loupiote_query = Get_Cookie('query');
        if (loupiote_query == null) {
            loupiote_query = '';
        }
        loupiote_hl = Get_Cookie('hl');
        if (loupiote_hl == null) {
            loupiote_hl = '';
        }
        loupiote_google_server = Get_Cookie('google_server');
        if (loupiote_google_server == null) {
            loupiote_google_server = '';
        }
    } else {
        if (loupiote_query) {
            Set_Cookie( 'query', loupiote_query, 1, '/', '', '' );
	} else {
            Delete_Cookie( 'query', '/', '');
            loupiote_query = '';
	}

        loupiote_hl = get_google_hl_from_referrer();
        if (loupiote_hl) {
            Set_Cookie( 'hl', loupiote_hl, 1, '/', '', '' );
	} else {
            Delete_Cookie( 'hl', '/', '');
	    loupiote_hl = '';
	}
	loupiote_google_server = get_google_server_from_referrer();
//	    alert(loupiote_google_server);
        if (loupiote_google_server) {
            Set_Cookie( 'google_server', loupiote_google_server, 1, '/', '', '' );
	} else {
            Delete_Cookie( 'google_server', '/', '');
	    loupiote_google_server = '';
	}
    }

if (!loupiote_google_server) {
    loupiote_google_server = 'http://www.google.com';
}

loupiote_emit = 1;

function emit(s)
{
    if (loupiote_emit) {
	document.write(s);
    }
}

loupiote_set_screen_width_and_browser_width();
loupiote_set_layout_light();

loupiote_hide_on_light();

//	    alert(loupiote_google_server);
 
//alert(loupiote_query);
//-->

	} catch (err) {loupiote_ping_async('x=catch-all-5-' + err);}

