﻿//<!--
//YUI({combine: true, timeout: 10000}).use("node", "anim", "event-simulate", function(Y) {
//	var nodes = Y.all(".main");
//	var nodeStates = new Array();
//	
//	var onClick = function(e) {			
//		if(Y.get('#'+e.target.get('id')+'_subs')) {
//			var content = Y.get('#'+e.target.get('id')+'_subs').plug(Y.Plugin.NodeFX, {
//				from: { height: 1 },
//				to: {
//					height: function(node) { // dynamic in case of change
//						return node.get('scrollHeight'); // get expanded height (offsetHeight may be zero)
//					}
//				},
//		
//				easing: Y.Easing.easeOut,
//				duration: 0.5
//			});
//			Y.get('#'+e.target.get('id')).toggleClass('main_inactive');
//			
//			/*nodeStates[e.target.get('id')] = content.fx.get('reverse');
//		
//			nodes.each(function(node) {
//				if(e.target.get('id') != node.get("id") && nodeStates[node.get("id")] === true) {
//					Y.Event.simulate(document.getElementById(node.get("id")), "click");
//				}
//			});*/
//			
//			content.fx.set('reverse', !content.fx.get('reverse')); // toggle reverse 
//			content.fx.run();
//		}
//		return;
//	};

//	nodes.on('click', onClick);
//	
//	var ids = 0;
//	var firstNode;
//	nodes.each(function(node) {
//		nodeStates[node.get("id")] = true;
//		Y.Event.simulate(document.getElementById(node.get("id")), "click");
//	});
//});
//-->

function GetDetailTabId(tabId)
{
    switch(tabId)
    {
        case "cTab1":
            return "product_detail";
            break;
        
        case "cTab2":
            return "testimonial_detail";
            break;
        
        case "cTab3":
            return "galleries_detail";
            break;
        
        default:
            return "product_detail";
    }
    /*
cTab1 - product_detail
cTab2 - testimonial_detail
cTab3 - galleries_detail
*/
}
function ToggleTab(tabId)
{
    //alert("seleced before init: " + this.selectedTabId);
    if(this.selectedTabId == null) this.selectedTabId = "cTab1";
    //alert("seleced after init: " + this.selectedTabId);
    
    //if the tabId passed is already selected, don't do anything
    if(this.selectedTabId == tabId)
        return false;
        
    var detailDivId = GetDetailTabId(tabId);
    var oldDetailDivId = GetDetailTabId(this.selectedTabId);
    
    var tab = document.getElementById(tabId);
    //alert("id: " + tabId + " tab: " + tab);
    var div = document.getElementById(detailDivId);
    //alert("id: " + detailDivId + " div: " + div);
    var oldtab = document.getElementById(this.selectedTabId);
    //alert("id: " + this.selectedTabId + " oldtab: " + oldtab);
    var olddiv = document.getElementById(oldDetailDivId);
    //alert("id: " + oldDetailDivId + " olddiv: " + olddiv);

    if((tab)&&(div)&&(oldtab)&&(olddiv))
    {
        //deactivate the prior selected tab and detail div
        oldtab.className = this.selectedTabId + "Active";    //this class actually deactiviates the prior selected tab
        olddiv.className = "hide";
      
        //select the new tab and detail div
        tab.className = tabId;                          //this class selects the tab in question
        div.className = "featured";
        
        //reset the global
        this.selectedTabId = tabId;        
    }
    else
        alert("Either the tab: " + tabId + " or the div: " + detailDivId + " was not found.");
        
    
    return false;
}

function Toggle(id)
{
    var element = document.getElementById(id);
    if(element)
        (element.className == 'sub') ? element.className = 'subshow' : element.className = 'sub';
}