<?xml version="1.0" encoding="UTF-8" ?>
<Module>
 <ModulePrefs title="MediaPops" scrolling="false" title_url="http://mediapops.com" author="MediaPops.com" author_email="mediapopsinc+widget@gmail.com" author_affiliation="MediaPops.com" 
 author_location="Seattle, WA" singleton="true" author_link="http://mediapops.com" screenshot="http://mediapops.com/art/widgetScreenshot.jpg" thumbnail="http://mediapops.com/art/logoSocialDirectory.gif" description="Never miss another new release! Tell us your favorite bands, authors, movies and games, and we'll bring all their new releases to you.">
 	<Locale lang="en" country="us" />
   <Require feature="opensocial-0.5"/>
   <Require feature="setprefs"/>
   <Require feature="analytics"/>
 </ModulePrefs>
 
 <UserPref name="ID" default_value="0" datatype="hidden"/>
    
 <Content type="html">
 <![CDATA[

 <script type="text/javascript">
 
 	// Remember about the caching refreshInterval below.
 	var container, canvasWidth, canvasHeight, profileWidth, profileHeight, currentButton, containerArtDir, isContainer, gadgetID;
 	var prefs, isOwner, owner, viewer, ownerName, ownerID, viewerName, viewerID, screenMode;
 	currentButton				= 'music';
 	var q 						= document.URL.substring((document.URL.indexOf('?') +1),document.URL.length);
	var baseURL					= "http://mediapops.com";
	
	if (q.indexOf("myspace") >= 0) { 
		container 					= 'MySpace';
		isContainer					= 'T';
		canvasWidth 				= 765;
		canvasHeight 				= 600;
		profileWidth 				= 420;
		profileHeight 				= 130;
		containerArtDir 			= baseURL + "/art/OS-Ning";
		doTrack("Load");
	}
	
	if (q.indexOf("ning") >= 0) { 
		container 					= 'Ning';
		isContainer					= 'T';
		canvasWidth 				= 765;
		canvasHeight 				= 600;
		profileWidth 				= 420;
		profileHeight 				= 130;
		containerArtDir 			= baseURL + "/art/OS-Ning";
		doTrack("Load");
	}
	
	if (q.indexOf("orkut") >= 0) { 
		container 				= 'Orkut';
		isContainer				= 'T';
		canvasWidth 			= 765;
		canvasHeight 			= 600;
		profileWidth 			= 540;
		profileHeight 			= 200;
		containerArtDir 		= baseURL + "/art/OS-Orkut";
		doTrack("Load");
	}
	
	if (q.indexOf("google.com") >= 0) { 
		container 				= 'iGoogle'; 
		isContainer				= 'F';
		canvasWidth 			= 765;
		canvasHeight 			= 600;
		profileWidth 			= 540;
		profileHeight 			= 200;
		containerArtDir 		= baseURL + "/art/OS-Google";
		doTrack("Load");
		prefs 					= new _IG_Prefs();
		gadgetID 				= prefs.getInt("ID");
		if (gadgetID == 0) 		{ 
			gadgetID 			= Math.floor(Math.random() * 99999999999); 
			prefs.set("ID", gadgetID);
		}
	}
	
	
	function doTrack(msg) {
		msg = "/Widget-" + container + "-" + msg;
		_IG_Analytics("UA-2508249-1", msg);
	}
	
	
	
	function startUp() {
		var homeURL;
		
		document.getElementById('message').innerHTML = 'Loading...';
		
		if (isContainer == 'T') {
			var req = opensocial.newDataRequest();
			req.add(req.newFetchPersonRequest('OWNER'), 'owner');
			req.add(req.newFetchPersonRequest('VIEWER'), 'viewer');
			req.send(onLoadEnv);
		}
		else {
			ownerID 			= gadgetID;
			isOwner				= "T";
			screenMode 			= "NA";
			homeURL				= baseURL + "/cgi-bin/showHomeOS.cgi?O=" + ownerID + "&ISO=" + isOwner + "&M=" + screenMode + "&C=" + container;
			_IG_FetchContent(homeURL, function (responseText) { document.getElementById('message').innerHTML = responseText; }, { refreshInterval: 0 });
		}
	}
	
	

	function doGlow(type) {
		if (currentButton != type) { 
			document.getElementById(type).src = containerArtDir + "/" + type + "Glow.jpg";
		}
	}
	
	function doOut(type) {
		if (currentButton != type) { 
			document.getElementById(type).src = containerArtDir + "/" + type + ".jpg";
		}
	}
	
	
	
	
	
	function loadPanel(type) {
	
		if (type == 'music') {
			setButton(type);
			P7AniMagic('mainContent',0,0,100,20,0,0);
		}
		
		if (type == 'words') {
			setButton(type);
			tmp = (0 - profileWidth) - 4;
			P7AniMagic('mainContent',tmp,0,100,20,0,0);
		}
	
		if (type == 'movies') {
			setButton(type);
			tmp = 2 * (0 - profileWidth) - 8;
			P7AniMagic('mainContent',tmp,0,100,20,0,0);
		}
		
		if (type == 'games') {
			setButton(type);
			tmp = 3 * (0 - profileWidth) - 12;
			P7AniMagic('mainContent',tmp,0,100,20,0,0);
		}
		
		if (type == 'concerts') {
			setButton(type);
			tmp = 4 * (0 - profileWidth) - 16;
			P7AniMagic('mainContent',tmp,0,100,20,0,0);
		}
		
		if (type == 'favs') {
			setButton(type);
			tmp = 5 * (0 - profileWidth) - 20;
			P7AniMagic('mainContent',tmp,0,100,20,0,0);
		}
		
		tmp = type + "Click";
		doTrack(tmp);
	}
	
	
	function loadPanelNoSlide(button,type) {
		setButton(button);
		hideAll();
		show(type);
		tmp = type + "Click";
		doTrack(tmp);
	}
	
	
	function show(id) {
		document.getElementById(id).style.display 	= 'block';
	}
	
	
	function hide(id) {
		document.getElementById(id).style.display 	= 'none';
	}
	
	
	function killWelcome() {
		hide('welcome'); 
		show('navbar');
		show('musicPanel');
		doTrack("FirstLoad");
	}
	
	
	function showLogin() {
		hideAll();
		show('login');
	}
	
	
	function hideAll() {
		document.getElementById('musicPanel').style.display 		= 'none';
		document.getElementById('wordsPanel').style.display 		= 'none';
		document.getElementById('moviesPanel').style.display 		= 'none';
		document.getElementById('gamesPanel').style.display 		= 'none';
		document.getElementById('concertsPanel').style.display 		= 'none';
		document.getElementById('favsPanel').style.display 			= 'none';
		document.getElementById('login').style.display 				= 'none';
	}
	
	
	
	function setButton(type) {
		currentButton		= type;
		document.getElementById('music').src 	= containerArtDir + "/music.jpg";
		document.getElementById('words').src 	= containerArtDir + "/words.jpg";
		document.getElementById('movies').src 	= containerArtDir + "/movies.jpg";
		document.getElementById('games').src 	= containerArtDir + "/games.jpg";
		document.getElementById('concerts').src = containerArtDir + "/concerts.jpg";
		document.getElementById('favs').src 	= containerArtDir + "/favs.jpg";
		document.getElementById(type).src 		= containerArtDir + "/" + type + "Down.jpg";
	}
	
	
	
	
	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}

	function P7AniMagic(el,x,y,a,b,c,s) { //v2.9 PVII-Project Seven Development
	 var xx,yy,i,g,elo=el,f="",m=false,d="",pa='px';if(document.layers||window.opera){pa='';}
	 x=parseInt(x);y=parseInt(y);var t='g.p7Magic=setTimeout("P7AniMagic(\''+elo+'\','; 
	 if((g=MM_findObj(el))!=null){d=(document.layers)?g:g.style;}else{return;}
	 if(parseInt(s)>0){eval(t+x+','+y+','+a+','+b+','+c+',0)",' + s+')');return;}
	 xx=parseInt(d.left);if(isNaN(xx)){if(g.currentStyle){xx=parseInt(g.currentStyle.left);
	 }else if(document.defaultView&&document.defaultView.getComputedStyle){
	 xx=parseInt(document.defaultView.getComputedStyle(g,"").getPropertyValue("left"));}
	 if(isNaN(xx)){xx=0;}}yy=parseInt(d.top);if(isNaN(yy)){if(g.currentStyle){yy=parseInt(g.currentStyle.top);
	 }else if(document.defaultView&&document.defaultView.getComputedStyle){
	 yy=parseInt(document.defaultView.getComputedStyle(g,"").getPropertyValue("top"));}
	 if(isNaN(yy)){yy=0;}}if(c==1){x+=xx;y+=yy;m=true;c=0;}else if(c==2){m=false;
	 if(g.p7Magic){clearTimeout(g.p7Magic);}}else{i=parseInt(a);if(g.p7Magic){clearTimeout(g.p7Magic);}
	 if(xx<x){xx+=i;m=true;if(xx>x){xx=x;}}if(xx>x){xx-=i;m=true;if(xx<x){xx=x;}}
	 if(yy<y){yy+=i;m=true;if(yy>y){yy=y;}}if(yy>y){yy-=i;m=true;if(yy<y){yy=y;}}}
	 if(m){d.left=xx+pa;d.top=yy+pa;eval(t+x+','+y+','+a+','+b+','+c+',0)",'+b+')');}
	}


	function checkAccess() {
		
		if (isContainer == 'F') { return true; }
		
		if (ownerID != viewerID) { 
			alert('Sorry, only ' + ownerName + ' can do that.'); 
			return false;
		}
		else { return true; }
	}
	

	function doBookmarkClick(theID, userID) {
		access = checkAccess();
		if (access == false) { return; }
		
		doTrack("ItemHotlisted");
		theBookmarkText = theID + "-bookmark";
		theText 		= document.getElementById(theBookmarkText);
		var theURL 		= baseURL + "/cgi-bin/saveBookmark.cgi?USERID=" + userID + "&ID=" + theID;
		theText.innerHTML = "saving...";
		tmp = "<a href=\"javascript:doBookmarkUnClick('" + theID + "' , " + userID + ");\">un-hotlist</a>";
		_IG_FetchContent(theURL, function (responseText) { 
			theText.innerHTML = tmp; 
			thePanel 		= document.getElementById('hotlist');
			thePanel.innerHTML = "Loading...";
			theURL 			= baseURL + "/cgi-bin/loadWidgetHotlist.cgi?USERID=" + userID;
			_IG_FetchContent(theURL, function (responseText) { thePanel.innerHTML = responseText; }, { refreshInterval: 0 });
		}, { refreshInterval: 0 });
	}
	
	
	
	
	function doBookmarkUnClick(theID, userID) {
		access = checkAccess();
		if (access == false) { return; }
		doTrack("ItemUnHotlisted");
		theBookmarkText = theID + "-bookmark";
		theBookmarkText2 = theBookmarkText + "2";
		theText 		= document.getElementById(theBookmarkText);
		theText2 		= document.getElementById(theBookmarkText2);
		var theURL 		= baseURL + "/cgi-bin/deleteBookmark.cgi?USERID=" + userID + "&ID=" + theID + "&ISWIDGET=T";
		if (theText) 	{ theText.innerHTML = "saving..."; }
		theText2.innerHTML = "saving...";
		tmp = "<a href=\"javascript:doBookmarkClick('" + theID + "' , " + userID + ");\">add to hotlist</a>	";
		_IG_FetchContent(theURL, function (responseText) { 
			if (theText) { theText.innerHTML = tmp; }
			thePanel 		= document.getElementById('hotlist');
			thePanel.innerHTML = "Loading...";
			theURL 			= baseURL + "/cgi-bin/loadWidgetHotlist.cgi?USERID=" + userID;
			_IG_FetchContent(theURL, function (responseText) { thePanel.innerHTML = responseText; }, { refreshInterval: 0 });
		}, { refreshInterval: 0 });
	}


function sendZipCode() {
	var zipCode 	= document.getElementById("ZIP").value;
	var email 		= document.getElementById("EMAIL").value;
	var pass	 	= document.getElementById("PASS").value;
	var username 	= document.getElementById("USERNAME").value;
	var city	 	= document.getElementById("CITY").value;
	var state	 	= document.getElementById("STATE").value;
	if (zipCode=='') 	{ alert('Please enter a US zipcode.'); 	return;	}
	if (email=='') 		{ alert('Please enter a valid email.'); return; }
	if (pass=='') 		{ alert('Please enter a password.'); 	return; }
	if (username=='') 	{ alert('Please enter a username.'); 	return; }
	if (city=='') 		{ alert('Please enter a city.'); 		return; }
	if (state=='*') 	{ alert('Please enter a state.'); 		return; }
	doTrack("AccountRegistered");
	var homeURL		= baseURL + "/cgi-bin/showHomeOS.cgi?O=" + ownerID + "&CITY=" + city + "&STATE=" + state + "&ISO=" + isOwner + "&M=" + screenMode + "&C=" + container + "&ZIP=" + zipCode + "&EMAIL=" + email + "&PASS=" + pass + "&USERNAME=" + username;
	_IG_FetchContent(homeURL, function (responseText) { document.getElementById('concertsData').innerHTML = responseText; document.getElementById("concertsData").scrollTop = 0; }, { refreshInterval: 0 });
}




function sendLogin() {
	var email 		= document.getElementById("EMAILLOGIN").value;
	var pass	 	= document.getElementById("PASSLOGIN").value;
	if (email=='') 		{ alert('Please enter a valid email.'); return; }
	if (pass=='') 		{ alert('Please enter a password.'); 	return; }
	doTrack("AccountLinked");
	var homeURL		= baseURL + "/cgi-bin/showHomeOS.cgi?EMAILLOGIN=" + email + "&PASSLOGIN=" + pass + "&O=" + ownerID + "&ISO=" + isOwner + "&M=" + screenMode + "&C=" + container;
	document.getElementById('message').innerHTML = "Logging in...";
	_IG_FetchContent(homeURL, function (responseText) { document.getElementById('message').innerHTML = responseText; document.getElementById("message").scrollTop = 0; }, { refreshInterval: 0 });
}




  function onLoadEnv(dataResponse) {
  
    owner 		= dataResponse.get('owner').getData();
    viewer 		= dataResponse.get('viewer').getData();
    ownerName 	= owner.getDisplayName(); 
    ownerID 	= owner.getId();
    viewerName	= viewer.getDisplayName();
    viewerID	= viewer.getId();
	
	var q = document.URL.substring((document.URL.indexOf('?') +1),document.URL.length);
	if (q.indexOf("profile") >= 0) { screenMode = 'profile'; }
	if (q.indexOf("canvas") >= 0) { screenMode = 'canvas'; }
	
	if (ownerID == viewerID) { isOwner = 'T' }
	else { isOwner = 'F'; }
	if (isContainer == 'F') { isOwner = 'T'; }
	
	var homeURL		= baseURL + "/cgi-bin/showHomeOS.cgi?O=" + ownerID + "&ISO=" + isOwner + "&M=" + screenMode + "&C=" + container + "&ON=" + ownerName;
	_IG_FetchContent(homeURL, function (responseText) { document.getElementById('message').innerHTML = responseText; }, { refreshInterval: (60 * 10) });
	
  };
  
  
  
  
	
  
	_IG_RegisterOnloadHandler(startUp);
	
  </script>
  <div id="message"> </div>
  ]]>
  </Content>
</Module>



