/************************************************************************************/
/* $Revision: 97858 $
 * $Id: cmtaggingservices-6232980-90224511-082808.txt 97858 2008-09-11 10:40:05Z rnaik $
 *
 * Author: Coremetrics/PSD 
 * Coremetrics  v1.4, 09/11/2008
 * COPYRIGHT 1999-2008 COREMETRICS, INC. 
 * ALL RIGHTS RESERVED. U.S.PATENT PENDING
 * Disclaimer: Coremetrics is not responsible for hosting or maintenance or this file
 *
 */
/************************************************************************************/
//Production data warehouse flag
cmSetProduction();
/*===========================GLOBAL VARIABLES ===============================*/
// current page url
var G_PS_URL_PATH = "" + document.location;
var G_PS_PATHNAME = document.location.pathname.toLowerCase();
var G_PS_QUERYSTRING = document.location.search.toLowerCase();
var G_PS_URL_REFERRER = document.referrer.toLowerCase();
var G_PS_COOKIE_LIFETIME = 432000; // 5*24*60*60 = 5 days
// cookie name
var G_PS_COOKIE_CATID = "PS_CATID";
var G_PS_COOKIE_PROD_CATID = "PS_PROD_CATID";
var G_PS_COOKIE_PROD_NAME = "PS_PROD_NAME";
var G_PS_COOKIE_PROFILE = "PS_PROFILE";
var G_PS_COOKIE_PROFILE_1 = "PS_PROFILE_1";
var G_PS_FLAG = "PS_FLAG";		// used as a "session" variable to handle events between pages
// current category ID while browsing/searching/refining, etc
var G_PS_CUR_CATID = null;
var G_PS_CK_SQUERY = "PS_SQUERY";
var G_PS_CK_ALL="PS_ALL";
var G_PS_CK_CUSID="PS_CUSID"
var G_PS_CK_CURRCATID="PS_CURRCAT"
// options for debug mode when sending tag:
// 1: only alert
// 2: only send tag
// 3: alert & send tag
var G_PS_DEBUG_MODE = 2;
/*========================= END GLOBAL VARIABLES =============================*/


/*=========================== BEGIN NAVIGATION ===============================*/
if(psIsSearchResultPage()==false)
{
	if(psSendErrorPageTag()==false)
	{
		psSendPageViewTag();
	}
}
//psSendProductViewTag();
psRegisterListener_Home();
psRegisterListener_SignIn_Home();
psRegisterListener_SignIn_Forum();
psSendRegistrationTag_SignIn();
psRegisterListener_Registration_Step1();
psRegisterListener_Registration_Step2();
psRegisterListener_UpdateProfile();
psSendRegistrationTag_Registration();
psSendErrorPageTag();
//psRegisterListener_Search();
psSendPageViewTag_Search();



/*============================ END NAVIGATION ================================*/


/*===================== BEGIN TAGGING BUSSINESS LOGIC ========================*/

/*====================== END TAGGING BUSSINESS LOGIC =========================*/


/*======================= GENERAL UTILITY FUNCTION ===========================*/


/* PURPOSE: Get inner text of an object or clean remove html tags of a particular string
 * RETURN: resultant string or null object
 */
function psGetInnerText(pTagOjb)
{
	if (pTagOjb != null)
	{
		if (typeof(pTagOjb) == "object")
			return pTagOjb.innerHTML.replace(/\<+.+?\>+/g, "");
		else
			return pTagOjb.replace(/\<+.+?\>+/g, "");
	}
	return null;
}

/* PURPOSE: Remove all unaccepted characters in categoryid, including
 * [, ', ", :, comma,]
 * RETURN: string
 */
function psCleanCatId(pCatId)
{
    return (pCatId != null) ? pCatId.replace(/[\'\":,]/g, "") : null;
}

function psCleanPageId(pPageId)
{
	return (pPageId != null) ? pPageId.replace(/[\n\t\v\r�\'\"]/gi, "") : null; 
}
function psCleanProductName(pProductName)
{
	return (pProductName != null) ? pProductName.replace(/[\n\t\v\r�\'\"]/gi, "") : null; 
}
/* PURPOSE: Remove all leading & trailing spaces of a string
 * Note: [&nbsp;] is also considered as a space
 * Two ways to call: as a string's built-in method or as an independent function
 * RETURN: string
 */
function psTrim(pStr)
{
	if (pStr == null || typeof(pStr) != "string")
		return pStr;

	return (pStr) ? pStr.replace(/&nbsp;/gi, ' ').replace(/^\s+|\s+$/g, '') : null;
}
String.prototype.trim = psTrim;

/* PURPOSE: extract value from the URL
 * in format of http://xxx.com/page.ext?key1=value1&key2=value2
 * RETURN: string value of the parameter
 */
function psGetValueFromUrl(pUrl, pKey)
{
    var re = new RegExp("[?&]" + pKey + "=([^&$]*)", "i");
    if (pUrl.search(re) == -1)
		return null;
    return unescape(RegExp.$1);
}

/* PURPOSE: returns the value of an element based on element_id
 * @pValueFlag: TRUE means VALUE  attribute of SELECT object returned, not innerHTML
 * RETURN: 
 *  Normal tag: decoded innerHTML
 *  INPUT tag: value attribute
 *  SELECT tag: decoded label of the selected option
 */
function psGetElementValueById(pTagId, pValueFlag)
{
    var tag = document.getElementById(pTagId);
    return psGetElementValue(tag, pValueFlag);
}

/* PURPOSE: returns the value of an element based on element object
 * Note: this function returns decoded text
 * to avoid "double" decode, don't invoke psHtmlDecode on returned value again
 * @pValueFlag: TRUE means VALUE  attribute of SELECT object returned, not innerHTML
 * RETURN: 
 *  Normal tag: decoded innerHTML
 *  INPUT tag: value attribute
 *  SELECT tag: decoded label of the selected option
 *  NULL: if element not exist
 */
function psGetElementValue(pTagObj, pValueFlag)
{
    var tagValue = null;
    if (pTagObj != null)
    {
        if (pTagObj.tagName.search(/^INPUT$/i) > -1)
            tagValue = pTagObj.value;
        else if (pTagObj.tagName.search(/^SELECT$/i) > -1)
        {
            if (pValueFlag == true)
                tagValue = pTagObj.options[pTagObj.selectedIndex].value;
            else
                tagValue = psHtmlDecode(pTagObj.options[pTagObj.selectedIndex].innerHTML);// return label instead of value
        }
        else
            tagValue = psHtmlDecode(pTagObj.innerHTML);
    }

    return tagValue;
}

/* PURPOSE: validate email format
 * RETURN: boolean
 */
function psCheckEmail(pEmail) 
{
    if (pEmail)
    {
        var i = pEmail.search(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/);
        return (i > -1);
    }

    return false;
}

/* PURPOSE: convert special HTML characters to normal character
 * Note: for each project, this function needs to be updated
 * RETURN: decoded string
 */
function psHtmlDecode(pValue)
{
    if (pValue)
    {
        pValue = pValue.replace(/&nbsp;/gi, " ");
        pValue = pValue.replace(/&quot;/gi, '"');
        pValue = pValue.replace(/&amp;/gi, "&");
        pValue = pValue.replace(/&lt;/gi, "<");
        pValue = pValue.replace(/&gt;/gi, ">");
    }

    return pValue;
}

/* PURPOSE: retrieve cookie value
 * RETURN: string
 */
function psGetCookie(pCookieName)
{
    if (!pCookieName)
		return null;

    var start = document.cookie.indexOf(pCookieName + "=");
    if (start > -1)
    {
        start = start + pCookieName.length + 1; 
        var end = document.cookie.indexOf(";", start);
        if (end == -1)
            end = document.cookie.length;
        return unescape(document.cookie.substring(start, end));
    }
    return null;
}

/* PURPOSE: set cookie value
 * Note: if the designated cookie is too big, the old items will be removed
 * because cookie size is limited to 4K
 * @pLifeTime in seconds
 * pDomain: don't specify if using current domain
 * RETURN: boolean
 */
function psSetCookie(pCookieName, pCookieValue, pLifeTime, pDomain)
{
    if (!pCookieName)
		return false;

	if(pLifeTime == "delete") 
    {         
        CC(pCookieName);//delete cookie by calling coremetrics's cookie function
        return true;
    }
    // set cookie by calling coremetrics's cookie function
    var expire = (pLifeTime) ? (new Date((new Date()).getTime() + (1000 * pLifeTime))).toGMTString() : null;
    
    return CB(pCookieName, escape(pCookieValue), expire, pDomain);
}

/* PURPOSE: set value in cookie in format of:
 * #key1~value1#key2~value2
 * RETURN: string
 * NOTE: Use null or '' for pValue to remove the pair specified by pKey
 */
function psSetValueToCookie(pCookieName, pKey, pValue)
{
	// "normalize" input parameters
	pCookieName = psTrim(pCookieName);
	pKey = psTrim(pKey);
	// 
	var catCookie = psGetCookie(pCookieName);
	if (catCookie == null)
		catCookie = '';

	if (catCookie.indexOf(pKey) >=0) // Store before -> remove the old value
	{
        var reg = new RegExp("#" + pKey + "~([^#]*)", "gi");
        catCookie = catCookie.replace(reg, "");
	}
	// remove the last items (eldest items) until cookie size < 3500	
	if (pValue != null && pValue != '')
	{
		catCookie = "#" + pKey + "~" + pValue + catCookie;
		var cookieArray = null;
		while (catCookie.length > 3500)
		{
			cookieArray = catCookie.split("#");
			cookieArray.pop();
			catCookie = cookieArray.join("#");
		}
	}
	// Save to cookie
	psSetCookie(pCookieName, catCookie, G_PS_COOKIE_LIFETIME);
}

/* PURPOSE: get value stored in cookie in format of:
 * #key1~value1#key2~value2
 * RETURN: string
 */
function psGetValueFromCookie(pCookieName, pKey)
{
	// "normalize" input parameters
	pCookieName = psTrim(pCookieName);
	pKey = psTrim(pKey);
	// extract catId associated with the specified key (pKey)
    var catCookie = psGetCookie(pCookieName);
    if (catCookie != null)
    {
        var re = new RegExp("#" + pKey + "~([^#$]+)", "i");
		if (catCookie.search(re) == -1)
			return null;

        return RegExp.$1;
    }
    return null;
}

/********************************************************/
/* WRAPPER FOR COREMETRICS' TAG FUNCTIONS               */
/********************************************************/
function psCreatePageviewTag(pageID, categoryID, searchString, searchResults) 
{
	pageID=psCleanPageId(pageID);
	categoryID=psCleanCatId(categoryID);
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreatePageviewTag(" + pageID + ", " + categoryID + ", " + searchString + ", " + searchResults + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreatePageviewTag(pageID, categoryID, searchString, searchResults);
}

function psCreateProductviewTag(productID, productName, categoryID) 
{
	productName = psCleanProductName(productName);
	categoryID=psCleanCatId(categoryID);
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateProductviewTag(" + productID + ", " + productName + ", " + categoryID + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateProductviewTag(productID, productName, categoryID);
}

function psCreateShopAction5Tag(productID, productName, productQuantity, productPrice, categoryID) 
{
	productName = psCleanProductName(productName);
	categoryID=psCleanCatId(categoryID);
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateShopAction5Tag(" + productID + ", " + productName + ", " + productQuantity + ", " + productPrice + ", " + categoryID + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateShopAction5Tag(productID, productName, productQuantity, productPrice, categoryID);
    
}

function psCreateShopAction9Tag(productID, productName, productQuantity, productPrice, customerID, orderID, orderTotal, categoryID) 
{
	productName = psCleanProductName(productName);
	categoryID=psCleanCatId(categoryID);
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateShopAction9Tag(" + productID + ", " + productName + ", " + productQuantity + ", " + productPrice + ", " + customerID + ", " + orderID + ", " + orderTotal + ", " + categoryID + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateShopAction9Tag(productID, productName, productQuantity, productPrice, customerID, orderID, orderTotal, categoryID);
}

function psCreateOrderTag(orderID, orderTotal, orderShipping, customerID, customerCity, customerState, customerZIP) 
{
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateOrderTag(" + orderID + ", " + orderTotal + ", " + orderShipping + ", " + customerID + ", " + customerCity + ", " + customerState + ", " + customerZIP + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateOrderTag(orderID, orderTotal, orderShipping, customerID, customerCity, customerState, customerZIP);
}

function psCreateConversionEventTag(eventID, actionType, categoryID, points) 
{
	categoryID=psCleanCatId(categoryID);
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateConversionEventTag(" + eventID + ", " + actionType + ", " + categoryID + ", " + points + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateConversionEventTag(eventID, actionType, categoryID, points);
}

function psCreateRegistrationTag(customerID, customerEmail, customerCity,
				customerState, customerZIP,customerCountry, newsletterName, 
				subscribe) 
{
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateRegistrationTag(" + customerID + ", " + customerEmail + ", " + customerCity + ", " + customerState + ", " + customerZIP + ", " + newsletterName + ", " + subscribe + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateRegistrationTag(customerID, customerEmail, customerCity, customerState, customerZIP, customerCountry, newsletterName, subscribe);
}

function psCreateErrorTag(pageID, categoryID) 
{
	pageID=psCleanPageId(pageID);
	categoryID=psCleanCatId(categoryID);
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmCreateErrorTag(" + pageID + ", " + categoryID + ")");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmCreateErrorTag(pageID, categoryID);
}

function psDisplayShop5s()
{
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmDisplayShop5s()");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmDisplayShop5s();
}

function psDisplayShop9s()
{
    if (G_PS_DEBUG_MODE == 1 || G_PS_DEBUG_MODE == 3)
        alert("cmDisplayShop9s()");
    if (G_PS_DEBUG_MODE == 2 || G_PS_DEBUG_MODE == 3)
        cmDisplayShop9s();
}
/*===========================END GENERAL UTILITY FUNCTION ==================*/

/* 	#SECTION : 	Methods that can be reused in other project		 */

// Find element by name
function psGetElementsByClassName(psDocument, psElementTagName, psClassName)
{
    var arrResult = new Array();
    var index = 0;
    var arrInputs = psDocument.getElementsByTagName(psElementTagName);
    if(arrInputs == null)
    {
        return null;
    }
    for(var i = 0; i < arrInputs.length; i ++ )
    {
        if(arrInputs[i].className.toLowerCase() == psClassName)
        {
            arrResult[index ++ ] = arrInputs[i];
        }
    }
    return arrResult;
}

// Find element by name
function psGetElementByName(psDocument, psElementTagName, psElementName, psElementType)
{
    // Find all elements that tag name is specified
    var arrInputs = psDocument.getElementsByTagName(psElementTagName);
    if(arrInputs == null)
    {
        return null;
    }
    for(var i = 0; i < arrInputs.length; i ++ )
    {
        // Find one that has specified name
        if(arrInputs[i].name.toLowerCase() == psElementName)
        {
            // If element type is provided
            if(typeof(psElementType) != "undefined" && psElementType != "")
            {
                // Find it
                if(arrInputs[i].type.toLowerCase() == psElementType)
                {
                    return arrInputs[i];
                }
            }
            else
            {
                return arrInputs[i];
            }
        }
    }
    return null;
}


function psGetElementByName_1(psDocument, psElementTagName, psElementName, psElementType, psClassName)
{
    // Find all elements that tag name is specified
    var arrInputs = psDocument.getElementsByTagName(psElementTagName);
    if(arrInputs == null)
    {
        return null;
    }
    for(var i = 0; i < arrInputs.length; i ++ )
    {
        // Find one that has specified name
        if(arrInputs[i].name.toLowerCase() == psElementName)
        {
            // If element type is provided
            if(typeof(psElementType) != "undefined" && psElementType != "")
            {
                // Find it
                if(arrInputs[i].type.toLowerCase() == psElementType)
                {
					if(typeof(psClassName) != "undefined" && psClassName != "")
					{
						// Find it
						if(arrInputs[i].className.toLowerCase() == psClassName)
						{
							return arrInputs[i];
						}
					}
					else
					{
						return arrInputs[i];
					}
                }				
            }
			else
			if(typeof(psClassName) != "undefined" && psClassName != "")
            {
                // Find it
                if(arrInputs[i].className.toLowerCase() == psClassName)
                {
                    return arrInputs[i];
                }
            }
            else
            {
                return arrInputs[i];
            }
        }
    }
    return null;
}

// Get elements which name is known
function psGetElementsByName(psDocument, psElementTagName, psElementName, psElementType)
{
    var arrResult = new Array();
    var index = 0;
    // Find all elements that tag name is specified
    var arrInputs = psDocument.getElementsByTagName(psElementTagName);
    if(arrInputs == null)
    {
        return null;
    }
    for(var i = 0; i < arrInputs.length; i ++ )
    {
        // Find one that has specified name
        if(arrInputs[i].name.toLowerCase() == psElementName)
        {
            // If element type is provided
            if(typeof(psElementType) != "undefined" && psElementType != "")
            {
                // Find it
                if(arrInputs[i].type.toLowerCase() == psElementType)
                {
                    arrResult[index] = arrInputs[i];
                    index ++ ;
                }
            }
            else
            {
                arrResult[index] = arrInputs[i];
                index ++ ;
            }
        }
    }

    return arrResult;
}

/* 	#SECTION : Methods to check element exist or not */
// Check if array is exist or not
function psCheckArrayExist(pArrElement)
{
    if(typeof(pArrElement) == "undefined" || pArrElement == null || pArrElement.length <= 0)
    {
        return false;
    }

    return true;
}

// Check an element exist or not
function psCheckElementExist(pElement)
{
    if(typeof(pElement) == "undefined" || pElement == null)
    {
        return false;
    }

    return true;
}

//End

function psGetPathName()
{
	return G_PS_PATHNAME.toLowerCase();
}

function psGetV()
{
	return psGetValueFromUrl(G_PS_URL_PATH, "v");
}

function psGetCat()
{
	return psGetValueFromUrl(G_PS_URL_PATH, "cat");
}


function psGetType()
{
	return psGetValueFromUrl(G_PS_URL_PATH, "type");
}

function psGetAct()
{
	return psGetValueFromUrl(G_PS_URL_PATH, "act");
}

function psGetSubject_ContactUs()
{
	return psGetValueFromUrl(G_PS_URL_PATH, "subject");
}

function psGetProfileID()
{
	return psGetValueFromUrl(G_PS_URL_PATH, "id");
}

function psGetQuery()
{
	return psGetValueFromUrl(G_PS_URL_PATH, "query");
}

function psGetHighlite()
{
	return psGetValueFromUrl(G_PS_URL_PATH, "highlite");
}

function psSendPageViewTag()
{
	var catId="Home";
	var pageID="Home";
	
	var pageName=psGetPathName();
	if(pageName=="/")
	{
	}
	else
		if(pageName=="/photos/submit.php")
	{
		catId="my profile";
		pageID="Submit your photo";
	}
	else
		if(pageName=="/photos/")
	{
		catId="photos";
		pageID=catId;
	}
	else
		if(pageName.indexOf("/photos/")>=0)
	{
		var temp=psGetParameter();		
		catId="photos";
		pageID="photos";
		if(psCheckElementExist(temp)==true)
		{
			pageID+=":"+temp;
			if(G_PS_URL_PATH.indexOf("v=")>=0)
			{
				pageID+="-"+psGetPhotoVideoName();
				pageID=psStripOffText(pageID);
			}
			temp=psGetCat();			
			if(psCheckElementExist(temp)==true)
			{				
				catId+=":category";
			}
		}
		else
		{
			pageID=psTrimPathName();
		}		
	}	
	else
		if(pageName=="/videos/submit.php")
	{		
		catId="my profile";
		pageID="submit your video";
	}
	else
		if(pageName=="/videos/")
	{
		catId="videos";
		pageID=catId;
	}
	else
		if(pageName.indexOf("/videos/")>=0)
	{
		var temp=psGetParameter();		
		catId="videos";
		pageID="videos";
		if(psCheckElementExist(temp)==true)
		{
			pageID+=":"+temp;
			if(G_PS_URL_PATH.indexOf("v=")>=0)
			{
				pageID+="-"+psGetPhotoVideoName();
				pageID=psStripOffText(pageID);
			}
			
			temp=psGetCat();			
			if(psCheckElementExist(temp)==true)
			{				
				catId+=":category";
			}
		}		
	}	
	else
		if(pageName=="/forums/")
	{
		catId="forums";
		pageID=catId;
	}
	else
		if(pageName.indexOf("/forums/")>=0)
	{
		catId="forums";
		pageID=catId;
		
		if(G_PS_URL_PATH.toLowerCase().indexOf("www.airshowbuzz.com/forums/index.php?act=msg&code=")>=0||G_PS_URL_PATH.toLowerCase().indexOf("www.airshowbuzz.com/forums/index.php?act=usercp&code=")>=0)
		{
			var temp=psSendPageViewTag_UserCP();
			if(psCheckElementExist(temp)==true)
			{
				//pageID+=":"+psSendPageViewTag_UserCP();
				pageID=psSendPageViewTag_UserCP();
			}
			else
			{
				pageID+=":"+psGetParameter();				
			}
			catId="control panel";
			if(psCheckElementExist(pageID)==false)
			{
				return;
			}
		}
		else
		{
			var temp=psGetParameter();
			if(psCheckElementExist(temp)==true)
			{
				var temp1=pageID;
				pageID+=":"+temp;
				
				if(G_PS_URL_PATH.indexOf("showforum=")>=0)
				{
					pageID+="-"+psGetForumName_ShowForum();
					var temp2=psGetValueFromUrl(G_PS_URL_PATH, "showforum");
					if(psCheckElementExist(temp2)==true && temp2!="")
					{
						temp1+=":showforum="+temp2;
						pageID=temp1;
					}
					pageID+="-"+psGetForumName_ShowForum();
				}
				else
				if(G_PS_URL_PATH.indexOf("showtopic=")>=0)
				{
					pageID+="-"+psGetForumName_ShowTopic();
				}
				pageID=psStripOffText(pageID);
			}
			else
			{
				pageID=psTrimPathName();
			}
		}		
	}
	else
		if(pageName=="/schedules/")
	{
		pageID="schedules";
		catId="Air show schedules";		
	}
	else
		if(pageName.indexOf("/schedules/")>=0)
	{
		pageID="schedules";
		catId="Air show schedules";
		var temp=psGetParameter();
		if(psCheckElementExist(temp)==true)
		{
			pageID+=":"+temp;			
		}
		else
		{
			pageID=psTrimPathName();
		}
	}
	else
		if(pageName=="/profiles/search.php")
	{
		pageID="profiles:search";
		catId="Member profile";
	}
	else
		if(pageName.indexOf("/contact.php")>=0)
	{
		catId="Contact us";
		pageID="contact.php";
		
		var subject=psGetSubject_ContactUs();
		if(psCheckElementExist(subject)==true)
		{
			pageID=subject;
		}
	}
	else
		if(pageName=="/registration.php")
	{
		pageID="registration:step1";
		catId="Account";
	}
	else
		if(pageName.indexOf("/registration_1.php")>=0)
	{
		pageID="registration";
		catId="Account";
	}
	else
		if(pageName.indexOf("/registration_2.php")>=0)
	{
		pageID="registration:step2";
		catId="Account";
	}
	else
		if(pageName.indexOf("/registration_3.php")>=0)
	{
		pageID="registration:step3";
		catId="Account";
	}
	else
		if(pageName.indexOf("/profiles/edit.php")>=0)
	{
		pageID="Edit profile";		
		catId="Edit profile";		
	}
	else
		if(pageName.indexOf("/profiles/")>=0)
	{
		pageID="profiles";
		catId="Member profile";		
		
		var temp=psGetParameter();
		if(psCheckElementExist(temp)==true)
		{
			pageID+=":"+temp;
		}
		else
		{
			pageID=psTrimPathName();
		}
		
		if(psIsMyProfilePage()==true)
		{
			pageID="Member profile";
			catId="My profile";
			
			if(pageName.indexOf("profiles/browse_friends.php")>=0)
			{
				pageID="friends";
			}			
		}
		
	}
	else
	{
		pageID=psTrimPathName();
		if(pageID=="")
		{
			return;
		}
	}
	if(psCheckElementExist(pageID)==false|| pageID==""|| pageID=="null")
	{
		return;
	}
	
	if(psIsNotFoundPage()==true)
	{
		pageID="page not found ";
		catId="Error";
		psCreateErrorTag(pageID, catId);
		return;
	}
	psCreatePageviewTag(pageID, catId);
}

function psTrimPathName()
{
	var pageName=psGetPathName();		
	if(pageName.indexOf("/")>=0)
	{
		var temp=pageName.split("/");
		return temp[temp.length-1];
	}
	
	return pageName;
}

function psGetParameter()
{
	var temp="?";
	var pageName=G_PS_URL_PATH;
	if(pageName.indexOf(temp)>=0)
	{
		temp=pageName.split(temp);
		if(temp[1].indexOf("&")<0)
		{
			return temp[1];
		}
		else
		{
			temp=temp[1].split("&");
			return temp[0];
		}
	}
	
	return null;
}

function psSendProductViewTag()
{
	var pageName=psGetPathName();
	var catId=null;
	var prName=null;
	var prID=null;
	if(pageName.indexOf("/photos/view.php")>=0)
	{
		catId="photos";
	}
	
	if(pageName.indexOf("/videos/view.php")>=0)
	{
		catId="videos";
	}
	
	if(psCheckElementExist(catId)==false)
	{
		return;
	}
	
	prID=psGetV();
	if(psCheckElementExist(prID)==false)
	{
		return;
	}
	
	var oSpan=document.getElementById("title");
	if(psCheckElementExist(oSpan)==true)
	{
		prName=psGetInnerText(oSpan);
	}
	
	psCreateProductviewTag(prID, prName, catId);
}


function psRegisterListener_Home()
{
	psRegisterListener_Home_LeftSide();
}

function psRegisterListener_Home_LeftSide()
{
	if(psGetPathName().indexOf("photos/photo_vertical.php")>=0)
	{
		var photoType=psGetType();
		if(psCheckElementExist(photoType)==false)
		{
			return;
		}
		var arrImg=document.getElementsByTagName("img");
		if(psCheckArrayExist(arrImg)==false)
		{
			return;
		}
		
		for(var i=0;i<arrImg.length;i++)
		{
			if(arrImg[i].src.indexOf("files/photo/gallery/photos/")>=0)
			{
				var oldFunc=arrImg[i].onclick;
				arrImg[i].onclick=function()
				{
					psSetValueToCookie(G_PS_CK_ALL, G_PS_COOKIE_CATID, photoType);
					return oldFunc;
				}
			}
		}
		
	}	
}

function psRegisterListener_Home_CenterSide()
{
	if(psGetPathName().indexOf("videos/video_vertical.php")>=0)
	{
		var photoType=psGetType();
		if(psCheckElementExist(photoType)==false)
		{
			return;
		}
		var arrImg=document.getElementsByTagName("img");
		if(psCheckArrayExist(arrImg)==false)
		{
			return;
		}
		
		for(var i=0;i<arrImg.length;i++)
		{
			if(arrImg[i].src.indexOf("files/photo/gallery/photos/")>=0)
			{
				var oldFunc=arrImg[i].onclick;
				arrImg[i].onclick=function()
				{
					psSetValueToCookie(G_PS_CK_ALL, G_PS_COOKIE_CATID, photoType);
					return oldFunc;
				}
			}
		}
		
	}	
}

function psTest()
{
	var catId=psGetValueFromCookie(G_PS_CK_ALL, G_PS_COOKIE_CATID);	
}

function psSaveCustID2Ck()
{
	var temp=psGetElementByName(document, "input", "username", "text");
	if(psCheckElementExist(temp)==false)
	{
		return;
	}
	
	temp=temp.value;
	
	psSetValueToCookie(G_PS_CK_ALL, G_PS_COOKIE_PROFILE, temp);	
}

function psRegisterListener_SignIn_Home()
{	
	var temp=psGetElementsByClassName(document, "input", "button");
	if(psCheckArrayExist(temp)==false)
	{
		return;
	}
	temp=temp[0];
	var oldFunc=temp.onclick;	
	temp.onclick=function()
	{
		psSetValueToCookie(G_PS_CK_ALL, G_PS_FLAG, "false");
		psSaveCustID2Ck();		
		return oldFunc;
	}
}


function psIsSignedIn()
{
	if(psGetPathName().indexOf("/forums/")>=0)
	{
		var temp1=document.getElementById("userlinks");
		if(psCheckElementExist(temp1)==true)
		{
			return true;
		}
	}
	var temp=document.getElementsByTagName("img");
	if(psCheckArrayExist(temp)==false)
	{		
		return false;
	}
	for(var i=0;i<temp.length;i++)
	{
		if(temp[i].src.indexOf("images/log_out.jpg")>=0)
		{			
			return true;
		}
	}
	
	
	return false;
}


function psSendRegistrationTag_SignIn()
{
	if(psIsSignedIn()==true)
	{
		var temp=psGetValueFromCookie(G_PS_CK_ALL, G_PS_FLAG);
		if(psCheckElementExist(temp)==false)
		{
			return;
		}
		
		if(temp=="false")
		{			
			temp=psGetValueFromCookie(G_PS_CK_ALL, G_PS_COOKIE_PROFILE);
			if(psCheckElementExist(temp)==false)
			{
				return;
			}
			var sep="-_-";
			if(temp.indexOf(sep)>=0)
			{
				var arrTemp=temp.split(sep);
				psCreateRegistrationTag(arrTemp[0], arrTemp[1]);				
			}
			else
			{
				psCreateRegistrationTag(temp);
			}			
			psSetValueToCookie(G_PS_CK_ALL, G_PS_FLAG, "true");
		}
	}
}

function psRegisterListener_Registration_Step1()
{	
	if(psGetPathName().indexOf("/registration.php")<0)
	{
		return;
	}
	
	if(psIsStep_Registration("1")==false)
	{		
		return;
	}
	
	var temp=document.getElementsByTagName("input");
	if(psCheckArrayExist(temp)==false)
	{
		return;
	}	
	var btnContinue=null;
	for(var i=0;i<temp.length;i++)
	{
		if(temp[i].src.indexOf("images/btn_continue.gif")>=0)
		{
			btnContinue=temp[i];
			break;
		}
	}
	
	if(psCheckElementExist(btnContinue)==false)
	{
		return;
	}	
	temp=btnContinue.onclick;
	btnContinue.onclick=function()
	{
		
		psSaveCustProfile2Ck();		
		return temp;
	}
}

function psSaveCustProfile2Ck()
{
	
	var temp=psGetElementByName_1(document, "input", "username", "text", "text");
	
	if(psCheckElementExist(temp)==false)
	{
		return;
	}
	
	var pUsername=temp.value;	
	temp=psGetElementByName(document, "input", "email", "text");
	if(psCheckElementExist(temp)==false)
	{
		return;
	}
	
	var pEmail=temp.value;	
	var sep="-_-";
	temp=pUsername+sep+pEmail;	
	psSetValueToCookie(G_PS_CK_ALL, G_PS_COOKIE_PROFILE, temp);	
}

function psIsStep_Registration(step)
{
	var temp=document.getElementsByTagName("img");
	if(psCheckArrayExist(temp)==false)
	{
		return false;
	}
	var temp1=null;
	if(step=="1")	
	{
		temp1="images/reg_step_1.gif"
	}
	else
		if(step=="2")
	{
		temp1="images/reg_step_2.gif"
	}
	else
		if(step=="3")
	{
		temp1="images/reg_step_3.gif"
	}
	for(var i=0;i<temp.length;i++)
	{
		
		if(temp[i].src.indexOf(temp1)>=0)
		{
			return true;
		}
	}
	
	return false;
}

function psRegisterListener_Registration_Step2()
{	
	if(psGetPathName().indexOf("/registration_2.php")<0)
	{
		return;
	}	
	if(psIsStep_Registration("2")==false)
	{		
		return;
	}
	
	var temp=document.getElementsByTagName("input");
	if(psCheckArrayExist(temp)==false)
	{
		return;
	}	
	var btnContinue=null;
	for(var i=0;i<temp.length;i++)
	{
		if(temp[i].src.indexOf("images/btn_continue.gif")>=0)
		{
			btnContinue=temp[i];
			break;
		}
	}
	
	if(psCheckElementExist(btnContinue)==false)
	{
		return;
	}	
	temp=btnContinue.onclick;
	btnContinue.onclick=function()
	{		
		psSaveCustProfile2Ck_S2();		
		return temp;
	}	
}

function psSaveCustProfile2Ck_S2()
{
	var temp=psGetElementByName_1(document, "input", "city", "text", "text");
		
	var sep="-_-";
	var strTemp=sep;
	if(psCheckElementExist(temp)==false)
	{
		strTemp+=sep;
	}
	else
	{
		var city=temp.value;
		strTemp+=city+sep;		
	}
	var temp=psGetElementByName(document, "select", "state");
	if(psCheckElementExist(temp)==false)
	{
		temp=psGetElementByName(document, "select", "STATE");
		if(psCheckElementExist(temp)==true)
		{
			var state=temp.options[temp.selectedIndex].text;
			strTemp+=state;			
		}		
	}
	else
	{
		var state=temp.options[temp.selectedIndex].text;		
		strTemp+=state;		
	}
	strTemp+=sep;
	
	temp=psGetElementByName(document, "select", "country");
	if(psCheckElementExist(temp)==false)
	{
		temp=psGetElementByName(document, "select", "COUNTRY");
		if(psCheckElementExist(temp)==true)
		{
			var country=temp.options[temp.selectedIndex].text;
			strTemp+=country;			
		}		
	}
	else
	{
		var country=temp.options[temp.selectedIndex].text;		
		strTemp+=country;		
	}
	strTemp+=sep;
	
	temp=psGetElementByName(document, "input","rec_email", "checkbox");
	if(psCheckElementExist(temp)==false)
	{
		temp=psGetElementByName(document, "input", "REC_EMAIL", "checkbox");
		if(psCheckElementExist(temp)==false)
		{			
			strTemp+=sep;
		}
	}
	else
	{
		if(temp.checked==false)
		{			
			strTemp+=sep;
		}
		else
		{
			strTemp+="email updates"+sep+"Y";
		}
	}
	//var sep="-_-";
	//var strTemp=sep+"Y";
	psSetValueToCookie(G_PS_CK_ALL, G_PS_COOKIE_PROFILE_1, strTemp);	
}

function psSendRegistrationTag_Registration()
{
	if(psGetPathName().indexOf("/registration_3.php")<0)
	{
		return;
	}
	if(psIsStep_Registration("3")==false)
	{		
		return;
	}
	
	var temp=document.getElementsByTagName("b");
	if(psCheckArrayExist(temp)==false)
	{
		return;
	}
	
	for(var i=0;i<temp.length;i++)
	{
		if(psGetInnerText(temp[i]).toLowerCase().indexOf("been created")>=0)
		{
			psSendRegistrationTag_Registration_1();
			return;
		}
	}
}

function psSendRegistrationTag_Registration_1()
{	
	var temp=psGetValueFromCookie(G_PS_CK_ALL, G_PS_COOKIE_PROFILE);
	if(psCheckElementExist(temp)==false)
	{
		return;
	}

	var strTemp=temp;
	var temp1=psGetValueFromCookie(G_PS_CK_ALL, G_PS_COOKIE_PROFILE_1);
	if(psCheckElementExist(temp1)==false|| temp1=="null")
	{		
	}
	else
	{
		strTemp+=temp1;
	}
	
	var sep="-_-";
	var arrTemp=strTemp.split(sep);
	if(psCheckArrayExist(arrTemp)==false)
	{
		return;
	}
	
	if(arrTemp.length==2)
	{
		psCreateRegistrationTag(arrTemp[0], arrTemp[1]);
	}
	else
		if(arrTemp.length>2)
	{
		//temp=arrTemp[2];
//		if(arrTemp.length>3)
//		{
//			temp1=arrTemp[3];
//		}
//		else
//		{
//			temp1=null;
//		}
//		
//		if(psCheckElementExist(temp)==false || temp=="")
//		{
//			temp=null;
//		}
//		if(psCheckElementExist(temp1)==false || temp1=="")
//		{
//			temp1=null;
//		}
		
		psCreateRegistrationTag(arrTemp[0], arrTemp[1],arrTemp[2], arrTemp[3],null, arrTemp[4],arrTemp[5], arrTemp[6], arrTemp[7]);
	}	
}

function psRegisterListener_UpdateProfile()
{
	if(psGetPathName().indexOf("profiles/edit.php")<0)
	{
		return;
	}
	
	var temp=document.getElementsByTagName("input");
	if(psCheckArrayExist(temp)==false)
	{
		return;
	}
	
	for(var i=0;i<temp.length;i++)
	{
		if(temp[i].type=="image" && temp[i].src.indexOf("/images/btn_save.gif")>=0)
		{
			var temp1=temp[i];
			var oldFunc=temp1.onclick;
			temp1.onclick=function()
			{
				psSaveCustProfile2Ck_UpdateProfile();
				if(psCheckElementExist(oldFunc)==true)
				{
					return oldFunc();
				}
			}
			break;
		}
	}
}

function psSaveCustProfile2Ck_UpdateProfile()
{
	var temp=psGetElementByName(document, "input", "login_name", "text");
	if(psCheckElementExist(temp)==false)
	{
		return;
	}
	
	temp=temp.value;
	
	var temp1=psGetElementByName(document, "input", "email", "text");
	if(psCheckElementExist(temp1)==false)
	{
		return;
	}
	
	temp1=temp1.value;
	
	var sep="-_-";
	temp=temp+sep+temp1;
	psSetValueToCookie(G_PS_CK_ALL, G_PS_COOKIE_PROFILE, temp);
	psSetValueToCookie(G_PS_CK_ALL, G_PS_FLAG, "false");
}

function psIsSearchResultPage()
{
	if(G_PS_URL_PATH.toLowerCase().indexOf("=search")>=0 && G_PS_URL_PATH.toLowerCase().indexOf("query=")>=0)
	{
		return true;
	}
	
	if(G_PS_URL_PATH.toLowerCase().indexOf("=search")>=0 && G_PS_URL_PATH.toLowerCase().indexOf("code=show")>=0)
	{
		return true;
	}	
	return false;
}

function psGetPage()
{
	return psGetValueFromUrl(G_PS_URL_PATH, "page");
}

function psGetPageCurrent()
{
	var arrTemp=psGetElementsByClassName(document, "span", "pagecurrent");
	if(psCheckArrayExist(arrTemp)==false)
	{
		return "1";
	}
	
	for(var i=0;i<arrTemp.length;i++)
	{
		return psGetInnerText(arrTemp[i]);
	}
	
	return "1";
}

function psSendPageViewTag_Search()
{
	if(psIsSearchResultPage()==false)
	{
		return;
	}	
	var query=psGetQuery();	
	if(psCheckElementExist(query)==false)
	{		
		query=psGetHighlite();
		if(psCheckElementExist(query)==false)
		{
			query=psGetNavStrip();			
			if(psCheckElementExist(query)==false)
			{
				return;
			}
			else
			{
				psCreatePageviewTag("Posts since your last visit", "forums");
				return;
			}
		}
	}
	
	query=psHtmlDecode(query);
	query=query.replace(/[+]/gi,' ')	
	var pageID="SearchSuccessful";
	var catId="Search";
	
	if(psDoesSearchSucceed()==false)
	{
		pageID="SearchUnsuccessful";
	}
	var searchResults="0";
	searchResults=psGetSearchResults();
	if(searchResults=="0")
	{
		pageID="SearchUnsuccessful";
	}
	else
	{		
		var pageNo=psGetPage();
		if(psGetPathName().indexOf("forums/")>=0)
		{
			pageNo=psGetPageCurrent();
		}
		
		if(psCheckElementExist(pageNo)==true)
		{
			pageID="Page"+pageNo+":"+pageID;
		}
		else
		{
			pageID="Page1"+":"+pageID;
		}
	}
	psCreatePageviewTag(pageID, catId, query, searchResults);
}

function psGetNavStrip()
{
	var temp= document.getElementById("navstrip");
	if(psCheckElementExist(temp)==false)
	{
		return null;
	}
	
	temp=psGetInnerText(temp).toLowerCase();
	if(temp.indexOf("posts since your last visit")>=0)
	{
		return "posts since your last visit";
	}
	
	return null;
}
function psDoesSearchSucceed()
{
	var temp=document.getElementsByTagName("h3");
	if(psCheckElementExist(temp)==true)
	{
		for(var i=0;i<temp.length;i++)
		{			
			if(psGetInnerText(temp[i]).toLowerCase().indexOf("your search returned no results.")>=0)
			{
				return false;
			}
		}
	}
	
	temp=document.getElementsByTagName("span");
	if(psCheckElementExist(temp)==true)
	{
		for(var i=0;i<temp.length;i++)
		{
			if(psGetInnerText(temp[i]).toLowerCase().indexOf("displaying 1 - 0 of 0")>=0)
			{
				return false;
			}
			
			if(psGetInnerText(temp[i]).toLowerCase().indexOf("displaying 1 - 0 of 0")>=0)
			{
				return false;
			}
		}
	}
	
	temp=document.getElementById("inner");
	if(psCheckElementExist(temp)==true)
	{
		temp=psGetInnerText(temp);
		if(psTrim(temp)=="")
		{
			return false;
		}
	}
	
	return true;
}


function psGetSearchResults()
{
	if(G_PS_URL_PATH.toLowerCase().indexOf("=search")>=0 && G_PS_URL_PATH.toLowerCase().indexOf("code=show")>=0)
	{
		return temp=psGetSearchResults_Forum();
	}
	
	var temp=document.getElementsByTagName("span");
	if(psCheckElementExist(temp)==true)
	{
		for(var i=0;i<temp.length;i++)
		{
			if(psGetInnerText(temp[i]).toLowerCase().indexOf("displaying ")>=0)
			{
				temp=psGetInnerText(temp[i]).split(" ");
				return temp[temp.length-1];
			}
		}
	}	
	return "0";
}

function psGetSearchResults_Forum()
{
	var arrTemp=document.getElementsByTagName("span");
	if(psCheckArrayExist(arrTemp)==false)
	{
		return "1";
	}
	
	for(var i=0;i<arrTemp.length;i++)
	{		
		if(arrTemp[i].className.toLowerCase()=="pagelink" && arrTemp[i].id.toLowerCase().indexOf("page-jump")>=0)
		{
			var temp=psGetInnerText(arrTemp[i]);
			arrTemp=temp.split(" ");
			return arrTemp[0];
		}
	}
	return "1";
}

function psSendErrorPageTag()
{
	var arrTemp=psGetElementsByClassName(document, "div", "errorwrap");
	if(psCheckArrayExist(arrTemp)==false)
	{
		return false;
	}	
	if(psGetInnerText(arrTemp[0]).toLowerCase().indexOf("the error returned was")>=0)
	{		
		psRegisterListener_SignIn_BoardMessage();
		psCreatePageviewTag("Board Message", "forums");		
		return true;
	}
	
	return false;
}

function psRegisterListener_Search()
{
	var temp=psGetElementByName(document, "input", "search", "image");
	if(psCheckElementExist(temp)==false)
	{
		return;
	}
	
	var oldFunc=temp.onclick;
	temp.onclick=function()
	{
		psSaveSearchQuery2Ck();
		
		if(psCheckElementExist(oldFunc))
		{
			return oldFunc();
		}
	}
}

function psSaveSearchQuery2Ck()
{
	var temp=document.getElementById("search_text");
	if(psCheckElementExist(temp)==false)
	{
		return;
	}
	temp=psHtmlDecode(temp.value);		
	psSetValueToCookie(G_PS_CK_ALL, G_PS_CK_SQUERY, temp);	
}

function psRegisterListener_SignIn_Forum()
{	
	if(psGetPathName().indexOf("forums/index.php")<0)
	{
		return;
	}
	
	var temp=psGetAct();
	if(psCheckElementExist(temp)==false)
	{
		return;
	}
	
	if(temp.toLowerCase()!="login")
	{
		return;
	}
	
	temp=psGetElementByName(document, "input", "submit", "submit");
	if(psCheckElementExist(temp)==false)
	{
		return;
	}	
	var oldFunc=temp.onclick;
	temp.onclick=function()
	{
		psSaveCustID2Ck_Forum();
		if(psCheckElementExist(oldFunc)==true)
		{
			return oldFunc();
		}
	}	
}

function psSaveCustID2Ck_Forum()
{	
	var temp=psGetElementByName(document, "input", "username", "text");
	
	if(psCheckElementExist(temp)==false)
	{
		return;
	}	
	temp=temp.value;	
	psCreateRegistrationTag(temp);
	//psSetValueToCookie(G_PS_CK_ALL, G_PS_FLAG, "true");	
}

function psIsMyProfilePage()
{	
	var arrTemp=document.getElementsByTagName("a");
	if(psCheckArrayExist(arrTemp)==false)
	{
		return;
	}	
	for(var i=0;i<arrTemp.length;i++)
	{
		if(arrTemp[i].href.indexOf("airshowbuzz.com/profiles/?id=")>=0)
		{			
			var temp=arrTemp[i].getElementsByTagName("img");
			if(psCheckArrayExist(temp)==true)
			{
				temp=temp[0];
				if(temp.src.indexOf("btn_my_profile.jpg")>=0)
				{
					temp=psGetValueFromUrl(arrTemp[i].href, "id");					
					if(G_PS_URL_PATH.indexOf(temp)>=0)
					{
						return true;
					}
					
					return false;
				}
			}
		}		
	}	
	return false;
}

function psIsNotFoundPage()
{
	if(document.title.toLowerCase().indexOf("404 not found")>=0)
	{
		return true;
	}
	
	return false;
}

function psSendPageViewTag_UserCP()
{	
	var temp=document.getElementById("ucpcontent");
	if(psCheckElementExist(temp)==false)
	{
		return null;
	}
	
	var arrTemp=psGetElementsByClassName(temp, "div", "formsubtitle");
	if(psCheckArrayExist(arrTemp)==false)
	{
		return;
	}
	
	return psGetInnerText(arrTemp[0]);	
}

function psRegisterListener_SignIn_BoardMessage()
{	
	var temp=psGetElementByName(document, "input", "submit", "submit");
	if(psCheckElementExist(temp)==false)
	{
		return;
	}	
	var oldFunc=temp.onclick;
	temp.onclick=function()
	{
		psSaveCustID2Ck_Forum();
		if(psCheckElementExist(oldFunc)==true)
		{
			return oldFunc();
		}
	}
}

function psStripOffText(pText)
{
	if(pText.length>255)
	{
		pText=pText.substr(0, 255);
	}
	
	return pText;
}

function psGetPhotoVideoName()
{
	var temp=document.getElementById("title");
	if(psCheckElementExist(temp)==false)
	{
		return null;
	}
	
	temp=temp.innerHTML;
	if(psCheckElementExist(temp)==false)
	{
		return null;
	}
	temp=temp.toLowerCase();
	
	if(temp.indexOf("<br>")>=0)
	{
		var arrTemp=temp.split("<br>");
		temp=psTrim(arrTemp[0]);
	}
	return temp;
}

function psGetForumName_ShowForum()
{
	var temp=document.getElementsByTagName("title");
	if(psCheckArrayExist(temp)==false)
	{
		return null;
	}
	
	temp=temp[0].innerHTML;
	if(psCheckElementExist(temp)==false)
	{
		return null;
	}
	
	temp=psHtmlDecode(temp);
	if(temp.indexOf("->")>=0)
	{
		var arrTemp=temp.split("->");
		temp=psTrim(arrTemp[1]);
	}	
	return temp;
}

function psIsMainTitleTable(pDiv)
{
	var arrTemp=pDiv.getElementsByTagName("img");	
	if(psCheckArrayExist(arrTemp)==false)
	{
		return false;
	}
	
	for(var j=0;j<arrTemp.length;i++)
	{
		if(psCheckElementExist(arrTemp[j].src)==true && arrTemp[j].src.indexOf("/nav_m.gif")>=0)
		{
			return true;
		}
	}
	
	return false;
}

function psGetMainTitle(pDiv)
{
	var arrTemp=pDiv.getElementsByTagName("table");
	if(psCheckArrayExist(arrTemp)==false)
	{
		return null;
	}
	var temp=arrTemp[0];
	var row=temp.rows[0];
	if(psCheckElementExist(row)==false)
	{
		return null;
	}
	
	var cell=row.cells[0];	
	if(psCheckElementExist(cell)==false)
	{
		return null;
	}
	
	arrTemp=cell.getElementsByTagName("b");
	if(psCheckArrayExist(arrTemp)==false)
	{
		return null;
	}
	temp=arrTemp[0];
	temp=psGetInnerText(temp);
	
	if(psCheckElementExist(temp)==false)
	{
		return null;
	}
	temp=psTrim(temp);
	return temp;
}


function psGetForumName_ShowTopic()
{
	var arrTemp=psGetElementsByClassName(document, "div", "maintitle");
	if(psCheckArrayExist(arrTemp)==false)
	{
		return null;
	}
	for(var i=0;i<arrTemp.length;i++)
	{		
		if(arrTemp[i].id!="myass-drag" && psIsMainTitleTable(arrTemp[i])==true)
		{
			
			temp=psGetMainTitle(arrTemp[i]);
			return temp;
		}
	}
	return null;
}
