function GetContents(index)
{
    var processName = "";
    if (index == "0")
        processName = "home";
    else if (index == "1")
        processName = "about";
    else if (index == "2")
        processName = "downloads";
    else
        processName = "contact";
    
    var ajx=new myAjax();
	ajx.requestText("ProcessReq.aspx?process=" + processName,"PopulateList('dvAjaxContainer',content,\"" + index + "\")","ajaxLoading");
}

function PopulateList(dv,content,index)
{   
    if (index == "0")
        document.getElementById("dvSlides").style.display = "block";
    else
        document.getElementById("dvSlides").style.display = "none";
        
	document.getElementById(dv).innerHTML = content;
}

function GetSubContents(subID)
{
    var ajx=new myAjax();
	ajx.requestText("ProcessReq.aspx?process=getsubmenudesc&subid="+subID,"PopulateList('dvAjaxContainer',content,-1)","ajaxLoading");
}

function GetTopProducts(topProductID)
{
    var ajx=new myAjax();
	ajx.requestText("ProcessReq.aspx?process=gettopproductdesc&topproductid="+topProductID,"PopulateList('dvAjaxContainer',content,-1)","ajaxLoading");
}

function GetText(x)
{
    var ajx=new myAjax();
	ajx.requestText("ProcessReq.aspx?process=gettext&textcontent="+x,"PopulateList('dvAjaxContainer',content,-1)","ajaxLoading");
}


function SaveNewQuery()
{
    var qrys = "";
    var newsLetter = document.getElementById("chkNewsLetter");
    if (newsLetter.checked)
        qrys = formUtilExt("QRY_") + "\u0096" + "1"; 
    else
        qrys = formUtilExt("QRY_") + "\u0096" + "0";
        
    var ajx=new myAjax();
	ajx.requestText("ProcessReq.aspx?process=saveqry&qrys="+qrys,"ShowAfterSaveQry(content)","ajaxLoading");
}

function ShowAfterSaveQry(content)
{
    document.getElementById("qryErrMsg").innerHTML = content;
}

function formUtilExt(inputID)
{
    var infos = "";
    var ctrlVal = "";
    for(i=0;i<document.forms[0].length;i++)
    {
        if(document.forms[0][i].id.lastIndexOf(inputID)!=-1)
        {            
            if (document.forms[0][i].type=="text" || document.forms[0][i].type=="select-one" || document.forms[0][i].type=="textarea")
            {         
                ctrlVal = Trim(document.forms[0][i].value);
                /*if (ctrlVal=="")
                    ctrlVal = "NA";*/

                if (infos == "")
                {
                    infos = ctrlVal;
                }
                else
                {
                    infos = infos + "\u0096" + ctrlVal;
                }
            }
        }
    }
    return infos;
}

//Trim Functions
// Removes leading whitespaces
function LTrim( value ) {

    var re = /\s*((\S+\s*)*)/;
    return value.replace(re, "$1");

}

// Removes ending whitespaces
function RTrim( value ) {

    var re = /((\s*\S+)*)\s*/;
    return value.replace(re, "$1");

}

// Removes leading and ending whitespaces
function Trim( value ) {

    return LTrim(RTrim(value));
}