function WM_readCookie(name) {
	if (document.cookie == '') { 
		return false;
	} else {
    		var firstChar, lastChar;
		var theBigCookie = document.cookie;
		firstChar = theBigCookie.indexOf(name);
		if(firstChar != -1)  {
			firstChar += name.length + 1;
			lastChar = theBigCookie.indexOf(';', firstChar);
			if(lastChar == -1) lastChar = theBigCookie.length;
			return (unescape(theBigCookie.substring(firstChar, lastChar)));
		} else {
			return false;
		}
	}
}


function WM_readSubCookie(cname,sname) {
  var ck = WM_readCookie(cname)
  if (ck==false) {
    return false
  }else{
    var firstChar, lastChar;
    firstChar = ck.indexOf(sname);
    if(firstChar != -1)  {
	firstChar += sname.length + 1;
	lastChar = ck.indexOf('&', firstChar);
	if(lastChar == -1) lastChar = ck.length;
	return (unescape(ck.substring(firstChar, lastChar)));
	} else {
	return false;
	}
  }
}

function openWin( windowURL, windowName, windowFeatures ) {
	return window.open( windowURL, windowName, windowFeatures );
}

function launchRegister( redir, lang ) {
	var xPos = (screen.width-650)/2;
	var yPos = (screen.height-450)/2;
	regWindow = openWin( '/register/register.asp?redir='+redir+'&lang='+lang, 'register','width=650,height=425,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0' );
	regWindow.moveTo(xPos,yPos);
	regWindow.focus();
}

function launchLogin( lang ) {
	var xPos = (screen.width-650)/2;
	var yPos = (screen.height-450)/2;
	loginWindow = openWin( '/register/login.asp?lang='+lang, 'login','width=650,height=425,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0' );
	loginWindow.moveTo(xPos,yPos);
	loginWindow.focus();
}

function launchLogout( ) {
	var xPos = (screen.width-650)/2;
	var yPos = (screen.height-450)/2;
	logoutWindow = openWin( '/register/logout.asp', 'logout','width=650,height=425,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0' );
	logoutWindow.moveTo(xPos,yPos);
	logoutWindow.focus();
}

function launchEcard(str) {
        var xPos = (screen.width-650)/2;
	var yPos = (screen.height-450)/2;
	ecardWindow = openWin( '/read.php?'+str, 'register','width=650,height=400,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0' );
	ecardWindow.moveTo(xPos,yPos);
	ecardWindow.focus();
}
 


function launchDiscussion( lang ) {
	if (UserHandle()==false) launchRegister('d', lang)
	else window.open("/discussion/")
}
 
function UserHandle() {
	return WM_readCookie('ti','UserHandle')
}




function popfull(photo,name) {
	myleft  = 25;
	mytop   = 25;
	width = 400;
	height = 630;
	dbart = window.open(photo,name,"height="+height+",width="+width+",left="+myleft+",top="+mytop+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1");
}

function launchLocationform(){
	popfull('locationform_flash.html','locationform');
}
