
var page_id = '';
function GetXmlHttpObject(){
	var xmlHttp=null;
	try  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	}
	catch (e){
	  // Internet Explorer
	  try {
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	  catch (e){
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	}
	return xmlHttp;
}
function GetXmlHttpObject2(){
	var xmlHttp2=null;
	try  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp2=new XMLHttpRequest();
	}
	catch (e){
	  // Internet Explorer
	  try {
		xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	  catch (e){
		xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	}
	return xmlHttp2;
}
function GetXmlHttpObject3(){
	var xmlHttp3=null;
	try  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp3=new XMLHttpRequest();
	}
	catch (e){
	  // Internet Explorer
	  try {
		xmlHttp3=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	  catch (e){
		xmlHttp3=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	}
	return xmlHttp3;
}
function GetXmlHttpObjectPin(){
	var xmlHttpPin=null;
	try  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttpPin=new XMLHttpRequest();
	}
	catch (e){
	  // Internet Explorer
	  try {
		xmlHttpPin=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	  catch (e){
		xmlHttpPin=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	}
	return xmlHttpPin;
}

function save_colour(pinPos){

	xmlHttpPin=GetXmlHttpObjectPin();
	if (xmlHttpPin==null){
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url="/colour.php";
	var params="pin="+pinPos;
	xmlHttpPin.onreadystatechange=return_save_colour;
	xmlHttpPin.open("POST",url,true);
	xmlHttpPin.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttpPin.setRequestHeader("Content-length", params.length);
	xmlHttpPin.setRequestHeader("Connection", "close");
	xmlHttpPin.send(params);

}
function return_save_colour(){ 
	if (xmlHttpPin.readyState==4){ 
///	alert(xmlHttp.responseText);   //view return
	}
}


var myWidth = 0;
var myHeight = 0;
function save_screen(){
	xmlHttp2=GetXmlHttpObject2();
	if (xmlHttp2==null){
		alert ("Your browser does not support AJAX!");
		return;
	}

	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

	var url="/screen.php";
	var params="h="+myHeight+"&w="+myWidth;
	xmlHttp2.onreadystatechange=return_save_screen;
	xmlHttp2.open("POST",url,true);
	xmlHttp2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp2.setRequestHeader("Content-length", params.length);
	xmlHttp2.setRequestHeader("Connection", "close");
	xmlHttp2.send(params);

}
function return_save_screen(){ 
	if (xmlHttp2.readyState==4 && page_id == 'home'){ 
///	alert(xmlHttp2.responseText);   
	//alert('saved');
	}
}


function formatFolderName(str){
	return str.replace(/ /gi,'_').replace(/[^a-z0-9\._\-]/gi,'_').replace('__','_').toLowerCase();
}
function toLatin(str){
	str = str.replace(/à/gi,'a');	str = str.replace(/á/gi,'b');	str = str.replace(/â/gi,'v');
	str = str.replace(/ã/gi,'g');	str = str.replace(/ä/gi,'d');	str = str.replace(/å/gi,'e');
	str = str.replace(/¸/gi,'e');	str = str.replace(/æ/gi,'j');	str = str.replace(/ç/gi,'z');
	str = str.replace(/è/gi,'i');	str = str.replace(/é/gi,'y');	str = str.replace(/ê/gi,'k');
	str = str.replace(/ë/gi,'l');	str = str.replace(/ì/gi,'m');	str = str.replace(/í/gi,'n');
	str = str.replace(/î/gi,'o');	str = str.replace(/ï/gi,'p');	str = str.replace(/ð/gi,'r');
	str = str.replace(/ñ/gi,'s');	str = str.replace(/ò/gi,'t');	str = str.replace(/ó/gi,'u');
	str = str.replace(/ô/gi,'f');	str = str.replace(/õ/gi,'h');	str = str.replace(/ö/gi,'c');
	str = str.replace(/÷/gi,'ch');	str = str.replace(/ø/gi,'sh');	str = str.replace(/ù/gi,'sch');
	str = str.replace(/ú/gi,'');	str = str.replace(/û/gi,'y');	str = str.replace(/ü/gi,'');
	str = str.replace(/ý/gi,'e');	str = str.replace(/þ/gi,'yu');	str = str.replace(/ÿ/gi,'ya');
	return str; 
}
function formatTags(str){
	
	return str.replace(/ /gi,'_').replace(/[^a-z0-9\.,_\-]|,,|\./gi,'_').replace('__','_').replace(',_',',').replace('_,',',').toLowerCase();
}


