﻿if (SLCOnlineCasino == undefined) {
	var SLCOnlineCasino = {
		DropDown: {
			DDSpeed: 5,
			DDTimer: 15,
			paddingBottom: 6,
			slide: function(c, dir) {
				var curHeight = c.offsetHeight;
				var distance;
				if (dir == 1) { distance = (Math.round((c.maxh - curHeight) / this.DDSpeed)); }
				else { distance = (Math.round(curHeight / this.DDSpeed)); }
				if (distance <= 1 && dir == 1) { distance = 1; }
                if (distance != 0) {
			        var h = curHeight + ((distance * dir));
				    c.style.cssText = "height:" + h + "px";
					if ((curHeight < 2 && dir != 1) || (curHeight > (c.maxh - 2) && dir == 1)) { clearInterval(c.timer); }
				} else {
					c.style.height = "0px";
					clearInterval(c.timer);
				}
			},
			collapse: function(c) {
				c.timer = setInterval(function() { SLCOnlineCasino.DropDown.slide(c, -1); }, this.DDTimer);
			},
			cancelHiding: function(id) {
				var d = document.getElementById(id + "_dropdown");
				var c = document.getElementById(id + "_content");
				clearTimeout(d.timer);
				clearTimeout(c.timer);
				if (c.offsetHeight < c.maxh) { c.timer = setInterval(function() { SLCOnlineCasino.DropDown.slide(c, 1); }, this.DDTimer); }
			},
			DDMenu: function(id, dir) {
				var d = document.getElementById(id + "_dropdown");
				var c = document.getElementById(id + "_content");
				clearInterval(c.timer);
				if (dir == 1) {
					clearTimeout(d.timer);
					if (c.maxh && c.maxh <= c.offsetHeight) { return; }
					else if (!c.maxh) {
						c.style.display = "block";
						c.style.height = "auto";
						c.maxh = c.offsetHeight + this.paddingBottom;
						c.style.height = "0px";
					}
    				//c.style.height = c.maxh + "px";

					c.timer = setInterval(function() { SLCOnlineCasino.DropDown.slide(c, 1); }, this.DDTimer);
				}
				else { d.timer = setTimeout(function() { SLCOnlineCasino.DropDown.collapse(c); }, 50); }
			}
		},
		Slider: {
			Menus: new Array(),
			RollOverType: { On: 1, Out: -1 },
			Change: function(group, index, type) {
				var h = document.getElementById("GameHeader_" + group);
                var i = document.getElementById("previewImage_" + group);
                var current = document.getElementById("current_" + group);
                var exA = document.getElementById("link_" + group + "_" + current.value);
				var item = this.Menus[group][index];
				if (item != undefined) {
					if (type == this.RollOverType.On) {
						h.innerHTML = item.title;
						if(item.imgUrl.indexOf('~') != 0)
						i.setAttribute("src", item.imgUrl);
						else
                        {
                            i.setAttribute("src", "");
						    i.setAttribute("src", item.imgUrl.substring(1,item.imgUrl.length));
						}
						i.setAttribute("alt", item.title);
						exA.setAttribute("class", "");
						current.value = index; 
					}
				}
				
			},
			Next: function(group, type){
			    var current = document.getElementById("current_" + group);
			    var currentIndex = parseInt(current.value);
			    var item;
			    var index = 0;
			    
			    if (type == this.RollOverType.On) {		
					index = (currentIndex + 1);
			        item = this.Menus[group][index];
			    }
			    else {
					index = (currentIndex - 1);
					item = this.Menus[group][index];
			    }    
			    
			    if (item == undefined || item == null) {
			        index = 0;
			        item = this.Menus[group][index];
			    }
			    
			    var h = document.getElementById("GameHeader_" + group);
                var i = document.getElementById("previewImage_" + group);
                var a = document.getElementById("link_" + group + "_" + index);
                var exA = document.getElementById("link_" + group + "_" + currentIndex);			    
			    
			    h.innerHTML = item.title;
				if(item.imgUrl.indexOf('~') != 0)
						i.setAttribute("src", item.imgUrl);
						else
                        {
                            i.setAttribute("src", "");
						    i.setAttribute("src", item.imgUrl.substring(1,item.imgUrl.length));
						}
				
				i.setAttribute("alt", item.title);
				a.setAttribute("class", "selected");
				exA.setAttribute("class", "");
				
				current.value = index; 
			},
			Description: function(group, index, e){
			    var item = this.Menus[group];
			    item = item ? item[index] : null;
			    
			    
			    
			    e = e || window.event;
                var cursor = {x:0, y:0};
                if (e.pageX || e.pageY) {
                    cursor.x = e.pageX;
                    cursor.y = e.pageY;
                } 
                else {
                    var de = document.documentElement;
                    var b = document.body;
                    cursor.x = e.clientX + 
                        (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
                    cursor.y = e.clientY + 
                        (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
                }
                
               

//                var myDiv;
//                
//               
//                
//			    if(item)
//			    {
//			        myDiv = document.getElementById('myDiv');
//			        
//			        if(myDiv)
//			        {
//			            var img = myDiv.getElementsByTagName('img')[0];
//			            var span = myDiv.getElementsByTagName('span')[0];
//			            if(img)
//			            {
//			                img.src = item.imgUrl;
//			                img.alt = item.desc;
//			            }
//			            if(span)
//			            {
//			                span.innerHTML = item.desc;
//			            }
//			        }
			        
                var divInfo;
                
                if(item)
                {
                    divInfo = document.getElementById('divGameSelectContainer');
                    if(divInfo)
                    {
                        var img = divInfo.getElementsByTagName('img')[0];
                        
                        if(img)
                        {
                            img.src = item.imgUrl;
                        }
                    }
                }
			    
			    var divPosX = 0;
			    
			    if(cursor.x < 300)
			    {
			        divPosX = 312;
			    }
			    else if(cursor.x >= 300 && cursor.x < 485)
			    {
			        divPosX = 485;
			    }
			    else if(cursor.x >= 485 && cursor.x < 656)
			    {
			        divPosX = 656;
			    }
			    else if(cursor.x >= 656)
			    {
			        divPosX = 825;
			    }

                divInfo.style.left = divPosX + "px";
                divInfo.style.top = (cursor.y - 15) + "px";
                
//                cat.style.left = divPosX + "px";
//                cat.style.top = 
//                cat.style.display = "block";
			    
			    
//	            myDiv.style.left = divPosX + "px";
//	            myDiv.style.top = (cursor.y - 15) + "px";
//	            
//			    myDiv.style.display = "block";
			}
			
		}
	}
}

