// focusing window
function focusW()
{
    window.focus();
}
//setTimeout("focusW()", 420000);//

function d908087043452281231(add2URL)
{
	var sURLpop = "http://www.mgc.com/language/french/" +add2URL;
	var sURLreg = "http://banner.32vegas.com/cgi-bin/SetupCasino.exe?member=offline&profile=french";

	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;
}

// verisign func
function popSign(url)
{
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,re sizable=1,width=720,height=450');
	self.name = "mainWin";
}








function Get_Cookie(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 Get_Profile(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 Get_Banner(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[1]);
}


/*******************************************************************************************************/
/****** Downlaod Impressions                                                   ****************************************************/
/*******************************************************************************************************/
/**
 *  Author: Artiom Lunev
 *  File: downloads/downloads.js
 *  Copyright: clubdicecasino, cpays (c) 2006
 *  Date: 2:19 PM 3/16/2006
 */

var xmlDoc;
var imp_url;

/**
 *  Checks if member and profile have impression url
 *  if in xml profile is *, it means: show this impression to all profiles
 */
function impUrl(member, profile) {
    var impressions = xmlDoc.getElementsByTagName('impression');


    for(i=0;i<impressions.length;i++) {
        // If xml structure changes, this needs to be changed as well
        member_xml = impressions[i].childNodes[0].firstChild.nodeValue;
        profile_xml = impressions[i].childNodes[1].firstChild.nodeValue;
        url_xml = impressions[i].childNodes[2].firstChild.nodeValue;

        if(member==member_xml && (profile==profile_xml || profile_xml=='*')) {
            imp_url = url_xml;
        }
	}

    return;
}

/**
 *  Load xml file
 */
function importXML(file, member, profile)
{
	if (document.implementation && document.implementation.createDocument)
	{
		xmlDoc = document.implementation.createDocument("", "", null);
		xmlDoc.onload = impUrl(member, profile);
	}
	else if (window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.onreadystatechange = function () {
			if (xmlDoc.readyState == 4) impUrl(member, profile);
		};
 	}
	else
	{
		alert('Browser can\'t handle this javascript');
		return;
	}
	xmlDoc.load(file);
}

// Download impression
member_cookie = Get_Cookie("banner_domainclick");
profile_cookie = Get_Profile("banner_domainclick");
if( (member_cookie==null) || (member_cookie === undefined) ) {
    member_cookie = 'defaultmg';
    profile_cookie = 'defaultmg';
}

importXML("../../lib/downloads/downloads.xml", member_cookie, profile_cookie);

/*******************************************************************************************************/
/*******************************************************************************************************/
/*******************************************************************************************************/







function upopup(url,w,h,s,n){
	var x;
	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=no,menubar=no,location=no,scrollbars="+s+",left="+l+",top="+t);
    x.window.focus();
}

function Download(buttonId){
    if(buttonId==null) buttonId="0000";
  	var urlStr = window.location.href;
  	var pageLang = "fr";
 	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 "_".

    if (document.images) {
        if(imp_url === undefined) {
            // No impression url been found in xml file
            // use our default one
            imp1 = new Image(1,1);
            imp1.src = 'http://banner.32vegas.com/cgi-bin/banner.cgi?member='+member_cookie+'&profile=french';
        }
        else {
            // Impression url been found
            imp1 = new Image(1,1);
            imp1.src = 'http://banner.32vegas.com/cgi-bin/banner.cgi?member='+member_cookie+'&profile=french';

            imp2 = new Image(1,1);
            imp2.src = imp_url;
        }
    }

	if(member_cookie != 'elg4mbling') {
		parent.window.location.href="http://banner.32vegas.com/cgi-bin/SetupCasino.exe?opt_lang=fr&creferer=DLB:"+finalStr;
	}
	else {
		parent.window.location.href="http://banner.32vegas.com/cgi-bin/SetupCasino.exe?opt_lang=fr";
	}
}

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 parentgoto(url){
    var isIE = document.all?true:false;		//true if browser is IE, false if Netscape
	var win;
	var base = 'index.html';
	if(!window.name)						//if never was a parent window (case 1)
	  win = window.open(base);				//open new one
	else{									//if there is a parent (case 2)
	  win = window.opener;					//find it
	  if(!win)								//if couldn't find (netscape friendle opener trouble)
	    win = window.open(base);			//open new one
	  if(win.closed)						//if it was closed (case 3)
	    win = window.open(base);			//open new one
	}

	try{
	  win.mainFrame.location.href = url;
	}
	catch(e){
	  win.location.href = url;
	}
	win.focus();
}

var pre = "";
function show(what){
if (pre){
document.getElementById(pre).style.display="none";
}
what = new String(what);
var splited = what.split("/");
var what = splited[splited.length-1];
pre = what;
document.getElementById(pre).style.display="";
return false;
}
