function buildUrl(url, lang) {
	var base = 'http://www.money-casino.com/';
	return(base+lang+'/'+url);
}

function jumpto(url, lang) {
    location.href = buildUrl(url, lang);
}

function getMember(name) {
   var start = document.cookie.indexOf(name+"=");
   var len = start+name.length+1;
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
   if (start == -1) return null;
   var end = document.cookie.indexOf(";",len);
   if (end == -1) end = document.cookie.length;
   var res = unescape(document.cookie.substring(len,end));
   var result = res.split(",");
   return (result[0]);
}

function getProfile(name) {
   var start = document.cookie.indexOf(name+"=");
   var len = start+name.length+1;
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
   if (start == -1) return null;
   var end = document.cookie.indexOf(";",len);
   if (end == -1) end = document.cookie.length;
   var res = unescape(document.cookie.substring(len,end));
   var result = res.split(",");
   return (result[2]);
}


function upopup(url,w,h,s,n,m){
	var x;
	if(m != "yes") m = "no";
	//alert("test "+m);
	var l = (window.screen.width-w)/2;
	var t = (window.screen.height-h)/2;
	x = window.open(url,n,"height="+h+",width="+w+",status=no,toolbar="+m+",menubar=no,location=no,scrollbars="+s+",left="+l+",top="+t);
    x.window.focus();
}

function replaceWith(str,char2find,char2replace) {
  var newStr = "";
  for(var i=0 ; i<str.length ; i++)
    if(str.charAt(i) == char2find)
	  newStr += char2replace;
	else
	  newStr += str.charAt(i);
  return newStr;
}

function downloadcasino(buttonId, lang) {
    if(buttonId==null) buttonId="0000";
  	var urlStr = window.location.href;
  	var pageLang = lang;
 	var urlStrArray = urlStr.split("/");						//seperate url into array, "/" is the seperator
  	var pageStr = urlStrArray[urlStrArray.length-1];			//page name is the last in the array
  	var len = pageStr.indexOf("."); 							//find seperator between file name and extension
  	var pageName = pageStr.substr(0,len);						//seperate file name from extension (save file name)
	if(pageName=="") pageName = "index";						//if ".com" address with no actual file
  	var finalStr = pageLang + "+" + pageName + "+" + buttonId;	//"+" is the seperator of the final string
	finalStr = replaceWith(finalStr,"_","-");					//replace all the "_" with "-" because the cgi won't accept "_".
  	
    // checking from what tracking link coming
    var wwwd = "banner";
	if(getMember("banner_click") != null) {
		//alert("wwww cookie was found");
		wwwd = "www";
	}
    
    down_url = "http://www.money-casino.com/install/Money-Casino-Hebrew.exe";   
    
    var sURLpop = "http://www.money-casino.com/casino/394.htm";
	var sURLreg = down_url;

	var a21 = window.open(sURLreg,"d12863","width=1,height=1,top=150,left=1,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,directories=no,status=no");
	a21.blur();
	document.location.href = sURLpop;
}
