function selectTabCookie(oneWay,retobj)
{
    if(oneWay !="true")
    {
        var x = readCookie('selTab')
        if(x)
        {
            //alert(x);
            if(x=="return")
            {
                addClass(document.getElementById(retobj), "selected");
                removeClass(document.getElementById("out_tab"), "selected");
               hide_show('ret','out',oneWay); 
            }
            else
            {
                removeClass(document.getElementById(retobj), "selected");
                addClass(document.getElementById("out_tab"), "selected");
                hide_show('out','ret',oneWay);
            }
        }
        else
        {
            hide_show('out','ret',oneWay);
        }
    }
}

function selectOutward(oneWay, retobj)
{
    if(oneWay !=true)
    {
        removeClass(document.getElementById(retobj), "selected");
        addClass(document.getElementById("out_tab"), "selected");
        hide_show('out','ret',oneWay);
        createCookie('selTab','outward',1)
    }
   // Connect.setSelectedFlightTab("Outward", SucceededCallback);
}
function selectReturn(retobj, oneWay)
{
    if(oneWay !=true)
    {
        addClass(document.getElementById(retobj), "selected");
        removeClass(document.getElementById("out_tab"), "selected");
        hide_show('ret','out',oneWay);
        
        createCookie('selTab','return',1)
    }
    //Connect.setSelectedFlightTab("Return", SucceededCallback);
}
function SucceededCallback(result)
    {
        var res = result;
       //alert('SucceededCallback' + result);
    }
function hide_show(showing,hiding,oneWay)
{

    //alert(showing);
    //alert("checking "+document.getElementById(showing+"_tab").tagName);
    if(oneWay !=true)
    {
        //alert(oneWay + ' should not be true');
        addClass(document.getElementById(hiding+"_results"), "fullnoshow");
        removeClass(document.getElementById(showing+"_results"), "fullnoshow");

//        addClass(document.getElementById(showing+"_tab"), "selected");
//        removeClass(document.getElementById(hiding+"_tab"), "selected");

        addClass(document.getElementById(hiding+"Sortby"), "fullnoshow");
        removeClass(document.getElementById(showing+"Sortby"), "fullnoshow");

        addClass(document.getElementById(hiding+"Paging"), "fullnoshow");
        removeClass(document.getElementById(showing+"Paging"), "fullnoshow");
    }
}

function addClass(element,value)
{
//alert("running "+element.tagName+" amd "+value);
//alert("className "+element.className);
    if(element !=null)
    {
	    if(!element.className)
	    {
	    element.className = value;
	    }
	    else
	    {
	    newClassName = element.className;
	    //alert(element.className);
	    newClassName+=" ";
	    newClassName+= value;
	    element.className = newClassName;
	    }
	}
}

function removeClass(element,value)
{
    if(element !=null)
    {
	    var arrList = element.className.split(' ');

	    for ( var i = 0; i < arrList.length; i++ )
         {

             // if class found
          if ( arrList[i] == value )
          {
                // remove array item
           arrList.splice(i, 1);
                // decrement loop counter as we have adjusted the array's contents
           i--;

          }
	      element.className = arrList.join(' ');

	    }
     }
}