// JavaScript Document

Testimonials = function()
{
	this.maxPage = null;
	this.site_url = null;
	this.php_self = null;
	this.wname = null;
	this.wseason = null;
	this.wflowert = null;
	
	/*
	this.item_mouseover=function(e, el)
	{
		var itemPictureA = YAHOO.util.Selector.query('div.itemPicture a',el);
		var productName=YAHOO.util.Selector.query('ul li a.productName',el);
		YAHOO.util.Dom.replaceClass(itemPictureA, 'itemPictureAOut', 'itemPictureAOver');
		YAHOO.util.Dom.replaceClass(productName, 'productNameOut', 'productNameOver');

	}
	
	this.item_mouseout=function(e, el)
	{
		var itemPictureA=YAHOO.util.Selector.query('div.itemPicture a',el);
		var productName=YAHOO.util.Selector.query('ul li a.productName',el);
		YAHOO.util.Dom.replaceClass(itemPictureA, 'itemPictureAOver', 'itemPictureAOut');
		YAHOO.util.Dom.replaceClass(productName, 'productNameOver', 'productNameOut');
	}
	
	this.initContainerRight = function()
	{
		var itemPictureAs = YAHOO.util.Selector.query('div.cpLeftColumn div.item div.itemPicture a','container_right');

		var productNames=YAHOO.util.Selector.query('div.cpRightColumn div.item ul li a.productName','container_right');

		YAHOO.util.Dom.addClass(itemPictureAs, 'itemPictureAOut');

		YAHOO.util.Dom.addClass(productNames, 'productNameOut');
		
		
		
		var items=YAHOO.util.Selector.query('div.item','container_right');
		
		var l=items.length;
		for(i=0;i<l;i++)
		{
		
			YAHOO.util.Event.addListener(items[i], 'mouseover', this.item_mouseover, items[i]);
			YAHOO.util.Event.addListener(items[i], 'mouseout', this.item_mouseout, items[i]);
		}
	}
	*/
	//erase left blank spaces in a string
	this.ltrim = function(s) 
	{ 
		return s.replace(/^\s+/, ""); 
	};
	//erase rigth blank spaces in a string
	this.rtrim = function(s) 
	{ 
		return s.replace(/\s+$/, ""); 
	}; 
	//erase left and right blank spaces in a string
	this.trim = function(s) 
	{ 
		return this.rtrim(this.ltrim(s)); 
	};
	
	/*blank input box*/
	this.blankInputText = function(e, obj)
	{
		this.value = "";
	}
	
	/*only write numbers in to input type text*/
	this.onlyNumbers = function (e, obj)
	{
		key = (document.all) ? e.keyCode : e.which;
		
		if (key == 8 || key == 0 || (key >= 48 && key <= 57))
			return true;
		else
			YAHOO.util.Event.stopEvent(e);
	}
	
	/*goTo_top_btn_click*/	
	this.goTo_top_btn_click = function(e, obj)
	{
		if(this.trim(this.goTo_top.value) != "" && isNaN(this.goTo_top.value) == false && (this.goTo_top.value > 0 && parseInt(this.goTo_top.value) <= parseInt(this.maxPage.value) ))
		{
			
			//alert(this.wname.value+" - "+this.wseason.value+" - "+this.wflowert.value);
			var links ="";
			if(this.wname.value != "")
				links += "&wname="+this.wname.value;
			if(this.wseason.value != -1)
				links += "&wseason="+this.wseason.value;
			if(this.wflowert.value != "X")
				links +="&wflowert="+this.wflowert.value;
			
			document.location.href = this.php_self+"?cur_page="+this.goTo_top.value+links;
			

		}
		else
		{
			this.goTo_top.value = "#";
		}
	}
	/*goTo_bottom_btn_click*/
	this.goTo_bottom_btn_click = function(e, obj)
	{
		if(this.trim(this.goTo_bottom.value) != "" && isNaN(this.goTo_bottom.value) == false && (this.goTo_bottom.value > 0 && parseInt(this.goTo_bottom.value) <= parseInt(this.maxPage.value) ))
		{
			
			//alert(this.wname.value+" - "+this.wseason.value+" - "+this.wflowert.value);
			var links ="";
			if(this.wname.value != "")
				links += "&wname="+this.wname.value;
			if(this.wseason.value != -1)
				links += "&wseason="+this.wseason.value;
			if(this.wflowert.value != "X")
				links +="&wflowert="+this.wflowert.value;
			
			document.location.href = this.php_self+"?cur_page="+this.goTo_bottom.value+links;

		}
		else
		{
			this.goTo_bottom.value = "#";
		}
	}

	
	/*Search Testimonials Button*/
	this.search_testimonials_btn_click = function(e, obj)
	{
		this.search_testimonials_frm = YAHOO.util.Dom.get("search");
		this.search_testimonials_frm.submit();
	}
	
	
	/*
	Function: initRoundCornerModules, 2008 Oct 06
	It draws a round corner border around testimonial search section
	*/
	/*
	//Note: 2009 Mar 06
	//Esta función redondea las esquinas del div que contiene el formulario para buscar testimonios
	this.initRoundCornerModules=function()
	{
		//testimonial search container
		$('#contentSearchTestimony').corner({
			  tl: { radius: 4 },
			  tr: { radius: 4},
			  bl: { radius: 4 },
			  br: { radius: 4 }});
	}
	*/
	
	
	
	//Function init
	this.init = function(site_url, php_self)
	{
		//Initializations
		this.site_url = site_url;
		this.php_self = php_self;
		
		this.goTo_top = YAHOO.util.Dom.get("goTo_top_txt");
		this.goTo_bottom = YAHOO.util.Dom.get("goTo_bottom_txt");
		
		this.maxPage = YAHOO.util.Dom.get("maxPage_top_txt");
		
		this.wname = YAHOO.util.Dom.get("wname");
		this.wseason = YAHOO.util.Dom.get("wseason");
		this.wflowert = YAHOO.util.Dom.get("wflowert");
		
		/*
		Note: 2008 Oct 07 
		Si ponemos la función "this.initRoundCornerModules()" después de los addListener  el botón "Search"
		deja de funcionar. Por este motivo se ubicó la función antes de su respectivo addListener.
		Start Rounded Corners for box of testimonial search
		*/
		//Note: 2009 Mar 06
		//Esta función redondea las esquinas del div que contiene el formulario para buscar testimonios
		//this.initRoundCornerModules();
		
		//Listeners
		YAHOO.util.Event.addListener("search_testimonials_btn", "click", this.search_testimonials_btn_click, this, true);		
		
		YAHOO.util.Event.addListener("goTo_top_txt", "focus", this.blankInputText, this.goTo_top, true);
		YAHOO.util.Event.addListener("goTo_bottom_txt", "focus", this.blankInputText, this.goTo_bottom, true);
		
		YAHOO.util.Event.addListener("goTo_top_txt", "keypress", this.onlyNumbers, this.goTo_top, true);
		YAHOO.util.Event.addListener("goTo_bottom_txt", "keypress", this.onlyNumbers, this.goTo_bottom, true);
		
		YAHOO.util.Event.addListener("goTo_top_btn", "click", this.goTo_top_btn_click, this, true);
		YAHOO.util.Event.addListener("goTo_bottom_btn", "click", this.goTo_bottom_btn_click, this, true);
		
		
	}

}

