/*
HoverSpot General Javascript functions
*/
//Variables for the promoExternalconsoles (buddy activity and favorites)
var promoExp1Data;
var promoExp2Data;
function showPromoExt(showWhat){
	var img = document.getElementById( 'recentactivitymyfaves');
	var promoExp1 = document.getElementById( 'promoExp1');	
	var promoExp2 = document.getElementById( 'promoExp2');
	var recentactivitymyfaves_Map0 = document.getElementById( 'recentactivitymyfaves_Map0');
	var promoConsoleDropDown =  document.getElementById( 'promoConsoleDropDown');	
	//alert('showWhat = ' + showWhat);
	if(!showWhat){
		
		if(promoExp1.style.display != 'none' || promoExp2.style.display != 'none'  ){
			img.src = 'images2/recentactivitymyfaves1.gif';
			promoExp1.style.display = 'none';
			promoExp2.style.display = 'none';
			recentactivitymyfaves_Map0.style.display = 'none';
			//recentactivitymyfaves_Map0.coords = "8,4,37,26";
			recentactivitymyfaves_Map0.style.coords = ''
			promoConsoleDropDown.style.marginBottom = '0px';			
		} else {
			img.src = 'images2/recentactivitymyfaves2.gif';
			promoExp1.style.display = '';
			promoExp2.style.display = 'none';		
			promoConsoleDropDown.style.marginBottom = '16px';
			loadBuddyActivity();
			
		}
	} else if (showWhat == 1) {
		img.src = 'images2/recentactivitymyfaves2.gif';
		promoExp1.style.display = '';
		promoExp2.style.display = 'none';
		promoConsoleDropDown.style.marginBottom = '16px';		
		loadBuddyActivity();
	} else if (showWhat == 2) {
		img.src = 'images2/recentactivitymyfaves3.gif';		
		promoExp1.style.display = 'none';
		promoExp2.style.display = '';		
		promoConsoleDropDown.style.marginBottom = '16px';		
		loadFavs();

	} else{
		img.src = 'images2/recentactivitymyfaves1.gif';

	}

	return false;
}

function loadBuddyActivity(){

	if(promoExp1Data){		 
		document.getElementById('promoExp1').innerHTML = promoExp1Data;
	} else {
		document.getElementById('promoExp1').innerHTML = '<div class="promosl2" style="text-align:center;"><img src="images2/loading/circle_white.gif" alt="Loading Memo Blasts . . ."><br>Loading Buddy Activity</div><img id="promoconsbot1" src="images2/promoconsbot.gif" border="0" alt="" usemap="#promoconsbot_Map" style="position:absolute; bottom:-29px; left:-1px; " />';
		var ajaxRequest;  
		
		try{
			// Opera 8.0+, Firefox, Safari
			ajaxRequest = new XMLHttpRequest();
		} catch (e){
			// Internet Explorer Browsers
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					// Something went wrong
					//alert("Your browser broke!");
					return false;
				}
			}
		}
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
				promoExp1Data = ajaxRequest.responseText;
				document.getElementById('promoExp1').innerHTML = promoExp1Data;
				
			}
		}
		ajaxRequest.open("GET", "ajax/promobuddyactivity.php", true);
		ajaxRequest.send(null); 
	}
}


function loadFavs(){

	if(promoExp2Data){		 
		document.getElementById('promoExp2').innerHTML = promoExp2Data;
	} else {
		document.getElementById('promoExp2').innerHTML = '<div class="promosl2" style="text-align:center;"><img src="images2/loading/circle_white.gif" alt="Loading Favroties . . ."><br>Loading Your Favorites</div><img id="promoconsbot1" src="images2/promoconsbot.gif" border="0" alt="" usemap="#promoconsbot_Map" style="position:absolute; bottom:-29px; left:-1px; " />';
		var ajaxRequest;  
		
		try{
			// Opera 8.0+, Firefox, Safari
			ajaxRequest = new XMLHttpRequest();
		} catch (e){
			// Internet Explorer Browsers
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					// Something went wrong
					//alert("Your browser broke!");
					return false;
				}
			}
		}
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
				promoExp2Data = ajaxRequest.responseText;
				document.getElementById('promoExp2').innerHTML = promoExp2Data ;
				
			}
		}
		ajaxRequest.open("GET", "ajax/rightfavsconsole.php", true);
		ajaxRequest.send(null); 
	}
}



/*
_____________________________________________________________________________________________
Skin Changing javascript
*/

function blastCB(){
	if (request.readyState == 4) {
			
//			alert('change color returned : '+request.responseText);
//			window.location.reload( false );
	}
}


function changeSkinTo(i){
//	alert('change to css #' + i);
	//Change the css file dynamically
	x = document.getElementById( 'mainCss');
//	x.styleSheet.href = "css/" + i + "/colordepend.css";

	try {
		x.styleSheet.href = "css/" + i + "/colordepend.css";
	} catch (failed) {
	}

	try {
		x.sheet.href = "css/" + i + "/colordepend.css";
	} catch (failed) {
	}

	//Change the indvidual table cells dynamically
	x = document.getElementById( 'header_toptilel');
	x.background = 'images2/' + i + '/toptilel.gif';
	x.style.backgroundImage='url(' + x.background + ')';

	name = 'toptilel';
	x = document.getElementById('header_'+name);
	x.background = 'images2/' + i + '/' + name + '.gif';
	x.style.backgroundImage='url(' + x.background + ')';

	name = 'tl';
	x = document.getElementById('header_'+name);
	x.src = 'images2/' + i + '/' + name + '.gif';


	name = 'logo';
	x = document.getElementById('header_'+name);
	x.src = 'images2/' + i + '/' + name + '.jpg';


	name = 'topback';
	x = document.getElementById('header_'+name);
	x.background = 'images2/' + i + '/' + name + '.jpg';
	x.style.backgroundImage='url(' + x.background + ')';

	name = 'menutile';
	x = document.getElementById('header_'+name);
	x.background = 'images2/' + i + '/' + name + '.gif';
	x.style.backgroundImage='url(' + x.background + ')';

	name = 'toptiler';
	x = document.getElementById('header_'+name);
	x.background = 'images2/' + i + '/' + name + '.jpg';
	x.style.backgroundImage='url(' + x.background + ')';

	name = 'tr';
	x = document.getElementById('header_'+name);
	x.src = 'images2/' + i + '/' + name + '.gif';

	name = 'bl';
	x = document.getElementById('header_'+name);
	x.src = 'images2/' + i + '/' + name + '.gif';

	name = 'br';
	x = document.getElementById('header_'+name);
	x.src = 'images2/' + i + '/' + name + '.gif';	

	var e=document.getElementsByTagName("body");
	for(var j=0; j<e.length; j++){
		x = e[j].style.backgroundColor;
		e[j].style.backgroundColor  = '#FFFFFF';		

		e[j].style.backgroundColor  = x ;		

	}
	




	try {
	  request = new XMLHttpRequest();
	} catch (trymicrosoft) {
	  try {
		request = new ActiveXObject("Msxml2.XMLHTTP");
	  } catch (othermicrosoft) {
		try {
		  request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (failed) {
		  request = false;
		}
	  }
	}

	request.onreadystatechange = blastCB ;		
	request.open("GET", "ajax30-changeskinto.php?r="+ Math.random() + "&i="+i, true);
	request.send(null);	


}


//xslow12345();
//window.setTimeout('xslow12345(2)',  500);
var ajaxRequest;
function checkNotifications(notifyType, functionToCall){
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				//alert("Your browser broke!");
				return false;
			}
		}
	}
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = setMiniHomeMessagesNotification;
		var url = "ajax/hasnotification.php?notifyType="+notifyType ;
		ajaxRequest.open("GET",url , true);
		ajaxRequest.send(null); 
//		alert('Requested '+url);
//		window.status='checkNotifications requested '+ url;
}


var setMiniHomeMessagesNotification = function (){
		
		if(ajaxRequest.readyState == 4 ){
//			alert('setMiniHomeMessagesNotification called  ajaxRequest.responseText  ='+ ajaxRequest.responseText  );
			if(ajaxRequest.responseText == '1' ){
				
				if(document.getElementById('promoConsoleMiniHome')){
					document.getElementById('promoConsoleMiniHome').innerHTML = 'New ';
				}
			} else {
				if(document.getElementById('promoConsoleMiniHome')){
					document.getElementById('promoConsoleMiniHome').innerHTML = '';				
				}
			}
			
		}	
}
