// This file is loaded BEFORE jquery
if(server == null){    
    var server = 'http://www.sumopix.com/';
//    var server = 'http://localhost/sumopix/docs/';
   
    if(typeof click_masking_mode != "undefined") {
       server = 'http://order.click.dk/';
    }
    var photo_app_link = server + "cl/photo_test/";
//    var photo_app_link = server + "da/photos/";
}
function confirmChoice (question, loc){
	if(confirm(question)){
		window.location = loc;
	}
	return false;
}
/**
 *
 */
$(document).ready(function(){
    if( $.browser.opera){
        var temp = ($('body').width() - $('#content_wrapper').width()) / 2;
//        alert(temp);
//        $('.side_bar').width(temp);
    }
});

var nResizes = 0;
function resizePage() {
	nResizes++;
	if(nResizes < 10){
		var obj = document.getElementById('resizeMe');
		var obj2 = document.getElementById('resizeMe2');
		var c = 1;	
		var tmp = document.getElementById('coords');
		
		if(tmp != null){
			var element,x, y;
			x = 0;
			y = 0;
			if (tmp.offsetParent) {
				x += tmp.offsetLeft;
				y += tmp.offsetTop;
				while (tmp = tmp.offsetParent) {
					c++;
					if(c >= 10) break;
					x += tmp.offsetLeft;
					y += tmp.offsetTop;
				}
			}
			y-=294;
			var y2 = y + 214;
			if(y > 10000){
				resizePage();
			}
			var newHeight = (y + 19) + "px";
			var newHeight2 = (y2 + 19) + "px";
			obj.style.height = newHeight;
			obj2.style.height = newHeight;
		}
	}
}

window.onresize = resizePage;
window.onload = resizePage;

function popUpWindow(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=1000,height=500');");
}
	
function changeLang(url, params){
	window.location = url + params;
}

function hover(id, sub_id){
  var obj = document.getElementById(id);
  if(obj.className != 'selected'){
  	obj.className = 'hover';
  }
  showSub(sub_id);
  holdSub(id);
}

function haway(id, sub_id){
	var obj = document.getElementById(id);
	obj.className = 'greyed';
    freeSub(sub_id);
    hideSub(sub_id);
}

function toggleExpress(url){
	if(document.getElementById('enable_express').checked){
		var enable = 'true';
	}else {
		var enable = 'false';
	}
	window.location= url + '&enable_express=' + enable;
}

function showURL(image, url) {
	var a = document.getElementById("ancor"+image+"");
	a.setAttribute('href', url);
	myLightbox.start(a);	
}

function OpenLightBox(id) {
	if(enable_lightbox) {
		var a = document.getElementById("ancor_default"+id+"");
		myLightbox.start(a);
	}	
}

function edit(){
	window.location = '?id=99&pageid=2';
}

// Javascrip Ecoding decoding function
 var Utf8 = {
	// public method for url encoding
	encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},
	// public method for url decoding
	decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}

}




