/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*	Pops Media
*	Author:
*	Description: 
*	Module: Tinipet website
*	Date started:
*	Date updated: 
*	Module Version Number: 1.0.0
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
var wt_News = Class.create();
wt_News.prototype = 
{
	gClick:0,
    initialize: function()
    {
    
    },
    
	/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	* Author:
	* Function Name:
	* Description:
	* Input:
	* Output:
	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
    stl_cValidateString: function(string)
    {
        var result;
        var invalidChars="+'&~`@#$%^*();\\|{}[]\"<>/";
        for (i = 0; i<string.length; i++)
        {
            for (j=0; j<invalidChars.length; j++)
            {
                if (string.substr(i,1)==invalidChars.substr(j,1))
                {
                    result=1;
                    return result;
                }
                else
                {
                    result=0;
                }
            }
        }
        return result;
    },
    
	/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	* Author:
	* Function Name:
	* Description:
	* Input:
	* Output:
	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
    wt_GetPagingNews: function(NewsCatID,Page)
	{
        $("news_paging").innerHTML = "<img src='../../tmpl/img/icon_loading.gif'></img>";
        var url = 'wt_GetNews.htm';
        new Ajax.Request(url,
		{
				method:'post',
				parameters:{NewsCatID:NewsCatID,Page:Page},
				onSuccess: function(Trans)
				{
					var data = Trans.responseText.split("<||>");
					$("new_content").innerHTML = data[0];
					$("news_paging").innerHTML = data[1];
					
				}
			}
		);
	},
    
	/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	* Author:
	* Function Name:
	* Description:
	* Input:
	* Output:
	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
    wt_GetPagingSearchNews: function(SearchKey,NewsCatID,Page)
    {
        var url = 'wt_SearchNews.htm';
        new Ajax.Request(url,
		{
				method:'post',
				parameters:{SearchKey:SearchKey,NewsCatID:NewsCatID,Page:Page},
				onSuccess: function(Trans)
				{
					var data = Trans.responseText.split("<||>");
					$("new_content").innerHTML = data[0];
					$("news_paging").innerHTML = data[1];
                }
			}
		);
    },
	
	/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	* Author:
	* Function Name:
	* Description:
	* Input:
	* Output:
	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
	wt_GetNewsHomePage: function(type)
    {
        $("wt_new_home_content").innerHTML = "<img src='../../tmpl/img/icon_loading.gif'></img>";
		var url = 'wt_GetNewsHomePage.htm';
        new Ajax.Request(url,
		{
				method:'post',
				parameters:{type:type},
				onSuccess: function(Trans)
				{
					var data = Trans.responseText.strip();
					$("wt_new_home_content").innerHTML = data;
					if(type == 1)
					{
						$("wt_home_news_tab_1").removeClassName("wt_news_home_tab_news_1");
						$("wt_home_news_tab_1").addClassName("wt_news_home_tab_news_2");
					
						$("wt_home_news_tab_2").removeClassName("wt_news_home_tab_news_2");
						$("wt_home_news_tab_2").addClassName("wt_news_home_tab_news_1");
					}
					else
					{
						$("wt_home_news_tab_1").removeClassName("wt_news_home_tab_news_2");
						$("wt_home_news_tab_1").addClassName("wt_news_home_tab_news_1");
					
						$("wt_home_news_tab_2").removeClassName("wt_news_home_tab_news_1");
						$("wt_home_news_tab_2").addClassName("wt_news_home_tab_news_2");
					}
                }
			}
		);
    },
    
	/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	* Author:
	* Function Name:
	* Description:
	* Input:
	* Output:
	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
    wt_SearchNews: function()
	{
        var SearchKey = $("news_search_input").value.strip();
        if(SearchKey == "")
        {
            alert(ocom.wt_ReturnMessage("02001"));
            $("news_search_input").value = "";
            $("news_search_input").focus();
            return false;
        }
        
        var check = this.stl_cValidateString(SearchKey);
        
        if(check == 1)
        {
            alert(ocom.wt_ReturnMessage("02002"));
            $("news_search_input").value = "";
            $("news_search_input").focus();
            return false;
        }
        var NewsCatID = $("eventchose").value;
        
        window.location.href = "news.htm?SearchKey="+SearchKey+"&NewsType="+NewsCatID;
	},
	
	/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	* Author:
	* Function Name:
	* Description:
	* Input:
	* Output:
	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
	wt_GetPetLevelOfHome: function()
    {
        var url = 'wt_GetBestPlayerLevelOfHome.htm';
        new Ajax.Request(url,
		{
				method:'post',
				parameters:{},
				onSuccess: function(Trans)
				{
					var data = Trans.responseText;
					$("Player_Best_main_content").innerHTML = data;
                }
			}
		);
    },	
	
	/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	* Author:
	* Function Name:
	* Description:
	* Input:
	* Output:
	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
	wt_GetPetLevelOfNews: function()
    {
        var url = 'wt_GetBestPlayerLevelOfNews.htm';
        new Ajax.Request(url,
		{
				method:'post',
				parameters:{},
				onSuccess: function(Trans)
				{
					var data = Trans.responseText;
					$("Player_Best_main_content").innerHTML = data;
                }
			}
		);
    },
	
	/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	* Author:
	* Function Name:
	* Description:
	* Input:
	* Output:
	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
	wt_GetPetXitinOfNews: function()
    {
        var url = 'wt_GetBestPetXitinOfNews.htm';
        new Ajax.Request(url,
		{
				method:'post',
				parameters:{},
				onSuccess: function(Trans)
				{
					var data = Trans.responseText;
					$("topstylist").innerHTML = data;
                }
			}
		);
    },
	
	/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	* Author:
	* Function Name:
	* Description:
	* Input:
	* Output:
	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
	wt_GetPetAsset: function()
    {
        var url = 'wt_GetBestPlayerAsset.htm';
        new Ajax.Request(url,
		{
				method:'post',
				parameters:{},
				onSuccess: function(Trans)
				{
					var data = Trans.responseText;
					$("Player_Rich_main_content").innerHTML = data;
                }
			}
		);
    },	
	
	/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	* Author:
	* Function Name:
	* Description:
	* Input:
	* Output:
	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
	wt_Right: function(element)
	{
		if(this.gClick != 0)
		{
			return;
		}
		this.gClick = 1;
		
		var leftStr = document.getElementById(element).style.left;
		var leftInt = parseInt(leftStr.substr(0,leftStr.length-2)); 
		
		if((leftInt - 233) >= -2097)
		{
			/*leftInt = leftInt - 233+'px';
			document.getElementById('player_Top_Stylist_content').style.left=leftInt;
			*/
			new Effect.Move(element,{x: - 233, duration:1.5});
			alert('aaaaaaaaaaaaaa');
		}				
		t=setTimeout("wt_News.prototype.wt_OnFinish()", 1510);				
	},
	
	/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	* Author:
	* Function Name:
	* Description:
	* Input:
	* Output:
	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
	wt_Left: function(element)
	{
		if(this.gClick != 0)
		{
			return;
		}
		
		this.gClick = 1;
			
		var rightStr = document.getElementById(element).style.left;
		var rightInt = parseInt(rightStr.substr(0,rightStr.length-2)); 
		if((rightInt + 233) <= 0)
		{
			/*rightInt = rightInt + 233+'px';;
			document.getElementById('player_Top_Stylist_content').style.left=rightInt;
			*/
			new Effect.Move(element,{x: 233, duration:1.5});				
		}
		t=setTimeout("wt_News.prototype.wt_OnFinish()", 1510);		
	},
	
	/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	* Author:
	* Function Name:
	* Description:
	* Input:
	* Output:
	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
	wt_OnFinish:function()
	{
		this.gClick = 0;
		clearTimeout(t);
	}
};
