/**
 * @desc private class to read a XML file and displays in a news format
 * @author javier.morquecho javiermorquecho@live.com
 * */
function TagNews( tag, news, begin, pageScale, order, design ){
	this.tag       = tag;			//search
	this.news      = news;			//news by news page
	this.begin     = begin;			//first news
	this.pageScale = pageScale;		//elements in a row
	this.order     = order;			//order
	this.design    = design;		//to select css classes to use
	
	//default config
	this.optionsPageScale = 3									//options to display in a combo
	this.url              = "";
	this.xml              = this.url + "/xml/tags/index.php?tag=" + this.tag + "&news=" + this.news + "&begin=" + this.begin;
	
	//
	//this.cssVertical      = { "css": [ "wrapper":"news_vert", "new_wrapper":"new_vert", "head":"head_new_vert" ] };
	//this.cssHorizontal    = { "css": [ "wrapper":"new", "title":"side" ] };
	
	/**
	 * @desc   gets a list to show page items to view options
	 * @param  
	 * @return nothing
	 * @see select items_by_page options added 
	 * 
	function get_items_by_page_list(  ){
		a      = 0;
		
		for( i = 1; i < this.optionsPageScale; i++ ){
			a = i * this.news;
			if ( a == this.news )
				//result.push()
				//echo "<option value='$page_scale' selected>$page_scale</option>";
			else
				//echo "<option value='$page_scale'>$page_scale</option>";
		}
		
	}
	*/
	
	/**
	 * @desc   gets a list to show page items to view options
	 * @param  li LI HTML object to embed the info  
	 * @return nothing
	 * @see    news boxes in the LI 
	 **/
	this.get_page_items = function( li ){
		//console.log( "get_page_items" );
		$.ajax({
			url:      this.xml,
			type:     "GET",
			dataType: "xml",
			success:  function( xml ){
				a    = true;		//first loop
				html = "";			//result to add in document
				//console.log( "success" );
				switch( design ){
					case "vertical":
						if ( a ){
							html =  "<ul class='news_vert'>";
							//html += "<li class='new_vert'>Comunicado de Prensa</li>";
							a    = false;
						}
						break;
					default:
				}
				
				$(xml).find('article').each(function(){
					switch( design ){
						case "vertical":
							//console.log( "vertical" );
							html += "<li class='new_vert'><a href='" + $(this).find('url').text() + "'><img src='" + $(this).find('img').text() + "' width='103' height='80' alt='" + $(this).find('title').text() + "' title='" + $(this).find('title').text() + "' /></a><a href='" + $(this).find('url').text() + "'>" + $(this).find('title').text() + "</a></li>";
							//li.append( "<li><h1 class='head_new_vert'><a href='" + $(this).find('url').text() + "'><img src='" + $(this).find('img').text() + "' width='103' height='80' alt='" + $(this).find('title').text() + "' title='" + $(this).find('title').text() + "' /></a><a href='" + $(this).find('url').text() + "'>" + $(this).find('title').text() + "</a></h1>" );
							//li.append( "<div class='" + cssVertical.wrapper + "'>" + "<h1 class='" + cssVertical.title + "'><a href='" + $(this).find('url').text() + "'><img src='" + $(this).find('img').text() + "' width='103' height='80' alt='" + $(this).find('title').text() + "' title='" + $(this).find('title').text() + "' /></a><a href='" + $(this).find('url').text() + "'>" + $(this).find('title').text() + "</a></h1>" );
							break;
						case "horizontal":
							//console.log( "horizontal" );
							li.append( "<div class='new'><h1 class='side'><a href='" + $(this).find('url').text() + "'><img src='" + $(this).find('img').text() + "' width='103' height='80' alt='" + $(this).find('title').text() + "' title='" + $(this).find('title').text() + "' /></a><a href='" + $(this).find('url').text() + "'>" + $(this).find('title').text() + "</a></h1><h3 class='side'>Publicado el " + $(this).find('date').text() + "</h3><div class='new_intro'><a href='" + $(this).find('url').text() + "'>" + $(this).find('text').text() + "</a></div></div>" );
							break;
						default:
							//li.append( html );
					}
				});
				html += "</ul>";
				li.append( html );
			}
		});
	}
}
