﻿
function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}


    dojo.require("dojo.fx");
    bob = new Array();
    function basicSetup(){        
        function linkIn(){
            dojo.query(".seg").style("display","none");
            var u_loc = this.id.indexOf('_');
            //alert ("u_loc == " + u_loc)
            
            var subindex = (Right(this.id, this.id.length - u_loc))
            var index = this.id.replace(/clack/, '').replace(subindex, '')
            subindex = subindex.replace(/_/, '')
            //alert ("subindex ==" + subindex)
            //alert ("index ==" + index)

            var wipeArgs = {node: dojo.byId('part' + index), duration: 700};       
            var wipeArgsA = {node: dojo.byId('part' + index)
                , duration: 700,
                beforeBegin: function() {
                    var node = dojo.byId('part' + index);
                    dojo.style(node, "opacity", 0);
                    dojo.style(node, "display", "block");
                }
                
                };
//            document.getElementById('seg_a_' + index_id).style.display = 'none';
//            document.getElementById('seg_b_' + index_id).style.display = 'none';
//            document.getElementById('seg_c_' + index_id).style.display = 'none';
           //document.getElementById('seg_c_' + index_id).style.display = 'none';
                //dojo.query(".seg").style.display = 'none';
                document.getElementById('seg_' + index + '_' + subindex).style.display = 'block';

            if (dojo.byId('part' + index).style.display == 'none'){
                dojo.fx.wipeIn(wipeArgs).play();
                
            }else{
                //var wipeArgs2 = dojo.fadeOut(wipeArgs);
                //var wipeArgs3 = dojo.fadeIn(wipeArgs);
                //var bob = dojo.fx.chain([wipeArgs2, wipeArgs3]);
                //bob.play();
                dojo.fadeIn(wipeArgsA).play();
            }
        }

        function closeIt(){
            var index = this.id.replace(/closer/, '')
            var wipeArgs = { node: dojo.byId('part' + index), duration: 700};
            dojo.fx.wipeOut(wipeArgs).play();
            
        }
        
         
/*        for (ax = 1; ax < 4; ax++){
            dojo.connect(dojo.byId("closer" + ax), "onclick", closeIt);
        }  
        for (ax = 1; ax < 4; ax++){
            dojo.connect(dojo.byId("clack" + ax + "_a"), "onclick", linkIn);
            dojo.connect(dojo.byId("clack" + ax + "_b"), "onclick", linkIn);
            dojo.connect(dojo.byId("clack" + ax + "_c"), "onclick", linkIn);
        }
*/
		dojo.query("a.text_1").onclick(linkIn);
		dojo.query("a.closer").onclick(closeIt);
		//dojo.query("div.seg").style.display = 'none';
    }
    dojo.addOnLoad(basicSetup);
    
