var W3CDOM = (document.createElement && document.getElementsByTagName);

//addEvent(window, 'load', initCollapsingRows);

// This is the path to the images relative to the HTML file
// Ex. If your HTML file is at /files/Index.html
//     and your JavaScript and images are in /files/collapsible/
//     then the path here would be "collapsible/" 
var pathToImages = "/statement/js/";

function addEvent(obj, eventType,fn, useCapture)
{
	if (obj.addEventListener) {
		obj.addEventListener(eventType, fn, useCapture);
		return true;
	} else {
		if (obj.attachEvent) {
			var r = obj.attachEvent("on"+eventType, fn);
			return r;
		}
	}
}

// this function is needed to work around 
// a bug in IE related to element attributes
function hasClass(obj) {
   var result = false;
   if (obj.getAttributeNode("class") != null) {
       result = obj.getAttributeNode("class").value;
   }
   return result;
}  

function toggleVisibilityWithIcon(row,image,className ) {


    var theImage = document.getElementById(image);
    var theRowName = row;
    var theRow = document.getElementById(theRowName);
    //
		if(className != 'null'){
		//if there is a class of vendor_=$vendorCounter
		 	var tableRows = document.getElementsByTagName('tr');
		  // and iterate through them...
    	for (var k = 0; k < tableRows.length; k++) {
        
        // if the table has a class
        if (hasClass(tableRows[k])) {
					
					// if that class is the  vendor
            if (tableRows[k].getAttributeNode('class').value.indexOf(className)!=-1) {
		       			   theRow = tableRows[k];
			     if (theRow.style.display =="none") {
        theRow.style.display = "";
        theImage.src = pathToImages + "Collapse.gif";
    } else {
        theRow.style.display = "none";
        theImage.src = pathToImages + "Expand.gif";
    } 	   		
					}
				
				
			}
		}
		}
		else{
    if (theRow.style.display =="none") {
        theRow.style.display = "";
        theImage.src = pathToImages + "Collapse.gif";
    } else {
        theRow.style.display = "none";
        theImage.src = pathToImages + "Expand.gif";
    }
		}
}


$(document).ready(function(){
	$('#expandAllLink').click(function(){
		$("tr[class^='vendor_row_']").show();										
	});
});

function toggleVisibility(row,image,className ) {
	if($( '.' + className).is(':hidden') ){
		//$('.' +	className).hide();
		$('.' +	className).show();
	}else{	
		$('.' + className).hide();
	}

  }



