﻿function toggleTable(id,expd) {
         var target = 'table_div' + id;
		 var imgTarget = 'expImg' + id;
		 var contsTarget = 'table_div' + id + 'conts';
		
		 thisObj = document.getElementById(target);
		 imgObj = document.getElementById(imgTarget);
		 contObj = document.getElementById(contsTarget);

		 if (!expd) {
		 	var expd = (thisObj.innerHTML == '') ? 'expand' : 'colapse';
		
		 }
		 		 		 
		 if (expd == 'expand') {
		 	show(id, thisObj, contObj);
			imgObj.src = '/images/bullets/arrow-toggle-colapse.gif';
			imgObj.alt = 'Colapse';
		 } else {
		 	hide(thisObj);
			imgObj.src = '/images/bullets/arrow-toggle-expand.gif';
			imgObj.alt = 'Expand';
		 }	
	}
	
	function show(id, obj, contObj) {
		obj.innerHTML = contObj.innerHTML;
	}
	
	function hide(obj) {
		obj.innerHTML = '';
	}
	
	function showEnlarge(elem, dir) {

		var posArr = new Array;
		var oTop, oLeft;
		currElem = $(elem);
		
		if (dir == '') {
			dir = 'center';
			}
		new Effect.Grow(currElem, {direction: dir});
	}
	
	function colapse(elem, dir) {
		if (dir == '') {
			dir = 'center';
			}	
		new Effect.Shrink(elem, {direction: dir});
	}
	
	function expandAll( a, caller ) {
		
		linkStr = caller.firstChild.nodeValue;
	
		for ( i=0; i<a.length; i++ ) {
			toggleTable(a[i], (linkStr.substr(0,1) == "+") ? 'expand' : 'colapse');
		}
		
		if ( linkStr.substr(0,1) == "+" ) {
			caller.firstChild.nodeValue = "- colapse all";
		} else {
			caller.firstChild.nodeValue = "+ expand all";
		}
		window.scrollTo(0,findPosY(caller));
	}	
	
	function findPosY(obj)
	  {
		var curtop = 0;
		if(obj.offsetParent)
			while(1)
			{
			  curtop += obj.offsetTop;
			  if(!obj.offsetParent)
				break;
			  obj = obj.offsetParent;
			}
		else if(obj.y)
			curtop += obj.y;
		return curtop;
	  }	
	
	function findPos(obj) {
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft
			curtop = obj.offsetTop
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
		}
		return [curleft,curtop];
	}
	  
	function launchCall() {
		var wid = 380;
		var hei = 480;
		window.open("call.html", "callWin", "width="+ wid +",height="+ hei +",resizable=yes", true);
	}
	
	function launchDisti(partNum) {
		var sWidth;
		var popWidth = 790;
		sWidth = window.screen.width;
		if (sWidth < popWidth) {
			popWidth = 670;
			}
		window.open("http://www.futurecb.com/Store/SearchResult.aspx?PartNumber=" + partNum + "&SearchType=ByID&CategoryName=41301000000&ManufacturerName=LUMILEDS+LIGHTING", "futureWin", "width="+ popWidth +",height=570,resizable=yes,scrollbars=yes,toolbar=yes", true);
	}
	
	function launchHelp() {
		var wid = 500;
		var hei = 590
		window.open("/products/order_help.html", "helpWin", "width="+ wid +",height="+ hei +",resizable=yes", true);
	}	
	
function showImage(imgId) {
	var w = 420;
	var h = 420;
	var woptions = "directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=yes,height=" + h + "px,width=" + w + "px";
	window.open("show.cfm?imgId=" + imgId, "showWin", woptions);
}	 

function showBins() {
	var w = 420;
	var h = 420;
	var woptions = "directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=yes,height=" + h + "px,width=" + w + "px";
	window.open("binning.cfm", "binWin", woptions);
} 

function submitClick()
	{
		var SearchFor;
		SearchFor = document.frmSearch.domProductQueryName.value;
		
		if (SearchFor == "")
			alert("Please enter a keyword or a part number.");
		else
			window.location = "http://www.componentsuperstore.com/store/SearchResultByCategoryFullText.aspx?Keywords=" + SearchFor + "&SearchType=Keywords";
	 }
	
