function contentViewer(config)
{
	//init variables from config array
	this.ajaxCall						= config['ajaxCall'];
	this.currPage 					= config['currPage'];				// current page of the viewer
  this.numPages 					= config['numPages'];				// number of pages of the viewer
  this.offset							= config['offset'];
	this.prodsPerPage 			= config['limit'];					// how many items to show per page
	this.sectorId 					= config['sectorId'];				// sector Id
	this.subcatId						= config['subcatId'];				// subcat Id
	this.progressId					= config['progressId'];				// subcat Id
	this.fadeVal						= config['fade'];					// # of seconds for fade effect
	this.type							  = config['type'];					// type of content
	this.page							  = config['page'];					// page of content
	this.sectorName					= config['sectorName'];				// sectorName
	this.aapholder					= config['albumArtPlaceHolder'];	// path to the albumArt placeholder
	this.aapreview					= config['albumArtPreview'];		// path to the albumArt preview
	this.aabig							= config['albumArtBig'];			// path to the large albumArt
	this.aabigpreview				= config['albumArtBigPreview'];			// path to the large albumArt
	this.tabImage						= config['tabImage'];				// path to the tab image
	this.tabSelectedImage		= config['tabSelectedImage'];		// path to the selected tab image
	this.sector							= config['sector'];
	this.msisdn							= config['msisdn'];
	this.artistId						= config['artistId'];
	this.orderby						= config['orderby'];
	this.response						= '';								// ajax response
	this.max							  = 0;
	this.limit							= 0;
	this.currProduct				= 1;								// current item we're viewing
	this.container					= '';								// container of the items
	this.name 							= (config['name']==null||config['name']=='')?this.type:config['name'];
	this.nImagesLoaded			= 0;
	this.filter             = config['filter']; //added for community's message retrieval to filter out the message type (inbox, deleted, sent,...etc)
	this.passportId         = config['passportId']; //Passport ID
	this.groupId            = config['groupId']; //group ID
	
	var me 								  = this; //this javascript object
	
	//prevProducts function
	this.prevProducts = function() {
		
		var prevPage = $(this.name+'_prevPage');
		var nextPage = $(this.name+'_nextPage');
		
		if (prevPage)
		{
			prevPage.setAttribute("onClick","");
		}
		
		if (nextPage)
		{
			nextPage.setAttribute("onClick","");
		}
		// Steps back a page
		this.currPage--;
		
		// if the current page is less than 1, 
		// we start from the end
		if (this.currPage < 1)
		{
			this.currPage = this.numPages;
		}
		for (var i = 1; i <= this.numPages; i++)
		{
			if ( $(this.name+'Top_page_'+i))
			{
			    $(this.name+'Top_page_'+i).className = 'navPage';
			}
			if ($(this.name+'_pageDiv_'+i))
			{
				$(this.name+'_pageDiv_'+i).setAttribute("onClick","");
			}
		}
		if ( $(this.name+'Top_page_'+this.currPage))
		{
		    $(this.name+'Top_page_'+this.currPage).className = 'navPageSelected';
		}
		
		for (var i = 1; i <= this.numPages; i++)
		{
			if ( $(this.name+'Bot_page_'+i))
			{
			    $(this.name+'Bot_page_'+i).className = 'navPage';
			}
		}
		if ( $(this.name+'Bot_page_'+this.currPage))
		{
		    $(this.name+'Bot_page_'+this.currPage).className = 'navPageSelected';
		}
		
		for (var i = 1; i <= this.numPages; i++)
		{
			if ( $(this.name+'_page_'+i))
			{
			    $(this.name+'_page_'+i).className = 'navPage';
			}
		}
		if ( $(this.name+'_page_'+this.currPage))
		{
		    $(this.name+'_page_'+this.currPage).className = 'navPageSelected';
		}
		this.runRequest();
	};
	
	//nextProducts function
	this.nextProducts = function() {
		
		// Steps forward a page
		this.currPage++;
		
		var prevPage = $(this.name+'_prevPage');
		var nextPage = $(this.name+'_nextPage');
		
		if (prevPage)
		{
			prevPage.setAttribute("onClick","");
		}
		
		if (nextPage)
		{
			nextPage.setAttribute("onClick","");
		}
		
		// if the current page is greater than the number of pages, 
		// we start from 1
		if (this.currPage > this.numPages)
		{
			this.currPage = 1;
		}
		
		// loop through all the pages and if an image exists,
		// give it the default tab image
		for (var i = 1; i <= this.numPages; i++)
		{
			if ( $(this.name+'Top_page_'+i) )
			{
			    $(this.name+'Top_page_'+i).className = 'navPage';
			}
			if ( $(this.name+'_pageDiv_'+i) )
			{
				$(this.name+'_pageDiv_'+i).setAttribute("onClick","");
			}
		}
		// change the image of the selected tab
		if ( $(this.name+'Top_page_'+this.currPage))
		{
		    $(this.name+'Top_page_'+this.currPage).className = 'navPageSelected';
		}
		
		for (var i = 1; i <= this.numPages; i++)
		{
			if ( $(this.name+'Bot_page_'+i) )
			{
			    $(this.name+'Bot_page_'+i).className = 'navPage';
			}
		}
		// change the image of the selected tab
		if ( $(this.name+'Bot_page_'+this.currPage))
		{
		    $(this.name+'Bot_page_'+this.currPage).className = 'navPageSelected';
		}
		
		for (var i = 1; i <= this.numPages; i++)
		{
			if ( $(this.name+'_page_'+i) )
			{
			    $(this.name+'_page_'+i).className = 'navPage';
			}
		}
		// change the image of the selected tab
		if ( $(this.name+'_page_'+this.currPage))
		{
		    $(this.name+'_page_'+this.currPage).className = 'navPageSelected';
		}
		this.runRequest();
	}
	
	//changeProductPage function (called when page scroller's #s are clicked)
	this.changeProductPage = function(pageNum) {
	  //alert("changeProductPage pageNum:" + pageNum);
		
		// Steps forward a page
		this.currPage++;
		
		var prevPage = $(this.name+'_prevPage');
		var nextPage = $(this.name+'_nextPage');
		
		if (prevPage)
		{
			prevPage.setAttribute("onClick","");
		}
		
		if (nextPage)
		{
			nextPage.setAttribute("onClick","");
		}
		// loop through the tabs and set them to the default
		for (var i = 1; i <= this.numPages; i++)
		{
			if( $(this.name+'Top_page_'+i) )
			{
			    $(this.name+'Top_page_'+i).className = 'navPage';
			}
			if ($(this.name+'_pageDiv_'+i))
			{
				$(this.name+'_pageDiv_'+i).setAttribute("onClick","");
			}
		}
		
		if( $(this.name+'Top_page_'+pageNum) )
		{
		    $(this.name+'Top_page_'+pageNum).className = 'navPageSelected';
		}
		
		// loop through the tabs and set them to the default
		for (var i = 1; i <= this.numPages; i++)
		{
			if( $(this.name+'Bot_page_'+i) )
			{
			    $(this.name+'Bot_page_'+i).className = 'navPage';
			}
		}
		if( $(this.name+'Bot_page_'+pageNum) )
		{
		    $(this.name+'Bot_page_'+pageNum).className = 'navPageSelected';
		}
		
		// loop through the tabs and set them to the default
		for (var i = 1; i <= this.numPages; i++)
		{
			if( $(this.name+'_page_'+i) )
			{
			    $(this.name+'_page_'+i).className = 'navPage';
			}
		}
		if( $(this.name+'_page_'+pageNum) )
		{
		    $(this.name+'_page_'+pageNum).className = 'navPageSelected';
		}
		
		if (pageNum <= this.numPages)
		{
			this.currPage = pageNum;
		}
		
		this.runRequest();
	}
	
	//resetPage function
	this.resetPage = function() {
		var pageNum = 1;
				
		var prevPage = $(this.name+'_prevPage');
		var nextPage = $(this.name+'_nextPage');
		
		if (prevPage)
		{
			prevPage.setAttribute("onClick","");
		}
		
		if (nextPage)
		{
			nextPage.setAttribute("onClick","");
		}
		// loop through the tabs and set them to the default
		for (var i = 1; i <= this.numPages; i++)
		{
			if( $(this.name+'Top_page_'+i) )
			{
			    $(this.name+'Top_page_'+i).className = 'navPage';
			}
			if ($(this.name+'_pageDiv_'+i))
			{
				$(this.name+'_pageDiv_'+i).setAttribute("onClick","");
			}
		}
		
		if( $(this.name+'Top_page_'+pageNum) )
		{
		    $(this.name+'Top_page_'+pageNum).className = 'navPageSelected';
		}
		
		// loop through the tabs and set them to the default
		for (var i = 1; i <= this.numPages; i++)
		{
			if( $(this.name+'Bot_page_'+i) )
			{
			    $(this.name+'Bot_page_'+i).className = 'navPage';
			}
		}
		if( $(this.name+'Bot_page_'+pageNum) )
		{
		    $(this.name+'Bot_page_'+pageNum).className = 'navPageSelected';
		}
		
		// loop through the tabs and set them to the default
		for (var i = 1; i <= this.numPages; i++)
		{
			if( $(this.name+'_page_'+i) )
			{
			    $(this.name+'_page_'+i).className = 'navPage';
			}
		}
		if( $(this.name+'_page_'+pageNum) )
		{
		    $(this.name+'_page_'+pageNum).className = 'navPageSelected';
		}
		
		if (pageNum <= this.numPages)
		{
			this.currPage = pageNum;
		}
		
		enableNav();
	}	
	
	//runRequest function - calls the AJAX
	this.runRequest = function() {
	  //alert("runRequest this.ajaxCall:" + this.ajaxCall);
		
		var offset = (this.currPage-1)*this.prodsPerPage;
	
    // Make this URL the php script which will handle this request
    if (this.ajaxCall == 'locker')
    {
	    var url = '/script/ajax/product-retrieve/my-locker.php';
    
	    // Prep the parameters for the ajax call
	    var params = 
	    	'msisdn='+		this.msisdn +
	    	'&sector='+		this.sector +
	    	'&limit='+		this.prodsPerPage +
	    	'&sleep='+		this.fadeVal +
	    	'&offset='+		offset;		    
    }
    else if (this.ajaxCall == 'artist')
    {
	    var url = '/script/ajax/product-retrieve/artist.php';
    
	    // Prep the parameters for the ajax call
	    var params = 
	    	'artistId='+	this.artistId +
	    	'&sectorId='+	this.sectorId +
	    	'&subcatId='+	this.subcatId +
	    	'&type='+		this.type +
	    	'&offset='+		offset +
	    	'&sleep='+		this.fadeVal*2 +
	    	'&limit='+		this.prodsPerPage +
	    	'&orderby='+	this.orderby +
	    	'&page='+		this.page;		    
    }
    else if (this.ajaxCall == 'message')
    {
	    var url = '/script/ajax/community/message-retrieve.php';
	    
	    // Prep the parameters for the ajax call
	    var params = 
	    	'offset='+ offset +
	    	'&sleep='+ this.fadeVal*2 +
	    	'&limit='+ this.prodsPerPage +
	    	'&filter='+ this.filter +
	    	'&page='+ this.page;
    }
    else if (this.ajaxCall == 'friend')
    {		    
      clearFriendList();
	    
      var url = '/script/ajax/community/get-group-friends.php';				
      
      // Prep the parameters for the ajax call
	    var params = 
	    	'offset='+ offset +
	    	'&sleep='+ this.fadeVal*2 +
	    	'&limit='+ this.prodsPerPage +
	    	'&group_id='+ 0 +
	    	'&passport_id='+ this.passportId;				
    }	    
    else if (this.ajaxCall == 'group')
    {		    
      //enableNav();
    	//return;	
    	
      clearGroupList();
	    
      var url = '/script/ajax/community/get-group-friends.php';				
      
      // Prep the parameters for the ajax call
	    var params = 
	    	'offset='+ offset +
	    	'&sleep='+ this.fadeVal*2 +
	    	'&limit='+ this.prodsPerPage +
	    	'&group_id='+ this.groupId +
	    	'&passport_id='+ this.passportId;		
    }	   
    else
    {
    	var url = '/script/ajax/product-retrieve/product-retrieve.php';
	    // Prep the parameters for the ajax call
	    var params = 
	    	'sectorId='+	this.sectorId +
	    	'&subcatId='+	this.subcatId +
	    	'&type='+		this.type +
	    	'&offset='+		offset +
	    	'&sleep='+		this.fadeVal*2 +
	    	'&limit='+		this.prodsPerPage +
	    	'&page='+		this.page;		    
    }
    
    // Calls AJAX with a GET request to the URL, passing params, and calling 'endfunction' when done
    var mfRequest = new Ajax.Request(url,{method:'get',parameters:params,onLoading:me.fadeOut,onComplete:me.endFunction});	    
	}
	
	//fadeOut function 
	this.fadeOut = function() {		
		//alert("fadeOut");
		
		if(me.type == "message"){
			currElement = $('div_message');
		}
		else if(me.type == "friend"){
			currElement = $('div_friend');
		}		
		else if(me.type == "group"){
			currElement = $('div_group');
		}			
		else{
			
			// using the first item, find the tab-page
			currElement = $(me.name+'_1');
			
	  	while(currElement.className != 'tab-page')
	  	{
	  		currElement = currElement.parentNode;
	  	}
			//alert(currElement.id);
		}
		
		//put current element into a container
	  me.container = currElement;
  	
  	// fade the tab page
  	new Effect.Opacity(me.container.id, {duration:me.fadeVal, from:0.9999999, to:0.00, beforeStart: me.loading} );
	}
	
	//loading function - this function displays the loading image
	this.loading = function(obj){
		//alert("loading");
		
		// get the dimensions of the tab page
		var dim = obj.element.getDimensions(obj.element);
		
		// grab the tab-page's parent
		var parent = obj.element.parentNode;
		//alert(parent.className);
				
		// change the style of the tab-page for hiding beneath the loading image
		obj.element.style.position = '';
		obj.element.style.zIndex = 0;
		
		// create the div that will hold the loading image
		var div = document.createElement("div");
		
		// set the style properties for the div to display over the tab-page
		div.id = obj.element.id + '_loading';
		div.style.opacity = 0;
		div.style.filter = 'alpha(opacity:0)';
		div.vAlign = 'middle';
		div.style.width = '100%';
		div.align = 'center';
		div.style.position = 'absolute';
		div.style.zIndex = 10;
		
		// create the new image and add it to the div
		var img = new Image();
		img.src = '/template/shared/images/ajax-loader.gif';
		if (me.type == 'friend' || me.type == 'group'){		
		  div.style.top = ((dim.height/2)+img.height-30)+'px';		
		}
		else{
		  div.style.top = ((dim.height/2)+img.height)+'px';		
		}
		div.appendChild(img);
		
		// add the div to the tab-page's parent
		parent.appendChild(div);			
		
		// fade in the div
	  new Effect.Opacity(div.id, {duration:me.fadeVal, from:0.0, to:0.9999999} );
	}
	
	//endFunction function
	this.endFunction = function(mfRequest) {
		// the object containing the response is passed to this function by the prototype library
    // mfRequest.responseText contains the raw text response
    response = mfRequest.responseText;
    me.nImagesLoaded = 0;

    //alert(me.type);    
    //alert(response);
    
    //if type is message, html response is returned
    if (me.type == 'message')
		{
		  $('span_message').innerHTML = response;			
		  
		  //finish the loading
			for(i=0; i<me.max; i++){
			  me.nImagesLoaded++;	
			}
			me.imagesLoaded();	
			
			return;
		}		
		//if type is friend
    else if (me.type == 'friend')
		{
		  //finish the loading
			for(i=0; i<me.max; i++){
			  me.nImagesLoaded++;	
			}
			me.imagesLoaded();	
						
		  fillFriendList(mfRequest);
			
			return;
		}				
		//if type is group
    else if (me.type == 'group')
		{
		  //finish the loading
			for(i=0; i<me.max; i++){
			  me.nImagesLoaded++;	
			}
			me.imagesLoaded();	
						
		  fillGroupList(mfRequest);
			
			return;
		}				
		else{    
	    // evaluate the json expression and store the object
	    // decoded now contains the object in the same format as php before it encoded it
	    var decoded = eval('('+response+')');
	    
	    // Grabs the information of the catalog we requested
	    me.limit = decoded[0];
	    
	    // Grabs the wallpapers returned in the catalog
	    prods = decoded[1];
	    
	    // calculates the max based on the returned number of products and our limit
	    me.max = (prods.length<me.limit)?prods.length:me.limit;
	    
	    if ($(me.name+'PageNum'))
	  	{
	      $(me.name+'PageNum').innerHTML = me.currPage;
	  	}
			me.container.style.display = 'block';
			
			me.changeProducts();
		}
		
	}
	
	//fadeIn function
	this.fadeIn = function(obj) {		
		//alert("fadeIn");
		// Fades each cell of the products back in, calling the changeProducts function before starting
		new Effect.Opacity(obj.id, {duration:me.fadeVal,from:0.0,to:0.9999999,afterFinish:me.enableNav} )
	}
	
	//enableNav function
	this.enableNav = function(obj) {
		//alert("enableNav");
		
		var prevPage = $(me.name+'_prevPage');
		var nextPage = $(me.name+'_nextPage');
		
		if (prevPage)
		{
			prevPage.setAttribute("onClick",me.name+"CV.prevProducts(this);");
		}
		
		if (nextPage)
		{
			nextPage.setAttribute("onClick",me.name+"CV.nextProducts(this);");
		}
		
		// loop through the tabs and set them to the default
		for (var i = 1; i <= me.numPages; i++)
		{
			if ( $(me.name+'_pageDiv_'+i) )
			{
				$(me.name+'_pageDiv_'+i).setAttribute("onClick",me.name+"CV.changeProductPage("+i+");");
			}
		}
		
    /*
			if ($(me.container.id+'_loading'))
			{
				$(me.container.id+'_loading').remove();	
			}						
	  */
	}
	
	//enableNav() function
	function enableNav() {
		
		var prevPage = $(me.name+'_prevPage');
		var nextPage = $(me.name+'_nextPage');
		
		if (prevPage)
		{
			prevPage.setAttribute("onClick",me.name+"CV.prevProducts(this);");
		}
		
		if (nextPage)
		{
			nextPage.setAttribute("onClick",me.name+"CV.nextProducts(this);");
		}
		
		// loop through the tabs and set them to the default
		for (var i = 1; i <= me.numPages; i++)
		{
			if ( $(me.name+'_pageDiv_'+i) )
			{
				$(me.name+'_pageDiv_'+i).setAttribute("onClick",me.name+"CV.changeProductPage("+i+");");
			}
		}
	}	
	
	//hideElements function
	this.hideElements = function(obj) {
		// Fades each cell of the products back in, calling the changeProducts function before starting
		obj.element.style.visibility = 'hidden';
	}
	
	//changeProducts function
	this.changeProducts = function() {
		if (me.type == 'ringtone' || me.type == 'music' )
		{
			me.changeTones();
		}
		else if (me.type == 'image' || me.type == 'wallpaper' || me.type == 'screensaver')
		{
			me.changeWallpapers();
		}
		else
		{
			me.changeApps();
		}
	}
		
	//changeTones function
	this.changeTones = function() {
		// creates the regex to be used when replacing the publicationID in the wallpaper src
	    var regexPublication = /(o=[^&\'\"]*)/gi;
	    var regexFilename = /(filename=[^&\'\"]*)/gi;
	    var regexSectorId = /(s=[^&\'\"]*)/gi;
	    var regexBigPubId = /(\/[^\.]*)jpg/gi;
	    
	    for(var i=1; i<= me.max; i++)
	    {
	    	if (me.currPage > 1)
	        {
	            var itemNum = me.limit * (me.currPage-1) + parseInt(i);
	        }
	        else
	        {
	            var itemNum = i;
	        }
	        
	        var index = parseInt(i)-1;
	    	$(me.name+'_'+i).style.display = '';
	        $(me.name+'_'+i).style.visibility = 'visible';
	        $(me.name+'_'+i).style.opacity = '1';
	        
	        // grab the album art and album art link
	        var albumArt = $(me.name+'_albumArt_'+i);
	        var albumArtLink = $(me.name+'_albumArtLink_'+i);
	        var albumArtBig = $(me.name+'_albumArtBig_'+i);
	        
	        // grab the other links
	        var nameLink = $(me.name+'_nameLink_'+i);
	        var singerLink = $(me.name+'_singerLink_'+i);
	        var getItLink = $(me.name+'_getItLink_'+i);
		    var itemNumSpan = $(me.name+'_itemNum_'+i);
		    var ratingStar = me.name+'_ratingStar_'+i;
		    var swfDiv = $(me.name+'_so_'+i);
		    var embedLink = $(me.name+'_embed_'+i);
		    var purchaseDate = $(me.name+'_purchaseDate_'+i);
		    var row = $(me.name+'_row_'+i);
		    
	        // set the product title for easy use
	        if(prods[index].singer == "" || prods[index].singer == null){
	          prods[index].title = prods[index].name;
	        }
	        else{
	          prods[index].title = prods[index].name + ' - ' + prods[index].singer;
	        }
	        
	        // if there is a name link...
	        if (nameLink)
	        {
	            // set the name link url, title, and text
	        	  nameLink.href = prods[index].url;
	            nameLink.title = prods[index].title;
	            nameLink.alt = prods[index].title;
	            
	            if (itemNumSpan)
	            {
	                itemNumSpan.innerHTML = itemNum+'.';
	            	  nameLink.innerHTML = prods[index].name;
	            }
	            else
	            {
	                nameLink.innerHTML = prods[index].name;
	            }
        
	        }
	        
	        // if there is a row...
	        if (row)
	        {
	        	row.style.display = '';
	        }
	        
	        // if there is a singer link...
	        if (singerLink)
	        {
            // if we have a singer URL...
        	  if (prods[index].singerURL)
            {
            	singerLink.href = prods[index].singerURL;
            }
            else
            {
        	    singerLink.href = '';
            }
            // set the singer link title and text
            singerLink.title = prods[index].singer;
            singerLink.alt = prods[index].singer;
			      if(prods[index].singer)
			      {
	            singerLink.innerHTML = prods[index].singer;
			      }		 
			      else{
			        singerLink.innerHTML = "";
			      }
	          
			      /*
  	        //test
  	        if(prods[index].publicationId == "397773"){
  	          alert("test1 prods[index].publicationId:" + prods[index].publicationId + " prods[index].name:" + prods[index].name + " prods[index].title:" + prods[index].title + " prods[index].singer:" + prods[index].singer + " singerLink:" + singerLink + " singerLink.title:" + singerLink.title);
  	        }	
  	        */		    				      
	        }
	        
	        
	        
	        if (purchaseDate)
	        {
	        	purchaseDate.innerHTML = prods[index].orderDateDisplayA;
	        }
	        
	        // if there's a get it link
	        if (getItLink)
	        {
	        	// set the get it link url and title
	        	getItLink.href = prods[index].url;
	        	getItLink.title = prods[index].title;
	        	getItLink.alt = prods[index].title;
	        }
	        ringtoneSwf = '/template/skin/flycell/swf/play.swf?id='+prods[index].publicationId+'-2100-ringtone-'+me.sectorId;
	        
	        if (swfDiv) 
	        {
	        	swfDiv.innerHTML = null;
	        }
	        
	        if (embedLink)
	        {
	            var so = new SWFObject(ringtoneSwf,me.name+'_embed_'+i,'26','26','7');
	            so.addVariable("allowScriptAccess", 'sameDomain');
	            so.addVariable("movie", ringtoneSwf);
	            so.addVariable("quality", "high");
	            so.addVariable("scale", "exactfit");
	            so.addVariable("wmode", "transparent");
	            so.addVariable("bgcolor", "transparent");
	            so.write(me.name+'_so_'+i);
				$(me.name+'_embed_'+i).style.zIndex = 5;
				$(me.name+'_embed_'+i).style.position = '';
	        }
	        

	        	if(albumArt){
		          //alert("albumArt exists nameLink:" + nameLink + " i:" + i);
	        	}
	        	else if (albumArtBig){
		          //alert("albumArtBig exists nameLink:" + nameLink + " i:" + i);
	        	}	        
	        
	        // if there's album art
	        if (albumArt || albumArtBig)
	        {
	        		        	
	        	if( albumArt)
				{
	        		albumArt.onload = me.imageLoad;
		        	albumArt.onerror = me.imageLoad;
		        	albumArt.onabort = me.imageLoad;
		        	albumArt.src = me.aapreview;
		            // if the current product has album art, replace it
		            if (prods[index].albumArt)
		            {
		              //alert("albumArt.src:" + albumArt.src + " prods[index].albumArt:" + prods[index].albumArt);
		            
		            
		            	// replace the old wallpaper source with the new wallpaper source
		                albumArt.src = albumArt.src.replace(regexPublication,'o='+prods[index].publicationId);
		                albumArt.src = albumArt.src.replace(regexSectorId,'s='+me.sectorId);
		                albumArt.src = albumArt.src.replace(regexFilename,'filename='+prods[index].albumArt);
		            }
		            else
		            {
		            	//alert("no album art");
		                albumArt.src = albumArt.src.replace(regexPublication,'o='+prods[index].publicationId);
		                albumArt.src = albumArt.src.replace(regexSectorId,'s='+me.sectorId);						      
						        albumArt.src = albumArt.src.replace(regexFilename,'filename=');
		            }
		            
	            
		            // set the album art title, height, and width
		            albumArt.title = prods[index].title;
		            albumArt.alt = prods[index].title;
				}
				else if (albumArtBig)
				{
					albumArtBig.onload = me.imageLoad;
		        	albumArtBig.onerror = me.imageLoad;
		        	albumArtBig.onabort = me.imageLoad;
		        	//albumArtBig.src = me.aabigpreview;
		        	
	            	// replace the old wallpaper source with the new wallpaper source
	                //albumArtBig.src = albumArtBig.src + prods[index].publicationId + '.jpg';
		            
	                /*
	                 * Above albumArtBig.src lines replaced
	                 * albumArtParams contains default image when requested image is missing
	                 * Added by lanceh 2008-03-12
	                 */
	                albumArtBig.src = prods[index].albumArtParams;
		            
		            // set the album art title, height, and width
		            albumArtBig.title = prods[index].title;
		            albumArtBig.alt = prods[index].title;
				}
	        }
	        else
	        {
	        	me.nImagesLoaded++;
	        }
	        
	        if(albumArtLink)
	        {
	        	albumArtLink.title = prods[index].title;
	        	albumArtLink.alt = prods[index].title;
	        	albumArtLink.href = prods[index].url;
	        }
	        
	        if ( typeof( contentRatings ) != "undefined")
	        {
	        	contentRatings[prods[index].publicationId] = prods[index].ranking;
				contentRatingsVotes[prods[index].publicationId] = prods[index].votes;
	        }
			
	        for(j=1;j<=5;j++)
	        {
	        	if ( $(ratingStar+'^'+j) )
	        	{
	        		$(ratingStar+'^'+j).setAttribute("onmouseover","ratingHighlighted('" + me.name + "_ratingStar_" + i + "','" + prods[index].publicationId + "','" + j + "','" + i + "')");
	        		$(ratingStar+'^'+j).setAttribute("onmouseout","ratingHighlightOff('" + me.name + "_ratingStar_" + i + "','" + prods[index].publicationId + "','" + prods[index].ranking + "','" + i + "')");
	        		$(ratingStar+'^'+j).setAttribute("onclick","saveRating('" + me.name + "_ratingStar_" + i + "','" + prods[index].id + "','" + prods[index].publicationId + "','" + me.sectorId + "','" + j + "','" + i + "')");
	        		
	        		if (prods[index].ranking >= j)
	        		{
	        			$(ratingStar+'^'+j).src = '/template/skin/flycell/images/star_full.gif';
	        		}
	        		else if (prods[index].ranking >= (j-0.5))
	        		{
	        			$(ratingStar+'^'+j).src = '/template/skin/flycell/images/star_half.gif';
	        		}
	        		else
	        		{
	        			$(ratingStar+'^'+j).src = '/template/skin/flycell/images/star_empty.gif';
	        		}
	        		
	        		$(me.name+'_contentRatingStatus_'+i).innerHTML = 'Rated by ' + prods[index].votes + ' users.';
	        	}
	        }
	    }
	    for(i=(me.max+1); i<=me.limit;i++)
	    {
		    var row = $(me.name+'_row_'+i);
		    if (row)
		    {
		    	row.style.display = 'none';
		    }
	    	$(me.name+'_'+i).style.visibility = 'hidden';
	    	$(me.name+'_'+i).style.display = 'none';
	    }
	    me.imagesLoaded();
	}
	
	//changeWallpapers function
	this.changeWallpapers = function(obj) {
	    // creates the regex to be used when replacing the publicationID in the wallpaper src
	    var regexPublicationId = /(o=[^&\'\"]*)/gi;
	    var regexSectorId = /(s=[^&\'\"]*)/gi;
	    var regexProgressId = /(p=[^&\'\"]*)/gi;
	    var regexFilename = /(filename=[^&\'\"]*)/gi;

	    
	    for(var i=1; i<= me.max; i++)
	    {
	    	$(me.name+'_'+i).style.visibility = 'visible';
	        if (me.currPage > 1)
	        {
	            var itemNum = me.limit * (me.currPage-1) + parseInt(i);
	        }
	        else
	        {
	            var itemNum = i;
	        }
		    
		    var imgLink = $(me.name+'_imageLink_'+i);
		    var getItLink = $(me.name+'_getItLink_'+i);
		    var img = $(me.name+'_image_'+i);
		    var ratingStar = me.name+'_ratingStar_'+i;
		    var purchaseDate = $(me.name+'_purchaseDate_'+i);
		    
	        var index = parseInt(i)-1;
	        
	        var alt = prods[index].alt;
	        prods[index].alt = alt.replace("&copy;",unescape("%A9"));
	        
	        // set the product title for easy use
	        prods[index].title = me.sectorName + ' - ' + prods[index].name + ' ' + prods[index].alt;
	        
	        // if there is a name link...
	        if (imgLink)
	        {
	            // set the name link url, title, and text
	        	imgLink.href = prods[index].url;
	            imgLink.title = prods[index].title;
	            imgLink.alt = prods[index].title;
	        }
	        
	        // if there is a singer link...
	        if (getItLink)
	        {
	            // set the singer link title and text
	            getItLink.href = prods[index].url;
	            getItLink.title = prods[index].title;
	            getItLink.alt = prods[index].title;
	        }
	        
	        if (purchaseDate)
	        {
	        	purchaseDate.innerHTML = prods[index].orderDateDisplayA;
	        }
	        
	        var src = null;
	        
	        // if there's album art
	        if (img)
	        {
	        	var src = img.src;
	        	src = src.replace(regexPublicationId,'o='+prods[index].publicationId);
	        	src = src.replace(regexSectorId,'s='+me.sectorId);
	        	src = src.replace(regexProgressId,'p='+me.progressId);
	        	src = src.replace(regexFilename,'filename='+prods[index].tempName);
	        	img.onload = me.imageLoad;
	        	img.onerror = me.imageLoad;
	        	img.onabort = me.imageLoad;
	        	img.src = src;
	            
	            // set the album art title, height, and width
	            img.title = prods[index].title;
	            img.alt = prods[index].title;
	        }
	        else
	        {
	        	me.nImagesLoaded++;
	        }
	        
	        if ( typeof( contentRatings ) != "undefined")
	        {
	        	contentRatings[prods[index].publicationId] = prods[index].ranking;
				contentRatingsVotes[prods[index].publicationId] = prods[index].votes;
	        }
			
	        for(j=1;j<=5;j++)
	        {
	        	if ( $(ratingStar+'^'+j) )
	        	{
	        		$(ratingStar+'^'+j).setAttribute("onmouseover","ratingHighlighted('" + me.name + "_ratingStar_" + i + "','" + prods[index].publicationId + "','" + j + "','" + i + "')");
	        		$(ratingStar+'^'+j).setAttribute("onmouseout","ratingHighlightOff('" + me.name + "_ratingStar_" + i + "','" + prods[index].publicationId + "','" + prods[index].ranking + "','" + i + "')");
	        		$(ratingStar+'^'+j).setAttribute("onclick","saveRating('" + me.name + "_ratingStar_" + i + "','" + prods[index].id + "','" + prods[index].publicationId + "','" + me.sectorId + "','" + j + "','" + i + "')");
	        		
	        		if (prods[index].ranking >= j)
	        		{
	        			$(ratingStar+'^'+j).src = '/template/skin/flycell/images/star_full.gif';
	        		}
	        		else if (prods[index].ranking >= (j-0.5))
	        		{
	        			$(ratingStar+'^'+j).src = '/template/skin/flycell/images/star_half.gif';
	        		}
	        		else
	        		{
	        			$(ratingStar+'^'+j).src = '/template/skin/flycell/images/star_empty.gif';
	        		}
	        		
	        		$(me.name+'_contentRatingStatus_'+i).innerHTML = 'Rated by ' + prods[index].votes + ' users.';
	        	}
	        }
	    }
	    
	    for(i=(me.max+1); i<=me.limit;i++)
	    {
	    	$(me.name+'_'+i).style.visibility = 'hidden';
	    }
	}
	
	//changeApps function
	this.changeApps = function(obj) {
		// creates the regex to be used when replacing the publicationID in the wallpaper src
	    var regexPublicationId = /(o=[^&\'\"]*)/gi;
	    var regexSectorId = /(s=[^&\'\"]*)/gi;
	    var regexFilename = /(filename=[^&\'\"]*)/gi;
	    
	    for(var i=1; i<= me.max; i++)
	    {
	    	$(me.name+'_'+i).style.visibility = 'visible';
	        if (me.currPage > 1)
	        {
	            var itemNum = me.limit * (me.currPage-1) + parseInt(i);
	        }
	        else
	        {
	            var itemNum = i;
	        }
		    
	        var nameLink = $(me.name+'_nameLink_'+i);
		    var imgLink = $(me.name+'_imageLink_'+i);
		    var getItLink = $(me.name+'_getItLink_'+i);
		    var img = $(me.name+'_image_'+i);
	        var desc = $(me.name+'_desc_'+i);
		    var ratingStar = me.name+'_ratingStar_'+i;
		    var purchaseDate = $(me.name+'_purchaseDate_'+i);
		    
	        var index = parseInt(i)-1;
	        
	        // set the product title for easy use
	        prods[index].title = prods[index].name;
	        
	        if (nameLink)
	        {
	        	nameLink.href = prods[index].url;
	        	nameLink.title = prods[index].title;
	        	nameLink.alt = prods[index].title;
	        	nameLink.innerHTML = prods[index].name;
	        }
	        if (desc)
	        {
	        	desc.innerHTML = me.truncate(prods[index].description,100);
	        }
	        // if there is a name link...
	        if (imgLink)
	        {
	            // set the name link url, title, and text
	        	imgLink.href = prods[index].url;
	            imgLink.title = prods[index].title;
	            imgLink.alt = prods[index].title;
	        }
	        
	        // if there is a singer link...
	        if (getItLink)
	        {
	            // set the singer link title and text
	            getItLink.href = prods[index].url;
	            getItLink.title = prods[index].title;
	            getItLink.alt = prods[index].title;
	        }
	        
	        if (purchaseDate)
	        {
	        	purchaseDate.innerHTML = prods[index].orderDateDisplayA;
	        }
	        
	        var src = null;
	        
	        // if there's album art
	        if (img)
	        {
	        	var src = img.src;
	        	src = src.replace(regexPublicationId,'o='+prods[index].publicationId);
	        	src = src.replace(regexSectorId,'s='+me.sectorId);
	        	src = src.replace(regexFilename,'filename='+prods[index].tempName);
	        	img.onload = me.imageLoad;
	        	img.onerror = me.imageLoad;
	        	img.onabort = me.imageLoad;
	        	img.src = src;
	            
	            // set the album art title, height, and width
	            img.title = prods[index].title;
	            img.alt = prods[index].title;
	        }
	        else
	        {
	        	me.nImagesLoaded++;
	        }
	        
	        if ( typeof( contentRatings ) != "undefined")
	        {
	        	contentRatings[prods[index].publicationId] = prods[index].ranking;
				contentRatingsVotes[prods[index].publicationId] = prods[index].votes;
	        }
			
	        for(j=1;j<=5;j++)
	        {
	        	if ( $(ratingStar+'^'+j) )
	        	{
	        		$(ratingStar+'^'+j).setAttribute("onmouseover","ratingHighlighted('" + me.name + "_ratingStar_" + i + "','" + prods[index].publicationId + "','" + j + "','" + i + "')");
	        		$(ratingStar+'^'+j).setAttribute("onmouseout","ratingHighlightOff('" + me.name + "_ratingStar_" + i + "','" + prods[index].publicationId + "','" + prods[index].ranking + "','" + i + "')");
	        		$(ratingStar+'^'+j).setAttribute("onclick","saveRating('" + me.name + "_ratingStar_" + i + "','" + prods[index].id + "','" + prods[index].publicationId + "','" + me.sectorId + "','" + j + "','" + i + "')");
	        		
	        		if (prods[index].ranking >= j)
	        		{
	        			$(ratingStar+'^'+j).src = '/template/skin/flycell/images/star_full.gif';
	        		}
	        		else if (prods[index].ranking >= (j-0.5))
	        		{
	        			$(ratingStar+'^'+j).src = '/template/skin/flycell/images/star_half.gif';
	        		}
	        		else
	        		{
	        			$(ratingStar+'^'+j).src = '/template/skin/flycell/images/star_empty.gif';
	        		}
	        		
	        		$(me.name+'_contentRatingStatus_'+i).innerHTML = 'Rated by ' + prods[index].votes + ' users.';
	        	}
	        }
	    }
	    
	    for(i=(me.max+1); i<=me.limit;i++)
	    {
	    	$(me.name+'_'+i).style.visibility = 'hidden';
	    }
	}
	
	//truncate function
	this.truncate = function(str,len) {
	  if (str.length > len) {
	
	    /* Truncate the content of the P, then go back to the end of the
	       previous word to ensure that we don't truncate in the middle of
	       a word */
	    str = str.substring(0, len);
	    str = str.replace(/\w+$/, '');
	    str = str.replace(/[,.!; ]+$/, '');
	
	    /* Add an ellipses to the end and make it a link that expands
	       the paragraph back to its original size */
	    str += '...';
	  }
	  return str;
	}
	
	//imageLoad function
	this.imageLoad = function() {
		me.nImagesLoaded++;
		me.imagesLoaded();
	}
	
	//imagesLoaded function
	this.imagesLoaded = function() {
		//alert("me.nImagesLoaded:" + me.nImagesLoaded + " me.max:" + me.max);
		if( me.nImagesLoaded == me.max){
			me.nImagesLoaded = 0;
			
			if ($(me.container.id+'_loading'))
			{
				// fade out the loading image div
				new Effect.Opacity(me.container.id+'_loading', {duration:me.fadeVal, from:0.9999999, to:0.0,afterFinish:me.removeLoading} );
			
				me.fadeIn(me.container);
			}
			else
			{
				me.fadeIn(me.container);
			}
			
		}
	}
	
	//removeLoading function
	this.removeLoading = function() {
		// remove the loading image div
		$(me.container.id+'_loading').remove();
	}	
}