var iframeLoaded = false;
var fullReviewLoaded = false;
var gameTab = "favgames";
var offer = 0;

function ShowPopup(hoveritem, path, aTab){

	gameTab = aTab;

	var hp = document.getElementById("hoverpopup");
	var elem = document.getElementById("reviewIframe");
	var wp = document.getElementById("waitpopup");

	var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
	if (is_chrome == true){
		parent.document.getElementById("bestgameframe").style.visibility = "hidden";
	}

	wp.style.top = (document.body.clientHeight * 0.35) + document.body.scrollTop;
	wp.style.left = document.body.clientWidth * 0.43;

	hp.style.top = ((document.body.clientHeight - 585) * 0.5) + document.body.scrollTop;
	hp.style.left = (document.body.clientWidth - 775) * 0.5;

	elem.src= path;
	elem.reload;

	showpopuptimer();

}


function showpopuptimer(){

	wp = document.getElementById("waitpopup");
	if (fullReviewLoaded == false){

		grayOut(true, "");
		wp.style.visibility = "visible";
		setTimeout("showpopuptimer()", 100);
	}

	else{

		hp = document.getElementById("hoverpopup");
		hp.style.visibility = "visible";
		wp.style.visibility = "hidden";
		fullReviewLoaded=false;
		grayOut(false, "");
	}

}



function HidePopup(){

	hp = parent.document.getElementById("hoverpopup");
	hp.style.visibility = "Hidden";	

	var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
	if (is_chrome == true){
		parent.document.getElementById("bestgameframe").style.visibility = "visible";
	}

}


function reviewFrameSize(){


	var elem = document.getElementById("reviewIframe");
//	elem.style.width=document.body.clientWidth * 0.7;
//	elem.style.height=document.body.clientHeight * 0.7;

	elem.style.width="775px";
	elem.style.height="585px";


	var hp = document.getElementById("hoverpopup");
//	hp.style.top = document.body.clientHeight * 0.15;
//	hp.style.left = document.body.clientWidth * 0.15;

	hp.style.top = ((document.body.clientHeight - 585) * 0.5) + document.body.scrollTop;
	hp.style.left = (document.body.clientWidth - 775) * 0.5;
	

	var wp = document.getElementById("waitpopup");
	wp.style.top = document.body.clientHeight * 0.35;
	wp.style.left = document.body.clientWidth * 0.43;


	if (Right(elem.src, 14) == "moregames.html") {
		autoResize("reviewIframe");
	}

}


function changeMainDiv(doc) {

	var wp = document.getElementById("waitpopup");
	wp.style.top = (document.body.clientHeight * 0.35);
	wp.style.left = document.body.clientWidth * 0.43;

	srcFrame = document.getElementById("hiddenIframe");
	srcFrame.src = doc;

	waitIframeLoaded();
 
}


function waitIframeLoaded() {

	srcContent='';
	wp = document.getElementById("waitpopup");

	if (iframeLoaded==false){

		grayOut(true, "");

		wp.style.visibility = "visible";
		setTimeout("waitIframeLoaded()", 100);

	}

	else{

		if (srcFrame.contentDocument){
			srcContent=srcFrame.contentDocument.getElementsByTagName("BODY")[0].innerHTML;
 		}
	 	else if (srcFrame.contentWindow){
			srcContent=srcFrame.contentWindow.document.body.innerHTML;
		}
		document.getElementById("mainDiv").innerHTML = srcContent
		iframeLoaded=false;
		wp.style.visibility = "hidden";
		grayOut(false, "") ;
	}

}


function initilizePage(){

	grayOut(true, "");
	wp = document.getElementById("waitpopup");
	wp.style.visibility = "visible";

        preload_image = new Image(125,8); 
	preload_image.src="./img/loading.gif"; 

        preload_image2 = new Image(7,25); 
	preload_image2.src="./img/tabbgblueleft.png"; 

        preload_image3 = new Image(7,25); 
	preload_image3.src="./img/tabbgblueright.png"; 

        preload_image4 = new Image(7,25); 
	preload_image4.src="./img/tabbgwhiteleft.png"; 

        preload_image5 = new Image(7,25); 
	preload_image5.src="./img/tabbgwhiteright.png"; 

        preload_image6 = new Image(7,25); 
	preload_image6.src="./img/tabbggreyleft.png"; 

        preload_image7 = new Image(7,25); 
	preload_image7.src="./img/tabbggreyright.png"; 

        preload_image8 = new Image(104,20); 
	preload_image8.src="./img/downloadorange.png"; 

        preload_image9 = new Image(169,20); 
	preload_image9.src="./img/moregames2orange.png"; 

        preload_image10 = new Image(18,17); 
	preload_image10.src="./img/zoom_outorange.png"; 

        preload_image11 = new Image(18,17); 
	preload_image11.src="./img/zoom_inorange.png"; 

        preload_image12 = new Image(20,17); 
	preload_image12.src="./img/fullscreenorange.png"; 

        preload_image13 = new Image(104,20); 
	preload_image13.src="./img/download.png"; 

        preload_image14 = new Image(169,20); 
	preload_image14.src="./img/moregames2.png"; 

        preload_image15 = new Image(18,17); 
	preload_image15.src="./img/zoom_out.png"; 

        preload_image16 = new Image(18,17); 
	preload_image16.src="./img/zoom_in.png"; 

        preload_image17 = new Image(20,17); 
	preload_image17.src="./img/fullscreen.png"; 


	fname=Right(window.name, window.name.length - 12);
	ftype=Left(window.name, 12);

	if (ftype == "populareview"){
		changeMainDiv(fname);

	}
	else if (ftype == "casinoreview"){
		changeMainDiv("./eng/homepage.html");
		ShowPopup(this, fname, '')
	}
	else {
		changeMainDiv("./eng/homepage.html");

	} 


	window.name = "";

	reviewFrameSize();
	
	setInterval("rotateOffer();", 8000);

	if(navigator.appName == "Microsoft Internet Explorer"){
		document.getElementById("bookmark").innerHTML = "Add to Favorites ";	

	}
	else{
		document.getElementById("bookmark").innerHTML = "Bookmark Us";	

	}
}


function indexWaitLoading(){

	var wp = document.getElementById("waitpopup");
	wp.style.top = (document.body.clientHeight * 0.35) + document.body.scrollTop ;
	wp.style.left = (document.body.clientWidth * 0.43);
	grayOut(true, "");
}

function grayOut(vis, options) {
  // Pass true to gray out screen, false to ungray
  // options are optional.  This is a JSON object with the following (optional) properties
  // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
  // in any order.  Pass only the properties you need to set.
  var options = options || {}; 
  var zindex = options.zindex || 0;
  var opacity = options.opacity || 0;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#FFFFFF';
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');           // Create the layer.
        tnode.style.position='absolute';                 // Position absolutely
        tnode.style.top='0px';                           // In the top
        tnode.style.left='0px';                          // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='darkenScreenObject';                   // Name it so we can find it later
    tbody.appendChild(tnode);                            // Add it to the web page
    dark=document.getElementById('darkenScreenObject');  // Get the object.
  }
  if (vis) {
    // Calculate the page width and height 
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    }   
    //set the shader to cover the entire page and make it visible.
    dark.style.opacity=opaque;                      
    dark.style.MozOpacity=opaque;                   
    dark.style.filter='alpha(opacity='+opacity+')'; 
    dark.style.zIndex=zindex;        
    dark.style.backgroundColor=bgcolor;  
    dark.style.width= pageWidth;
    dark.style.height= pageHeight;
    dark.style.display='block';                          
  } else {
     dark.style.display='none';
  }
}
				

function zoom (aValue) {

  var myFrame = "bestgame";
  var value = 0;

  if (aValue == "in"){

  	value = 70;
  }
  else if (aValue == "out"){
	value = -70;

 }


  var obj = document.getElementById(myFrame).style;
  var wt = obj.width;
  var ht = obj.height;
  var ratio = parseInt(ht) / parseInt(wt);


  wt = parseInt(wt) + parseInt(value);
//  ht = wt * 0.75;
  ht = wt * ratio;


  wt=parseInt(wt)+'px';
  ht=parseInt(ht)+'px';

  obj.width=wt;
  obj.height=ht;

}


function loadgame(agame) {

var casinodownload;
var iframepath;
var gameframe = parent.document.getElementById("bestgameframe");
var gametable = parent.document.getElementById("bestgame");
var europadownload = "http://www.wincasinos.net/eng/download/europa_casino.php";
var tropezdownload = "http://www.wincasinos.net/eng/download/casino_tropez.php";
var spinpalacedownload = "http://www.wincasinos.net/eng/download/spin_palace.php";
var casinoonnet = "http://www.wincasinos.net/eng/download/888_casino.php";


if (agame == "bjeuropa") {
	casinodownload = europadownload;
	iframepath = "./eng/games/europa/blackjack.html";

}

if (agame == "rouletteeuropa") {
	casinodownload = europadownload;
	iframepath = "./eng/games/europa/roulette.html";

}

if (agame == "tie9for1europa") {
	casinodownload = europadownload;
	iframepath = "./eng/games/europa/tie9for1.html";

}

if (agame == "jacksorbettereuropa") {
	casinodownload = europadownload;
	iframepath = "./eng/games/europa/jacks_or_better.html";

}
if (agame == "deuceswildeuropa") {
	casinodownload = europadownload;
	iframepath = "./eng/games/europa/deuces_wild.html";

}
if (agame == "europareels") {
	casinodownload = europadownload;
	iframepath = "./eng/games/europa/europa_reels.html";

}
if (agame == "aroundtheworldeuropa") {
	casinodownload = europadownload;
	iframepath = "./eng/games/europa/around_the_world.html";

}
if (agame == "headsortailseuropa") {
	casinodownload = europadownload;
	iframepath = "./eng/games/europa/heads_or_tails.html";

}
if (agame == "spinawineuropa") {
	casinodownload = europadownload;
	iframepath = "./eng/games/europa/spin_a_win.html";

}
if (agame == "popbingoeuropa") {
	casinodownload = europadownload;
	iframepath = "./eng/games/europa/pop_bingo.html";

}


if (agame == "shootout") {
	casinodownload = europadownload;
	iframepath = "./eng/games/europa/shoot_out.html";

}

if (agame == "2waysroyaltropez") {
	casinodownload = tropezdownload;
	iframepath = "./eng/games/tropez/2_ways_royal.html";

}
if (agame == "acesandfacestropez") {
	casinodownload = tropezdownload;
	iframepath = "./eng/games/tropez/aces_and_faces.html";

}


if (agame == "bonusbowling") {
	casinodownload = tropezdownload;
	iframepath = "./eng/games/tropez/bonus_bownling.html";

}

if (agame == "deserttreasure") {
	casinodownload = tropezdownload;
	iframepath = "./eng/games/tropez/desert_treasure.html";

}

if (agame == "jokerpoker") {
	casinodownload = tropezdownload;
	iframepath = "./eng/games/tropez/joker_poker.html";

}

if (agame == "rockpaperscissor") {
	casinodownload = tropezdownload;
	iframepath = "./eng/games/tropez/rock_paper_scissor.html";

}

if (agame == "tropezslots") {
	casinodownload = tropezdownload;
	iframepath = "./eng/games/tropez/tropez_slots.html";

}

if (agame == "derbyday") {
	casinodownload = tropezdownload;
	iframepath = "./eng/games/tropez/derby_day.html";

}

if (agame == "anightouttropez") {
	casinodownload = tropezdownload;
	iframepath = "./eng/games/tropez/a_night_out.html";

}


if (agame == "baccaratspinpalace") {
	casinodownload = spinpalacedownload;
	iframepath = "./eng/games/spin_palace/baccarat.html";

}

if (agame == "roulettespinpalace") {
	casinodownload = spinpalacedownload;
	iframepath = "./eng/games/spin_palace/roulette.html";

}

if (agame == "3cardpokerspinpalace") {
	casinodownload = spinpalacedownload;
	iframepath = "./eng/games/spin_palace/3cardpoker.html";

}

if (agame == "triplemagicspincasino") {
	casinodownload = spinpalacedownload;
	iframepath = "./eng/games/spin_palace/triple_magic.html";

}


if (agame == "cashvillespinpalace") {
	casinodownload = spinpalacedownload;
	iframepath = "./eng/games/spin_palace/cashville.html";

}

if (agame == "jurassicjackpotspinpalace") {
	casinodownload = spinpalacedownload;
	iframepath = "./eng/games/spin_palace/jurassic_jackpot.html";

}

if (agame == "deuceswildspinpalace") {
	casinodownload = spinpalacedownload;
	iframepath = "./eng/games/spin_palace/deuces_wild.html";

}
if (agame == "deucesjokerspinpalace") {
	casinodownload = spinpalacedownload;
	iframepath = "./eng/games/spin_palace/deuces_joker.html";

}
if (agame == "crapsspinpalace") {
	casinodownload = spinpalacedownload;
	iframepath = "./eng/games/spin_palace/craps.html";

}
if (agame == "tombraiderspinpalace") {
	casinodownload = spinpalacedownload;
	iframepath = "./eng/games/spin_palace/tomb_raider.html";

}

if (agame == "bj888") {
	casinodownload = casinoonnet;
	iframepath = "./eng/games/888/blackjack.htm";

}

if (agame == "caribbean888") {
	casinodownload = casinoonnet;
	iframepath = "./eng/games/888/caribbean.htm";

}

if (agame == "roulette888") {
	casinodownload = casinoonnet;
	iframepath = "./eng/games/888/roulette.htm";

}

if (agame == "2timeswild888") {
	casinodownload = casinoonnet;
	iframepath = "./eng/games/888/2timeswild.htm";

}

if (agame == "goldenegg888") {
	casinodownload = casinoonnet;
	iframepath = "./eng/games/888/goldeneggs.htm";

}


if (agame == "jacksorbetter888") {
	casinodownload = casinoonnet;
	iframepath = "./eng/games/888/vp.htm";

}


gameframe.src = iframepath;
gameframe.reload
gametable.style.width = 675;

if (casinodownload == spinpalacedownload){
	gametable.style.height = parseInt(675 * (714/653));

}
else if (casinodownload == casinoonnet){
	gametable.style.height = 675 * 0.7;

}

else{
	gametable.style.height = 675 * 0.75;

}



parent.document.getElementById("downloadbestgame1").href = casinodownload;
parent.document.getElementById("fullscreenicon1").href = iframepath;
parent.document.getElementById("fullscreenlink").href = iframepath;
HidePopup();

}


function autoResize(id){

    var elem = document.getElementById(id);

    elem.style.height="100px";
    elem.style.width="100px";


    elem.style.height= elem.contentWindow.document.body.scrollHeight + "px";
    elem.style.width= elem.contentWindow.document.body.scrollWidth + "px";


}



function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function showfavgames(){

hideallgamesdiv();
favdiv.style.visibility="visible";
favmenu.className= "navigationselected";

}

function showtablegames(){

hideallgamesdiv();
tablediv.style.visibility="visible";
tablemenu.className= "navigationselected";

}

function showslotgames(){

hideallgamesdiv();
slotdiv.style.visibility="visible";
slotmenu.className= "navigationselected";

}


function showvpokergames(){

hideallgamesdiv();
vpokerdiv.style.visibility="visible";
vpokermenu.className= "navigationselected";

}

function showarcadegames(){

hideallgamesdiv();
arcadediv.style.visibility="visible";
arcademenu.className= "navigationselected";

}

function hideallgamesdiv(){

favdiv.style.visibility="hidden";
tablediv.style.visibility="hidden";
slotdiv.style.visibility="hidden";
vpokerdiv.style.visibility="hidden";
arcadediv.style.visibility="hidden";

favmenu.className= "navigation";
tablemenu.className= "navigation";
slotmenu.className= "navigation";
vpokermenu.className= "navigation";
arcademenu.className= "navigation";

}

function getY( oElement )
{
var iReturnValue = 0;
while( oElement != null ) {
iReturnValue += oElement.offsetTop;
oElement = oElement.offsetParent;
}
return iReturnValue;
}

function initmoregames(){
parent.fullReviewLoaded=true;

tablediv.style.position = "absolute";
tablediv.style.top = getY(favdiv);
slotdiv.style.position = "absolute";
slotdiv.style.top = getY(favdiv);
vpokerdiv.style.position = "absolute";
vpokerdiv.style.top = getY(favdiv);
arcadediv.style.position = "absolute";
arcadediv.style.top = getY(favdiv);


if(parent.gameTab=="tablegames"){
	showtablegames();
}
else if(parent.gameTab=="slots"){
	showslotgames();
}
else if(parent.gameTab=="arcade"){
	showarcadegames();
}
else if(parent.gameTab=="videopoker"){
	showvpokergames();
}
else{
	showfavgames();
}

}


function sortTable(id, col, rev) {


  //sortColor(All);


  // Get the table or table section to sort.
  var tblEl = document.getElementById(id);

  // The first time this function is called for a given table, set up an
  // array of reverse sort flags.
  if (tblEl.reverseSort == null) {
    tblEl.reverseSort = new Array();
    // Also, assume the team name column is initially sorted.
    tblEl.lastColumn = 1;
  }

  // If this column has not been sorted before, set the initial sort direction.
  if (tblEl.reverseSort[col] == null)
    tblEl.reverseSort[col] = rev;

  // If this column was the last one sorted, reverse its sort direction.
  //if (col == tblEl.lastColumn)
  //  tblEl.reverseSort[col] = !tblEl.reverseSort[col];

  // Remember this column as the last one sorted.
  tblEl.lastColumn = col;

  // Set the table display style to "none" - necessary for Netscape 6 
  // browsers.
  var oldDsply = tblEl.style.display;
  tblEl.style.display = "none";

  // Sort the rows based on the content of the specified column using a
  // selection sort.

  var tmpEl;
  var i, j;
  var minVal, minIdx;
  var testVal;
  var cmp;
  var alternate = true;

  for (i = 0; i < tblEl.rows.length - 1; i++) {

    // Assume the current row has the minimum value.
    minIdx = i;
    minVal = getTextValue(tblEl.rows[i].cells[col]);

    // Search the rows that follow the current one for a smaller value.
    for (j = i + 1; j < tblEl.rows.length; j++) {
      testVal = getTextValue(tblEl.rows[j].cells[col]);
      cmp = compareValues(minVal, testVal);
      // Negate the comparison result if the reverse sort flag is set.
      if (tblEl.reverseSort[col])
        cmp = -cmp;
      // Sort by the second column (team name) if those values are equal.
      if (cmp == 0 && col != 1)
        cmp = compareValues(getTextValue(tblEl.rows[minIdx].cells[1]),
                            getTextValue(tblEl.rows[j].cells[1]));
      // If this row has a smaller value than the current minimum, remember its
      // position and update the current minimum value.
      if (cmp > 0) {
        minIdx = j;
        minVal = testVal;
      }

    }

    // By now, we have the row with the smallest value. Remove it from the
    // table and insert it before the current row.
    if (minIdx > i) {
      tmpEl = tblEl.removeChild(tblEl.rows[minIdx]);
      tblEl.insertBefore(tmpEl, tblEl.rows[i]);
    }

  }

  // Make it look pretty.
  makePretty(tblEl, col);

  // Set team rankings.
  //setRanks(tblEl, col, rev);

  // Restore the table's display style.
  tblEl.style.display = oldDsply;


  for (i = 0; i < tblEl.rows.length; i++) {


	for (j=0; j < tblEl.rows[i].cells.length; j++){
	
	if (alternate == true){

		tblEl.rows[i].cells[j].style.background = "rgb(255,255,235)";
		tblEl.rows[i].cells[col].style.background = "rgb(252,237,208)";
	}
	else{

		tblEl.rows[i].cells[j].style.background = "rgb(255,255,255)";
		tblEl.rows[i].cells[col].style.background = "rgb(255,255,250)";
	}

	}
	alternate = !alternate;

	tblEl.rows[i].cells[0].innerHTML = "#" + (i + 1);

}

  return false;
}

//-----------------------------------------------------------------------------
// Functions to get and compare values during a sort.
//-----------------------------------------------------------------------------

// This code is necessary for browsers that don't reflect the DOM constants
// (like IE).
if (document.ELEMENT_NODE == null) {
  document.ELEMENT_NODE = 1;
  document.TEXT_NODE = 3;
}

function getTextValue(el) {

  var i;
  var s;

  // Find and concatenate the values of all text nodes contained within the
  // element.
  s = "";
  for (i = 0; i < el.childNodes.length; i++)
    if (el.childNodes[i].nodeType == document.TEXT_NODE)
      s += el.childNodes[i].nodeValue;
    else if (el.childNodes[i].nodeType == document.ELEMENT_NODE &&
             el.childNodes[i].tagName == "BR")
      s += " ";
    else
      // Use recursion to get text within sub-elements.
      s += getTextValue(el.childNodes[i]);

  return normalizeString(s);
}

function compareValues(v1, v2) {

  var f1, f2;

  // If the values are numeric, convert them to floats.

  f1 = parseFloat(v1);
  f2 = parseFloat(v2);
  if (!isNaN(f1) && !isNaN(f2)) {
    v1 = f1;
    v2 = f2;
  }

  // Compare the two values.
  if (v1 == v2)
    return 0;
  if (v1 > v2)
    return 1
  return -1;
}

// Regular expressions for normalizing white space.
var whtSpEnds = new RegExp("^\\s*|\\s*$", "g");
var whtSpMult = new RegExp("\\s\\s+", "g");

function normalizeString(s) {

  s = s.replace(whtSpMult, " ");  // Collapse any multiple whites space.
  s = s.replace(whtSpEnds, "");   // Remove leading or trailing white space.

  return s;
}

//-----------------------------------------------------------------------------
// Functions to update the table appearance after a sort.
//-----------------------------------------------------------------------------

// Style class names.
var rowClsNm = "alternateRow";
var colClsNm = "sortedColumn";

// Regular expressions for setting class names.
var rowTest = new RegExp(rowClsNm, "gi");
var colTest = new RegExp(colClsNm, "gi");

function makePretty(tblEl, col) {

  var i, j;
  var rowEl, cellEl;

  // Set style classes on each row to alternate their appearance.
  for (i = 0; i < tblEl.rows.length; i++) {
   rowEl = tblEl.rows[i];
   rowEl.className = rowEl.className.replace(rowTest, "");
    if (i % 2 != 0)
      rowEl.className += " " + rowClsNm;
    rowEl.className = normalizeString(rowEl.className);
    // Set style classes on each column (other than the name column) to
    // highlight the one that was sorted.
    for (j = 2; j < tblEl.rows[i].cells.length; j++) {
      cellEl = rowEl.cells[j];
      cellEl.className = cellEl.className.replace(colTest, "");
      if (j == col)
        cellEl.className += " " + colClsNm;
      cellEl.className = normalizeString(cellEl.className);
    }
  }

  // Find the table header and highlight the column that was sorted.
  var el = tblEl.parentNode.tHead;
  rowEl = el.rows[el.rows.length - 1];
  // Set style classes for each column as above.
  for (i = 2; i < rowEl.cells.length; i++) {
    cellEl = rowEl.cells[i];
    cellEl.className = cellEl.className.replace(colTest, "");
    // Highlight the header of the sorted column.
    if (i == col)
      cellEl.className += " " + colClsNm;
      cellEl.className = normalizeString(cellEl.className);
  }
}

function setRanks(tblEl, col, rev) {

  // Determine whether to start at the top row of the table and go down or
  // at the bottom row and work up. This is based on the current sort
  // direction of the column and its reversed flag.

  var i    = 0;
  var incr = 1;
  if (tblEl.reverseSort[col])
    rev = !rev;
  if (rev) {
    incr = -1;
    i = tblEl.rows.length - 1;
  }

  // Now go through each row in that direction and assign it a rank by
  // counting 1, 2, 3...

  var count   = 1;
  var rank    = count;
  var curVal;
  var lastVal = null;

  // Note that this loop is skipped if the table was sorted on the name
  // column.
  while (col > 1 && i >= 0 && i < tblEl.rows.length) {

    // Get the value of the sort column in this row.
    curVal = getTextValue(tblEl.rows[i].cells[col]);

    // On rows after the first, compare the sort value of this row to the
    // previous one. If they differ, update the rank to match the current row
    // count. (If they are the same, this row will get the same rank as the
    // previous one.)
    if (lastVal != null && compareValues(curVal, lastVal) != 0)
        rank = count;
    // Set the rank for this row.
    tblEl.rows[i].rank = rank;

    // Save the sort value of the current row for the next time around and bump
    // the row counter and index.
    lastVal = curVal;
    count++;
    i += incr;
  }

  // Now go through each row (from top to bottom) and display its rank. Note
  // that when two or more rows are tied, the rank is shown on the first of
  // those rows only.

  var rowEl, cellEl;
  var lastRank = 0;

  // Go through the rows from top to bottom.
  for (i = 0; i < tblEl.rows.length; i++) {
    rowEl = tblEl.rows[i];
    cellEl = rowEl.cells[0];
    // Delete anything currently in the rank column.
    while (cellEl.lastChild != null)
      cellEl.removeChild(cellEl.lastChild);
    // If this row's rank is different from the previous one, Insert a new text
    // node with that rank.
    if (col > 1 && rowEl.rank != lastRank) {
      cellEl.appendChild(document.createTextNode(rowEl.rank));
      lastRank = rowEl.rank;
    }
  }
}



function sortColor(aTab, position){

sortTable('offTblBdy', position, true);

//All.style.background = "transparent";
//Slot.style.background = "transparent";
//Table.style.background = "transparent";
//Poker.style.background = "transparent";

document.getElementById("All").style.backgroundImage = "url('./img/bggreen.png')";
document.getElementById("Slot").style.backgroundImage = "url('./img/bggreen.png')";
document.getElementById("Table").style.backgroundImage = "url('./img/bggreen.png')";
document.getElementById("Poker").style.backgroundImage = "url('./img/bggreen.png')";

aTab.style.background = "rgb(128,0,0)";

if (aTab.id == "All"){
document.getElementById("AllRadio").checked = true;
}
if (aTab.id == "Slot"){

document.getElementById("SlotRadio").checked = true;
}
if (aTab.id == "Table"){
document.getElementById("TableRadio").checked = true;
}
if (aTab.id == "Poker"){
document.getElementById("PokerRadio").checked = true;
}

}

function toggleBgColor( elem )
{

    var style2 = elem.style;
    style2.backgroundColor = "#FFFF00";

}

function checkEmail(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.emailadd.value)){
return (true);
}
else{
alert("There seems to be something wrong with your email address. Please re-enter.");
return (false);
}
}



function emailfocus() {

var email = document.getElementById("emailadd");
if(email.value == "Your E-Mail address"){
	email.value = "";
}

}



function BookmarkUs() {

var title="WinCasinos.net - Casinos reviews";
var url="http://www.wincasinos.net";

if (window.sidebar) {
	window.sidebar.addPanel(title, url,"");
} else if( document.all ) {
	window.external.AddFavorite( url, title);
} else if( window.opera && window.print ) {
	return true;
}
else if (navigator.appName=="Netscape") {
		alert("Please click OK, then press <Ctrl-D> to bookmark this page.");
	}

}

function trover(atr, id){
var position;
position = getTextValue(document.getElementById(atr.id).cells[0]);
position = parseInt(Right(position, String(position).length - 1)) - 1;

var tblEl = document.getElementById(id);

	for (j=0; j < tblEl.rows[position].cells.length; j++){
		tblEl.rows[position].cells[j].style.background = "rgb(255,255,160)";
	}
	tblEl.rows[position].cells[getPayoutSelection()].style.background = "rgb(119,148,162)";
	tblEl.rows[position].cells[getPayoutSelection()].style.fontWeight = "bold";
	tblEl.rows[position].cells[getPayoutSelection()].style.color = "rgb(255,255,255)";
}


function trout(atr, id){
var position;
var color;
var selectcolor;
position = getTextValue(document.getElementById(atr.id).cells[0]);
position = parseInt(Right(position, String(position).length - 1)) - 1;


if (isInteger(position * 0.5) == true) {
	color = "rgb(255,255,235)";
	selectcolor = "rgb(252,237,208)";
}
else{
	color = "rgb(255,255,255)";
	selectcolor = "rgb(255,255,250)";	
}


var tblEl = document.getElementById(id);



	for (j=0; j < tblEl.rows[position].cells.length; j++){


		tblEl.rows[position].cells[j].style.background = color;
	}
	tblEl.rows[position].cells[getPayoutSelection()].style.background = selectcolor;
	tblEl.rows[position].cells[getPayoutSelection()].style.fontWeight = "normal";
	tblEl.rows[position].cells[getPayoutSelection()].style.color = "rgb(0,0,0)";

}


function getPayoutSelection(){

var result;

if (document.getElementById("AllRadio").checked  == true){
	result = 4;
}
if (document.getElementById("SlotRadio").checked == true){
	result = 5;
}
if (document.getElementById("TableRadio").checked == true){
	result = 6;
}
if (document.getElementById("PokerRadio").checked == true){
	result = 7;
}

return (result);

}


function isInteger(s) {
  return (s.toString().search(/^-?[0-9]+$/) == 0);
}


function changeColor() {
	document.getElementById("casinoname").style.color = "#551A8B";
	document.getElementById("promo").style.color = "#00868B";
}

function resetColor() {
	document.getElementById("casinoname").style.color = "blue";
	document.getElementById("promo").style.color = "red";
}


function rotateOffer(){
var htmlcode;


if (offer == 0){
	htmlcode = "<a href='./eng/visit/william_hill.html' target='_blank'>";
	htmlcode = htmlcode + "<span id='casinoname' style='color: blue' onMouseOver=changeColor() onMouseOut=resetColor()>William Hill: </span>";
	htmlcode = htmlcode + "<span id='promo' style='color: red' onMouseOver=changeColor() onMouseOut=resetColor()>Get 30$/€/£ FREE, NO DEPOSIT needed</span>";
	htmlcode = htmlcode + "</a>";
	document.getElementById("offer").innerHTML = htmlcode;

}


else if (offer == 1){
	htmlcode = "<a href='./eng/visit/eurogrand_casino.html' target='_blank'>";
	htmlcode = htmlcode + "<span id='casinoname' style='color: blue' onMouseOver=changeColor() onMouseOut=resetColor()>EuroGrand: </span>";
	htmlcode = htmlcode + "<span  id='promo' style='color: red' onMouseOver=changeColor() onMouseOut=resetColor()>October 2009 BEST PAYOUT 98.21%</span>";
	htmlcode = htmlcode + "</a>";
	document.getElementById("offer").innerHTML = htmlcode;

}

else if (offer == 2){
	htmlcode = "<a href='./eng/visit/golden_riviera.html' target='_blank'>";
	htmlcode = htmlcode + "<span id='casinoname' style='color: blue' onMouseOver=changeColor() onMouseOut=resetColor()>Golden Riviera: </span>";
	htmlcode = htmlcode + "<span  id='promo' style='color: red' onMouseOver=changeColor() onMouseOut=resetColor()>2500$/€/£ FREE Play - 60 minutes</span>";
	htmlcode = htmlcode + "</a>";
	document.getElementById("offer").innerHTML = htmlcode;

}

else if (offer == 3){
	htmlcode = "<a href='./eng/visit/titan_casino.html' target='_blank'>";
	htmlcode = htmlcode + "<span id='casinoname' style='color: blue' onMouseOver=changeColor() onMouseOut=resetColor()>Titan Casino: </span>";
	htmlcode = htmlcode + "<span  id='promo' style='color: red' onMouseOver=changeColor() onMouseOut=resetColor()>Get Up To 4000$/€/£ BONUS</span>";
	htmlcode = htmlcode + "</a>";
	document.getElementById("offer").innerHTML = htmlcode;

}

else if (offer == 4){
	htmlcode = "<a href='./eng/visit/roxy_palace.html' target='_blank'>";
	htmlcode = htmlcode + "<span id='casinoname' style='color: blue' onMouseOver=changeColor() onMouseOut=resetColor()>Roxy Palace: </span>";
	htmlcode = htmlcode + "<span  id='promo' style='color: red' onMouseOver=changeColor() onMouseOut=resetColor()>Deposit 100$/€, Get 100$/€ FREE</span>";
	htmlcode = htmlcode + "</a>";
	document.getElementById("offer").innerHTML = htmlcode;

}


offer = offer + 1;

if (offer > 4){

	offer = 0;
}

}


function loadinframe(filename) {

if (iframeLoaded == true){
	window.name = "populareview./eng/" + filename;
	window.location="../index.html";
}
}


function loadreview(filename) {

if (fullReviewLoaded == true){

	window.name = "casinoreview./eng/" + filename;
	window.location="../index.html";
}
}
