if(disabledButton==null && enabledButton==null) {
	var disabledButton=null;
	var enabledButton=null;
}

function toggleImage(id, imageSrc){
    $("#"+id).attr("src", imageSrc);
}

function toggleImageOn(leftImg, midImg, rightImg,imgSRC_L, index){
   $(leftImg+index).attr("src", imgSRC_L);
   $("#linkId"+index).css("color","#00356c");
	if(document.getElementById(midImg+index).className=='butOff'){
		document.getElementById(midImg+index).className='butOn';
	}
}
function toggleImageOff(leftImg, midImg, rightImg,imgSRC_L, index){
	$("#linkId"+index).css("color","#FFFFFF");
    $(leftImg+index).attr("src", imgSRC_L);		
	if(document.getElementById(midImg+index).className=='butOn'){
		document.getElementById(midImg+index).className='butOff';
	}
}

function reloadParent(){
  if (window.ActiveXObject) 
  {
    parent.parent.parent.history.go(0);
  } 
  else if (window.XMLHttpRequest) 
  {
  	window.parent.parent.location.reload();	
  }
}

function getFlashMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	
	return (isIE) ? window[movieName] : document[movieName];
}

function reloadFeatureXml() {

	getFlashMovie('CategoryModule').loadFlashFeatureXML();
}

function loadFeatureXMLComplete() {
	
	featureXMLComplete = true;
}

function postLoginReload() {

	var url = window.location.href;
	if(url.match(/\?/)) {
		window.location.href = url + "&eadm=true";
	}
	else {
		window.location.href = url + "?eadm=true";
	}
}
function triggerClick(id) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	
	if(document.getElementById(id) != null) {
		if(isIE)
			document.getElementById(id).click();
		else
			$('#'+id).click();
	}
}

function getURLParamByName(name, url) {
	
	if(url == null) 
		url = window.location.href;
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	if(url != null)
		var results = regex.exec( url );
	else
		var results = regex.exec( url );
	if( results == null )
		return null;
	else
		return results[1];
}

function submitTBForm(form) {
		
	$.ajax({
	  type: "POST",
	  url: form.action,
	  data: joinPostData(form),
	  success: function(html){
	  		$("#TB_ajaxContent").html(html);
	  }
	});
}

function doAjaxPost(divId, form) {
		
	$.ajax({
	  type: "POST",
	  url: form.action,
	  data: joinPostData(form),
	  success: function(html){
	  		$("#"+divId).html(html);
	  }
	});
}

function postLoginProductRefresh(refreshUrl, buyNowLink) {

	$('#header').load('/header.html', function(responseText, textStatus, XMLHttpRequest) {
			 	$('#rightOne').load(refreshUrl, function(responseText, textStatus, XMLHttpRequest) {
			 		if($("#"+buyNowLink)) {
			 			triggerClick(buyNowLink);	 	
			 		}
				 	tb_remove();
			 	});
			}
    );
}

function joinPostData(oForm) {

    var aParams = new Array();
	for (var i=0 ; i < oForm.elements.length; i++) {
		var sParam = encodeURIComponent(oForm.elements[i].name);
		sParam += "=";;
		if(oForm.elements[i].type == "checkbox") {
			if(oForm.elements[i].checked) {
				sParam += encodeURIComponent("true");
				aParams.push(sParam);
			}
			else {
				sParam += encodeURIComponent("false");
				aParams.push(sParam);
			}
		}
		else if(oForm.elements[i].type == "radio") {
			if(oForm.elements[i].checked) {
				sParam += encodeURIComponent(oForm.elements[i].value);
				aParams.push(sParam);
			}
		}
		else {
			//alert("name: "+oForm.elements[i].name+ " value: "+oForm.elements[i].value);
			sParam = encodeURIComponent(oForm.elements[i].name);
			sParam += "=";
			sParam += encodeURIComponent(oForm.elements[i].value);
			aParams.push(sParam);
		}
	}

    return aParams.join("&");
}

function loadProductDetail(productId, userOwned, count) {
	
	if(userOwned != 'true' || userOwned == null) {
		var style = 'left';
		if(count > 3)
			style = 'right';
		linkCodeFiveParameters(this, 'Learn More', productId, 'featured item '+count, 'featured');
		scAjax('productDetail.html?productId='+productId+'&layerDiv=featDiv'+count+'&buyNowLinkDiv=featBuyLink'+count+'&style='+style, 'featDiv'+count, 'GET');
		
		
	}
}

function getCategoryFeatureXmlUrl() {
	
	url = "categoryFeatureXml.html?r="+Math.random();	
	if(getURLParamByName("categoryId"))
		url = "categoryFeatureXml.html?categoryId=" + getURLParamByName("categoryId") + "&r="+Math.random();
		
	return url;
}

function loadFeatureXMLComplete() {
	//alert('loadFeatureXMLComplete');
	return true;
}
//************* cahngeColor Script Start *********************
var allLinkId = new Array();
var counter=0;
function changeColor(linkId){
	allLinkId[counter]=linkId;
	if(counter==0)
		$('#'+allLinkId[counter]).css('color', '#003667');
	else{
		$('#'+allLinkId[counter-1]).css('color', '#ffffff');
		$('#'+allLinkId[counter]).css('color', '#003667');
	}
	counter++;
}
//************* cahngeColor Script End *********************

//************* Left Navigation Script Start *********************
var allPageTags = new Array();
var offClass='subLinkContainerOff';
var childID;
var oldChildID= new Array();
var oldOpenID= new Array();
var count=0;
onClass="subLinkContainer";
function openChildTab(childID, openId) {
oldChildID[count]=childID;
oldOpenID[count]=openId;    
if(childID == "parentLink"){
 var allPageTags=document.getElementsByTagName("*");
  for (i = 0; i < allPageTags.length; i++) {
  	if (allPageTags[i].className == onClass) 
  		allPageTags[i].className = offClass;
  	if (allPageTags[i].className == 'subChildOn') 
  		allPageTags[i].className = 'subChildOff';
  }
  openTab='sub_'+openId;
  for (i=0; i<allPageTags.length; i++)
   if (allPageTags[i].id==openTab)
    allPageTags[i].className=onClass;
}
else{
 var allPageTags=document.getElementsByTagName("*");
  for (i=0; i<allPageTags.length; i++){
       if (allPageTags[i].className==onClass){
          allPageTags[i].className=offClass;
        if (oldChildID[count - 1] != "parentLink"){
			if(document.getElementById(oldChildID[count - 1])!=null){ 
	           document.getElementById(oldChildID[count - 1]).className='subChildOff';
			}
        }
      }
    }
  openTab='sub_'+openId;
  for (i=0; i<allPageTags.length; i++)
  {
       if (allPageTags[i].id==openTab){
        allPageTags[i].className=onClass; 
		if(document.getElementById(childID)!=null){
        	document.getElementById(childID).className='subChildOn';
		}
       }
   }
 }
 count++;
} 

function closeAllTab(){
	var allPageTags=document.getElementsByTagName("*");
  	for (i=0; i<allPageTags.length; i++)
  	 if (allPageTags[i].className==onClass)
   		allPageTags[i].className=offClass;
}
//************* Left Navigation Script End *********************

function hide()
{
	
	if(document.getElementById("hideSubmit")!=null)
	{
		document.getElementById("hideSubmit").style.display='none';
	}
	if(document.getElementById("disableSubmit")!=null)
	{
		document.getElementById("disableSubmit").style.display='block';
	}
}

function hideById(divId,disableID)
{
	document.getElementById(divId).style.display='none';
	document.getElementById(disableID).style.display='block';
}

function toggleButtonOnOff(disableId, enableId, clear) {
	
	if(document.getElementById(disableId) != null && document.getElementById(enableId) != null) {
		disabledButton = disableId;
		enabledButton = enableId;
		document.getElementById(disableId).style.display='none';
		document.getElementById(enableId).style.display='block';
	}
	
	if(clear == true) {
		disabledButton = null;
		enabledButton = null;
	}
}

function show()
{
	document.getElementById("hideSubmit").style.display='block';
	document.getElementById("disableSubmit").style.display='none';
}

function setFocus(){
	if(document.getElementById("emailBox").value!=""){
		$('#passwordBox').focus();
	}
	else{
		$('#emailBox').focus();
	}	
}

function displayDigitalAgreement(location)
{
	if(document.getElementById('trans')!=null)
	{
		document.getElementById('billingInfoEditContainer').style.display='none';
		document.getElementById('trans').style.display='block';
		if(location=='billingInfo')
		{
			document.getElementById('divHeight').style.height='465px'; 
		}
		else
		{
			document.getElementById('divHeight').style.height='435px';
		}
	}
	document.getElementById('layerAgreement').style.display='block';
}

function hideAgreement()
{
	document.getElementById('layerAgreement').style.display='none';
	if(document.getElementById('trans')!=null)
	{
		document.getElementById('billingInfoEditContainer').style.display='block';
		document.getElementById('trans').style.display='none';
	}
}

function showBuyNowLoading(loadingText) {
	
	document.getElementById('layerPopHdr').innerHTML = "<img src='images/trans.gif' width='24' height='24' border='0' />";

	var html = "<table id='buyNowLoading'><tr><td align='center'><div style='color:#3572C3;font-size:15px;font-weight:bold;'>"+loadingText+"</div></td></tr>"
	html += "<tr><td align='center'>&nbsp;</td></tr><tr><td align='center'>&nbsp;</td></tr>";
	html += "<tr><td align='center'><img id='ajaxIcon1' src='images/ajaxLoadingBig.gif'/></td></tr>";
	html += "<tr><td align='center'>&nbsp;</td></tr><tr><td align='center'>&nbsp;</td></tr><tr><td align='center'>&nbsp;</td></tr></table>";
	
	document.getElementById('layerPopContent').innerHTML = html;
	
	
}

function checkBox() 
{
	var cId = document.getElementById('eadmInstalled').checked;
	if(cId)
	{
		document.getElementById('eadmChecked').style.display = 'block';
		document.getElementById('eadmUnchecked').style.display = 'none';
	}
	else
	{
		document.getElementById('eadmUnchecked').style.display = 'block';
		document.getElementById('eadmChecked').style.display = 'none';
	}
}

function displaySuccessDiv(eadmLink)
{
	document.getElementById('eadm_iframe').innerHTML = "<iframe id='eadmframe' src='"+eadmLink+"' style='display:none;width:0px; height:0px; border: 0px;'></iframe>";
	
	document.getElementById('eadmInstalledDiv').style.display = 'none';
	document.getElementById('successMessageDiv').style.display = 'block';
}

function displayDownloadLaterDiv()
{
	document.getElementById('eadmInstalledDiv').style.display = 'none';
	document.getElementById('eadmDownloadLaterDiv').style.display = 'block';
}

function preloadImages()
{
	var myimages = new Array();
	function preloading(){
		for (x=0; x<preloading.arguments.length; x++){
			myimages[x] = new Image();
			myimages[x].src = preloading.arguments[x];
		}
	}
	preloading("images//butRep.gif","images//butRep_on.gif","images//hdL.gif","images//hdL_on.gif","images//hdR.gif","images//hdR_on.gif","images//hiL.gif","images//hiL_on.gif","images//cLft.gif","images//cLft_on.gif","images//hLft.gif","images//hLft_on.gif","images//coLft.gif","images//coLft_on.gif");
}

/*	
	This function enables the login url in header.
	When any page loads, the user will not be able to click the login url untill this function is called.
	The id's 'loginUrlDisabled' and 'loginUrlEnabled' are defined in header.jsp.
*/

function replaceLoginLink()
{
	if(document.getElementById("loginUrlDisabled")!=null)
	{
		$("#loginUrlDisabled").css("display","none");
		$("#loginUrlEnabled").css("display","inline");
	}
	
	if(document.getElementById("myaccountUrlDisabled")!=null)
	{		
		$("#myaccountUrlDisabled").css("display","none");
		$("#myaccountUrlEnabled").css("display","inline");
	}
	
	if(document.getElementById("feedbackUrlDisabled")!=null)
	{
		$("#feedbackUrlDisabled").css("display","none");
		$("#feedbackUrlEnabled").css("display","inline");
	}
}

function itemFilter(refreshUrl){

	var refreshUrl = window.location.pathname + window.location.search + "&ajax=true" +"&r="+Math.random();
	$("#itemFilterCloseLink").attr("onclick", "return false;");
	$("#itemFilterImg").attr("src", "/images/ajexloading.gif");
	$("#itemFilterBtn").attr({onclick: "return false;", style: "height:20px;width:auto;"});
	
	var simsGames = document.getElementsByName('simsGameItems');
	var simsGamesStr;
	for(var i = 0;i < simsGames.length; i++) {
		if(simsGames[i].checked) {
			if(simsGamesStr == null)
				simsGamesStr = simsGames[i].value;
			else 
				simsGamesStr += ','+simsGames[i].value;
		}
	}
	
	$.cookie('itemFilters', null);
	$.cookie('itemFilters', simsGamesStr, { expires: 99999 });
	
	if(document.getElementById('itemFilterSuccess')!=null)
		document.getElementById('itemFilterSuccess').style.display = 'block';
	
	
	$('#rightOne').load(refreshUrl,null,function() {
			tb_remove();
	});
}
function hideAd()
{
	if(document.getElementById("hideAd")!=null)
		document.getElementById("hideAd").style.display='none';
}
function showAd()
{
	if(document.getElementById("hideAd")!=null)
		document.getElementById("hideAd").style.display='block';
}

function redeemCashCode(serverName, formName) {

	$.get("https://"+serverName+"/jsonChkDefaultBillingAddr.html?r="+Math.random()+"&callback=", 
		function(data){
			var result = eval(data);
			if(result.loggedIn == true) {
				if(result.hasDefaultBillingAddrId == true) {
					$('#redeemAjaxIcon').attr('src', 'images/ajexloading.gif');
					document.forms[formName].submit();
				}
				else {
					tb_show(null,'zipCodeLayer.html?height=400&width=380&modal=true',false);
				}
			}
			else {
				window.location = "/sessionExpired.html";
			}
        },
        'text'
        );
}

function voidFn() {
	return;
}

var redeemFormNames =new Array("buyMoreSimPoints","redeemCode");

function doRedeem() {
	
	for(formName in redeemFormNames) {
		if(document.forms[formName] != null) {
			document.forms[formName].submit();
		}
	}
}