var sports3 = {   
//Start SNS Functions
   isSNSEnabled:function(){
	for (var i=0; i<snsEnabledProjects.length; i++) {
		if (snsEnabledProjects[i] == sportName)
		return true;
	}
	return false;
    },
 
    loginCheck:function() {
	var sitedomain = 'sitedomain=fanhouse.com';
	var url="siteState="+encodeURIComponent("OrigUrl="+encodeURIComponent(window.location));
	if(isUserLoggedIn) {
           VL6domElems.makeLogOutLink();
	} else {
           VL6domElems.makeLoginLink();
	 }
    },
//End SNS Functions

   addLoadEvent:function(func) {
      var oldonload = window.onload;
      if (typeof window.onload != 'function') {
          window.onload = func;
      } else {
         window.onload = function() {
            try{oldonload()}catch(e){};
            func();
         }
      }
   },
   onload:function(){
      $("#leftNav .listHead").click(sports3.toggleMenu);
      if($.browser.msie && $.browser.version < '7'){
         $("#leftNav .listHead").mouseover(sports3.mouseoverMenu);
         $("#leftNav .listHead").mouseout(sports3.mouseoutMenu);
      }
      sports3.loginCheck();
   }
}
var VL6domElems = {
	loginStatus: function (){return document.getElementById("loginStatus")},
	succUrl: function(){return "siteState="+encodeURIComponent("OrigUrl="+encodeURIComponent(window.location));},
	siteDomain:function(){return "sitedomain=fanhouse.com";},
	makeLoginLink: function(){
		if (VL6domElems.loginStatus()){
			if (document.getElementById('sns_screenname') && document.getElementById('sns_password')){
			}
			var loginLink = document.createElement("SPAN");
			loginLink.setAttribute("id", "loginLink"); 			
			loginLink.onclick = function (){
				var loginUrl = "https://my.screenname.aol.com/_cqr/login/login.psp?"+VL6domElems.siteDomain()+"&"+VL6domElems.succUrl();			                    document.location=loginUrl;
//				VL6domElems.makeIframe(loginUrl)
			}
			var loginText = document.createTextNode("Sign In / Register"); 
			loginLink.appendChild(loginText); 
			VL6domElems.loginStatus().appendChild(loginLink);
		}
	},
	makeLogOutLink: function(){
		if (VL6domElems.loginStatus() && (!(document.getElementById("logoutLink")))){
			var loggedInText = document.createTextNode("Logged In: ");
			var userName = document.createElement("span");   
			userName.setAttribute("id", "userName"); 	
			var userNameText = document.createTextNode(userScreenName); 
			userName.appendChild(userNameText);
			VL6domElems.loginStatus().appendChild(loggedInText);
			VL6domElems.loginStatus().appendChild(userName);
			var logoutLink = document.createElement("SPAN");
			logoutLink.style.cursor = "pointer";
			logoutLink.setAttribute("id", "logoutLink");
			logoutLink.onclick = function (){
				var logoutUrl = "https://my.screenname.aol.com/_cqr/logout/mcLogout.psp?"+VL6domElems.siteDomain()+"&"+VL6domElems.succUrl();			
                    document.location=logoutUrl;
				//VL6domElems.makeIframe(logoutUrl)
			}	
			var logoutText = document.createTextNode("Log Out"); 
			logoutLink.appendChild(logoutText); 
			VL6domElems.loginStatus().appendChild(logoutLink);	
		}
	},
	makeIframe: function(ifrmURL){
		var openAuthIframe = document.getElementById("openAuthIframe")
		openAuthIframe.style.display="block";
                var closeMe = null;
                var ifrm = null;
                if(openAuthIframe.getElementsByTagName("IFRAME").length > 0){
                   closeMe = openAuthIframe.getElementById("closeMe");
                   if(closeMe){
                     closeMe.parentNode.removeChild(closeMe);
                   }
                   ifrm = openAuthIframe.getElementsByTagName("IFRAME")[0];
                   ifrm.parentNode.removeChild(ifrm);
                }
		closeMe = document.createElement("DIV");
		closeMe.setAttribute("id", "closeMe");
		var closemelink = document.createElement("A");
		closemelink.setAttribute("href", "#");
		closemelink.onclick = function (){
			document.getElementById("openAuthIframe").style.display="none";
		}
		var closemeimg = document.createElement('img');
		closemeimg.src="http://www.blogsmithmedia.com/www.spinner.com/media/closeme.jpg";
		closemelink.appendChild(closemeimg);	
		closeMe.appendChild(closemelink);
		openAuthIframe.appendChild(closeMe);
		ifrm = document.createElement("IFRAME");	
		ifrm.setAttribute("frameborder","0");
		ifrm.src = ifrmURL; 
		ifrm.style.border= "0px";
		ifrm.setAttribute("frameborder", "0"); 
		ifrm.style.backgroundColor = "#fff";
		openAuthIframe.appendChild(ifrm);
	},
	hideLoginLink: function(){
		while (VL6domElems.loginStatus().firstChild) 
		 {
			VL6domElems.loginStatus().removeChild(VL6domElems.loginStatus().firstChild);
		 };
	},
	hideLogOutLink: function(){
		while (VL6domElems.loginStatus().firstChild) 
		 {
			VL6domElems.loginStatus().removeChild(VL6domElems.loginStatus().firstChild);
		 };
	},
	hideIframe: function(){
		if (document.getElementById("openAuthIframe")){
			var openAuthIframe = document.getElementById("openAuthIframe");
			openAuthIframe.style.display="none";
			while (openAuthIframe.firstChild) {
    				openAuthIframe.removeChild(openAuthIframe.firstChild);
			}
		}
	},
	clearForm: function(){
		if (document.getElementById('cmtuinfo_sns')){
			var snsInput = getElementsByClassName(document, "input", "formtext");
			for(a=0; a<snsInput.length; a++) {
				snsInput[a].value = '';
			}
		}
	}
}

sports3.addLoadEvent(sports3.onload);

