<!--
window.addEvent('load', function() {
	
	var cellnum = 0;
	var slide = $('slide');
	
	var addCell = function (data)
	{
		for (cellnum = 0; cellnum <= 5; cellnum++)
		{
			var star_name_str = data[cellnum].name;
			var star_html = (star_name_str.length >= 16) ? star_name_str.slice(0,15): star_name_str;
			var cell = new Element('div', {'class': 'star_cell','id': cellnum});
			var star_name = new Element ('a', {'html': star_html, 'href': data[cellnum].url,'style':'padding:1px;color:green;width:100px;float:left;', 'class': 'slidehref'}).inject(cell);
			//var img_src = new Element ('img' ,{'src': 'http://justastar.com/star_img/' + data[cellnum].img_src ,'height': '70', 'href': data[cellnum].url}).inject(star_name,'after');
			var img_src = new Element ('a', {'html': '<img src="http://justastar.com/star_img/'+ data[cellnum].img_src+'" border=\'0\' height=\'70\'>', 'href': data[cellnum].url, 'style': 'float:inherit;'}).inject(star_name,'after');
			///var br_space = new Element ('html' ,{'html':'<br />dve'}).inject(img_src, 'after');
			
			cell.inject(slide);
		}
		$('5').setStyles({'visibility':'hidden'});
	};
	
	var category_ID = $('categoryid').get('text');

		var request = new Request.JSON({
			url: 'http://justastar.com/stars.json.php?catID=' + category_ID,
			onComplete: function(jsonObj) {
				addCell(jsonObj.previews);
			}
		}).send();
	
});

window.addEvent('domready', function() {
	
	var mvleft  = function() {

		var all_cell_arr = $('slide').getElements('div');
		///in no 6 div stop script here
		//alert(all_cell_arr.length+'///ID:'+all_cell_arr[0].get('id'));
		if ((all_cell_arr.length !== 7) && (all_cell_arr[0].get('id') !== "0"))
			return false;
		
		if ((all_cell_arr[0].get('id') == "0") && (all_cell_arr.length <= 6))
		{
			all_cell_arr[0].tween('width', '0px');
			var t=setTimeout("$('slide').getElement('div').setStyles({'visibility':'hidden'})",500);
		}
				
		else
		{
			all_cell_arr[0].dispose();
			all_cell_arr[1].tween('width', '0px');
			var t=setTimeout("$('slide').getElements('div')[0].setStyles({'visibility':'hidden'})", 500);
		}

	    var slide = $('slide');    
		var last_element = all_cell_arr.getLast();
		////$('status').set('html','proba'+last_element.get('id'));

	    var hidden_cell = last_element.get('id');
	    //alert(hidden_cell);
	    $(hidden_cell).setStyles({'width':'0px'});
	    $(hidden_cell).setStyles({'visibility':'visible'});
	    $(hidden_cell).tween('width', '100px');
	    
	    var new_cell_id = parseInt(last_element.get('id'))+1;   
	    
	    var addnewCell = function (data, element)
		{
	    	//alert('add NEW CELL inside');
	    	if (data[new_cell_id]) 
	    	{
	    		var star_name_str = data[new_cell_id].name;
				var star_html = (star_name_str.length >= 16) ? star_name_str.slice(0,15): star_name_str;
	    	var new_cell = new Element('div', {'class': 'star_cell','id': new_cell_id, 'style': 'visibility:hidden;width:0px;'});
	    	var star_name = new Element ('a', {'html': star_html, 'href': data[new_cell_id].url,'style':'padding:1px;color:green;width:110px;float:left;', 'class': 'slidehref'}).inject(new_cell);
	    	/////var img_src = new Element ('img' ,{'src': 'http://justastar.com/star_img/' + data[new_cell_id].img_src ,'height': '70'}).inject(star_name,'after');
	    	var img_src = new Element ('a', {'html': '<img src="http://justastar.com/star_img/'+ data[new_cell_id].img_src+'" border=\'0\' height=\'70\'>', 'href': data[new_cell_id].url, 'style': 'float:left;'}).inject(star_name,'after');
	    	//var br_space = new Element('html', {'html' : new_cell_id}).inject(img_src,'after');
	    	
	    	new_cell.inject(slide);
	    	}
	    	else
	    		$('status').set('html','ARRAY JSON IS EMPTY !!!');
		}
	    
	    
	    
		var category_ID = $('categoryid').get('text');

	    var request = new Request.JSON({
			url: 'http://justastar.com/stars.json.php?catID=' + category_ID,
			onComplete: function(jsonObj) {
	    	if (new_cell_id)
	    	addnewCell(jsonObj.previews, new_cell_id);
			}
		}).send();
	    
	}
	
	var mvright  = function() {
		
		var all_cell_arr2 = $('slide').getElements('div');
		var left_cell = all_cell_arr2[0];
		///in no 6 div stop script here
		if ((left_cell.get('id') == 0) || (all_cell_arr2.length < 7))
			return false;
		
		var last_cell2 = all_cell_arr2.getLast();
	var right_cell_id = parseInt(last_cell2.get('id'))-1;
	var right_hidden_cell_id = parseInt(last_cell2.get('id'));

	$(''+ right_hidden_cell_id + '').dispose();
	
	$(''+right_cell_id+'').tween('width', '0px');
	
	var t=setTimeout("$('"+right_cell_id+"').setStyles({'visibility':'hidden', 'width':'0px'})",500);
	
	//$(right_cell).tween('width', '0px');
	//var t=setTimeout("$('slide').getElement('div').dispose()",500);
	
	
    var slide = $('slide');  
    var hidden_cell = left_cell.get('id');
    //alert(hidden_cell);
    $(hidden_cell).setStyles({'width':'0px'});
    $(hidden_cell).setStyles({'visibility':'visible'});
    $(hidden_cell).tween('width', '100px');
	
    var new_cell_id = parseInt(hidden_cell)-1;   
    
    var addnewCell = function (data, element)
	{
    	//alert('add NEW CELL inside');
    	if (data[new_cell_id]) 
    	{
    		var star_name_str = data[new_cell_id].name;
			var star_html = (star_name_str.length >= 16) ? star_name_str.slice(0,15): star_name_str;
			
    	var new_cell = new Element('div', {'class': 'star_cell','id': new_cell_id, 'style': 'visibility:hidden;width:0px;'});
    	var star_name = new Element ('a', {'html': star_html, 'href': data[new_cell_id].url,'style':'padding:1px;color:green;width:110px;float:left;', 'class': 'slidehref'}).inject(new_cell);
    	//////var img_src = new Element ('img' ,{'src': 'http://justastar.com/star_img/' + data[new_cell_id].img_src ,'height': '70'}).inject(star_name, 'after');
    	var img_src = new Element ('a', {'html': '<img src="http://justastar.com/star_img/'+ data[new_cell_id].img_src+'" border=\'0\' height=\'70\'>', 'href': data[new_cell_id].url, 'style': 'float:left;'}).inject(star_name,'after');
    	
    	   	
    	new_cell.inject(slide,'top');
    	}
    	else
    		$('status').set('html','ARRAY JSON IS EMPTY !!!');
	}
	
    var  new_variable; 
    var category_ID = $('categoryid').get('text');
    var request = new Request.JSON({
		url: 'http://justastar.com/stars.json.php?catID=' + category_ID,
		onComplete: function(jsonObj) {
    	if (new_cell_id)
    	addnewCell(jsonObj.previews, new_cell_id);
		}
	}).send();
	
	}
	
    $('lefthref').addEvent('click', mvleft);
    $('righthref').addEvent('click', mvright);
	
	
});

-->
