function openNDWindow(){
	var winProps  = 'height=' + screen.availHeight + ',width=' + screen.availWidth +'toolbar=0,scrollbars=0,status=0,resizable=1,location=0,menuBar=0,top=0,left=0,fullscreen';
	var res = getData();
	res['url'] = res['url']+'?skin_id='+res['skin_id']+'&lang='+res['lang']+'&pD='+res['pD'];
	var win = window.open(res['url'],'win',winProps);                      
}

/*Copyright Year for innerpages*/
var year = new Date();
var year = year.getUTCFullYear();
var copyright="&copy; Copyright "+year+" www.RMRoyalMedia.com";

var footerImgSrc = "/assets/Uploads/Common-Files/Payment-Logos/paymentLogos.jpg";
$(function(){
	var footer = document.getElementById('paymentLogos');
	//footer.src = footerImgSrc;
	$(".footerCopyright").html(copyright);
});

function isArray(obj) {
	return obj.constructor.toString().indexOf("Array") == -1 ? false : true;
}

function openPopOut(path){
window.open(path,'mywindow','menubar=1,resizable=1,scrollbars=1,width=800,height=600');
}

function loadImgs(path,imgs){
	var img;
	for (var i = 0; i < imgs.length; ++i) {
		img = document.createElement('img');
		img.src = path+imgs[i];
		$(img).trigger('load');
	}
}

//submenu work
function showmenu(elmnt){
	document.getElementById(elmnt.id).style.display="block";
}
function hidemenu(elmnt){
	document.getElementById(elmnt.id).style.display="none";
}

var menuIds=['gamesSubMenu','promoSubMenu'];
var textMaxLength=15, expText=6;

function loadSubMenus(){
	for(var i=0,len=menuIds.length;i < len;i++){
		var menuID,ul=document.getElementsByTagName("ul");
		if(menuIds[i]) menuID = document.getElementById(menuIds[i]);
		for(var j=0,leng=ul.length;j < leng;j++){
			/*Set every ul with an id if they havn't*/
			if(!ul[j].id) ul[j].setAttribute("id","subMenu"+j);
			(function(Area){
				if(menuID){
					/*if we have submenus in the dropdown menu*/
					if(menuID.getElementsByTagName('ul')[0]!==undefined){
						var firstul = menuID.getElementsByTagName('ul')[0];
						if(firstul.className==menuID.id){
							var lis=$("#"+ul[j].id+" > li"),z=0;
							/*Loop every single li element*/
							for(var lengt=lis.length-1;z < lengt;z++){
								var liLink = $(lis[z]).children("a");
								var liText,liTextLength;
								if(liLink!==undefined){
									liText = liLink.html()!==null ? liLink.html() : "";
									liTextLength = liText.length;
									/*
									If the text in the li element is too long we change it
									Example: Ongoing Promotions => Ongoing Promo...
									*/
									
									var p = z;
									while(p < lengt){
										if(liTextLength > textMaxLength){
											textMaxLength = liTextLength;
										}
										p++;
									}
									$(lis[z]).css("width",textMaxLength*expText);
									if(parseInt($(ul[j]).css("left")) > 0) $(ul[j]).css("left",textMaxLength*expText);
									
									/*
									if(liTextLength > textMaxLength){
										liText = liText.substr(0,textMaxLength-2)+"...";
										$(lis[z]).children("a").html(liText);
									}*/
									
								}
								/*Change li element style when mouseover/out the link element a*/
								liLink.bind('mouseenter',function(){
									var $this = $(this).parent();
									$this.css("background-color","#FFFFFF");
								});
								liLink.bind('mouseleave',function(){
									var $this = $(this).parent();
									$this.css("background-color","#bcbcbc");
								});
								/*Open/Close a dropdown (subsection, sublist) in the dropdown*/
								(function(Area){
									var nextul;
									if(lis[Area].getElementsByTagName('ul') !== undefined){
										nextul = lis[Area].getElementsByTagName('ul')[0];
									}
									if(nextul!==undefined){
										lis[Area].onmouseover=function(){
											showmenu(nextul);
										}
										lis[Area].onmouseout=function(){
											hidemenu(nextul);
										}
									}
								})(z);
							}
							$(".closeTopSubMenu").css("width",textMaxLength*expText);
							$(".closeTopSubMenu > div#right").css("left",textMaxLength*expText-8);
							$(".closeTopSubMenu > div#center").css("width",textMaxLength*expText-8);
							$(".closeBottomMenu").css("width",textMaxLength*expText);
							$(".closeBottomMenu > div#right").css("left",textMaxLength*expText-8);
							$(".closeBottomMenu > div#center").css("width",textMaxLength*expText-16);
							if(z-1 > 0){
								lis[z-1].style.borderBottom = "none";
							}
							/*Open/Close the dropdown*/
							menuID.onmouseover=function(){
								showmenu(firstul);
							}
							menuID.onmouseout=function(){
								hidemenu(firstul);
							}
						}
					}
				}
			})(j);
		}
	}
}

$(function(){
	/*Isset DropDownMenu for the top Menu*/
	//loadSubMenus();
});
