var pressId="";
var pressNum=1;
function goToPage(id,pageName)
{
    var divs=document.getElementsByTagName("DIV");
    for(var i=0; i < divs.length; i++)//all Divs
	{
	    if (divs[i].getAttribute('id').indexOf("Sub") == -1)
        {
           
            divs[i].className ="transGalOFF";
            divs[i].onmouseout = function(){ this.className="transGalOFF";}
        }
        else
        {
            divs[i].className ="transGalSubOFF";
            divs[i].onmouseout = function(){this.className="transGalSubOFF";}
        }
	}
	if (id.indexOf("Sub") == -1)//selected Div
    {
        document.getElementById(id).className ="transGalSel";
        document.getElementById(id).onmouseout= function(){this.className="transGalSel";}
    }
    else
    {
        document.getElementById(id).className ="transGalSel";
        document.getElementById(id).onmouseout= function(){this.className="transGalSel";}
    }
    
    var tables=document.getElementsByTagName("TABLE");
	var element;
	var str="";
	if(id.indexOf("Sub") == -1)
	{
	    for(var i=0; i < tables.length; i++)
	    {
            if (tables[i].getAttribute('id').indexOf("Table") != -1) 
            {   
          	    tables[i].style.display='none';
          	    str= tables[i].getAttribute('id').replace("Table","Span");
                element=document.getElementById(str);
                element.innerText=element.innerText.replace('-','+'); 
            }
	    }
	    if(pressId != id)
        {
            str="Table_"+id;
            document.getElementById(str).style.display='';
            str="Span_"+id;
            element=document.getElementById(str);
            element.innerText=element.innerText.replace('+','-'); 
            pressNum=2;
        }
        else if(pressNum%2==0)
        {
            str="Table_"+id;
            document.getElementById(str).style.display='none';
            str="Span_"+id;
            element=document.getElementById(str);
            element.innerText=element.innerText.replace('-','+'); 
            pressNum=pressNum+1;
        }
        else if(pressNum%2!=0)
        {
            str="Table_"+id;
            document.getElementById(str).style.display='';
            str="Span_"+id;
            element=document.getElementById(str);
            element.innerText=element.innerText.replace('+','-'); 
            pressNum=pressNum+1;
        }
  
	}
    pressId=id; 
    openPage(pageName);
}
function goToPage1(id,pageName)
{
    var divs=document.getElementsByTagName("div");
    if(browser_selector()=="ie")
    {
        for(var i=0; i < divs.length; i++)//all Divs
	    { 
	        if (divs[i].getAttribute('id').indexOf("Div_Top") != -1)
            {
                divs[i].className ="transOFF";
                divs[i].onmouseout = function(){ this.className="transOFF";}
            }
        }
        if(id!="map")
        {
            document.getElementById(id).className ="selected";
            document.getElementById(id).onmouseout= function(){this.className="selected";}
        }
    } 
    else if(browser_selector()=="gecko")
    {
       for(var i=0; i < divs.length; i++)//all Divs
	    { 
	        if (divs[i].id.indexOf("Div_Top") != -1)
            {
                divs[i].className ="transOFF";
                divs[i].onmouseout = function(){ this.className="transOFF";}
            }
        }
        if(id!="map")
        {
            document.getElementById(id).className ="selected";
            document.getElementById(id).onmouseout= function(){this.className="selected";}   
        } 
    }
   // closeAllLeftCategory();
    openPage(pageName);
}
function openPage(pageName)
{
    if(pageName!="")
    {
        var elem=parent.document.getElementById("ifmMain");
        elem.src=pageName;
    }
}
function openLeftPage(pageName)
{
//    var num=0;
//    var tds=document.getElementsByTagName("td");
//    for(var i=0; i < tds.length; i++)//all Divs
//    { 
//        if (tds[i].getAttribute('id').indexOf("PRODUCT_") != -1)
//        {
//            if(num%2==0)
//            {
//                tds[i].className ="offSubCategory0";
//                tds[i].onmouseout = function(){ this.className="offSubCategory0";}
//            }
//            else
//            {
//                tds[i].className ="offSubCategory1";
//                tds[i].onmouseout = function(){ this.className="offSubCategory1";}
//            }
//            num=num+1;
//        }
//    }
//  
//    document.getElementById(ProductId).className ="selectSubCategory";
//    document.getElementById(ProductId).onmouseout= function(){this.className="selectSubCategory";}  
    
    if(pageName!="")
    {
        var elem=parent.document.getElementById("ifmMain");
        elem.src=pageName;
    }
    //closeAllTopCategory();
}

function openLeftPage1(ProductId,CategoryId,pageName)
{
    var iframe = parent.window.frames[0].document;
    var num=0;
    var tds=iframe.getElementsByTagName("td");;
    for(var i=0; i < tds.length; i++)//all Divs
    { 
        if (tds[i].getAttribute('id').indexOf("CATEGORY_") != -1)
        {
            tds[i].className ="offCategory";
            //tds[i].onmouseout = function(){ this.className="offCategory";}
            //tds[i].onmouseover = function(){ this.className="onCategory";}
        }
        if (tds[i].getAttribute('id').indexOf("PRODUCT_") != -1)
        {
            if(num%2==0)
            {
                tds[i].className ="offSubCategory0";
                //tds[i].onmouseout = function(){ this.className="offSubCategory0";}
                //tds[i].onmouseover = function(){ this.className="onSubCategory0";}
            }
            else
            {
                tds[i].className ="offSubCategory1";
                tds[i].onmouseout = function(){ this.className="offSubCategory1";}
                //tds[i].onmouseover = function(){ this.className="onSubCategory1";}
            }
            num=num+1;
        }
    }
    
    var TdId="CATEGORY_"+CategoryId;
    iframe.getElementById(TdId).className ="selectCategory";
    iframe.getElementById(TdId).onmouseout= function(){this.className="selectCategory";}  
    
    iframe.getElementById(ProductId).className ="selectSubCategory";
    iframe.getElementById(ProductId).onmouseout= function(){this.className="selectSubCategory";}
   

    var tables=iframe.getElementsByTagName("TABLE");
	
	   for(var i=0; i < tables.length; i++)
	    {
           if (tables[i].getAttribute('id').indexOf("PRODUCTS_") != -1) 
           {   
         	    tables[i].style.display='none';
           }
        }
         	 
	 TdId="PRODUCTS_"+CategoryId;
	 iframe.getElementById(TdId).style.display='';

    if(pageName!="")
    {
        var elem=parent.document.getElementById("ifmMain");
        elem.src=pageName;
    }
    closeAllTopCategory();
}


function browser_selector() 
{
	var ua = navigator.userAgent.toLowerCase();
	var bro = "";
	if(ua.indexOf('msie') != -1 && !(ua.indexOf('opera') != -1) && (ua.indexOf('webtv') == -1) ) 
	    bro='ie';
	else if(ua.indexOf('gecko/') != -1) 
	    bro='gecko';
	else if(ua.indexOf('opera') != -1) 
	    bro='opera';
	else if(ua.indexOf('konqueror') != -1) 
	    bro='konqueror';
	else if(ua.indexOf('applewebkit/') != - 1) 
	    bro='safari';
	return bro;
}
function openCategory(CategoryId)
{
    var divs=document.getElementsByTagName("td");
    for(var i=0; i < divs.length; i++)//all Divs
    { 
        if (divs[i].id.indexOf("CATEGORY_") != -1)
        {
            divs[i].className ="offCategory";
            divs[i].onmouseout = function(){ this.className="offCategory";}
        }
    }
    var TdId="CATEGORY_"+CategoryId;
    document.getElementById(TdId).className ="selectCategory";
    document.getElementById(TdId).onmouseout= function(){this.className="selectCategory";}  
 
//    var tables=document.getElementsByTagName("TABLE");
//	
//	   for(var i=0; i < tables.length; i++)
//	    {
//           if (tables[i].getAttribute('id').indexOf("PRODUCTS_") != -1) 
//           {   
//         	    tables[i].style.display='none';
//           }
//        }
//         	 
//	 TdId="PRODUCTS_"+CategoryId;
//	 document.getElementById(TdId).style.display='';
	 
	 
	var iframe = parent.document.getElementById("ifmMain");
	iframe.src = "selectedCategory.asp?CategoryId="+CategoryId;
//	closeAllTopCategory();
}

function closeAllTopCategory()
{
    var divs=parent.document.getElementsByTagName("div");
    if(browser_selector()=="ie")
    {
        for(var i=0; i < divs.length; i++)//all Divs
	    { 
	        if (divs[i].getAttribute('id').indexOf("Div_Top") != -1)
            {
                divs[i].className ="transOFF";
                //divs[i].onmouseout = function(){ this.className="transOFF";}
                //divs[i].onmouseover = function(){ this.className="transON";}
            }
        }
    } 
 }
function closeAllLeftCategory()
{
    var iframe = window.frames[0].document;
    var tds=iframe.getElementsByTagName("td");
   
    for(var i=0; i < tds.length; i++)//all Divs
    { 
        
        if (tds[i].id.indexOf("CATEGORY_") != -1)
        {
            tds[i].className ="offCategory";
            tds[i].onmouseout = function(){ this.className="offCategory";}
        }
    }
   
    var tables=iframe.getElementsByTagName("TABLE");
    for(var i=0; i < tables.length; i++)
    {
        if (tables[i].getAttribute('id').indexOf("PRODUCTS_") != -1) 
        {   
            tables[i].style.display='none';
        }
    }

 }
