function collapse(div,image,imgCollapse,imgUncolapse)
{
	var oDiv;
	var oImg;
	if (oDiv = document.getElementById(div))
	{
		if (oDiv.style.display == 'none')
		{
			oDiv.style.display = '';
		}
		else
		{
			oDiv.style.display = 'none';
		}
	}

	if (oImg = document.getElementById(image))
	{
	    if (oDiv.style.display == 'none')
	    {
	        oImg.src = imgCollapse;
	    }
	    else
	    {
	        oImg.src = imgUncolapse;
	    }
	    	    
	    
	}
}

function afterSelectEvent(owner, tabItem, evnt,xx)
            {
            alert(tabItem);
            }
            
function flipBanners(owner, tabItem, evnt,xx)
{

   var key = tabItem.Key;
   var oBanners = document.getElementsByName("hddBanner");
	var oCurrent;
	var oParent;
	var oDiv;
	var oChilds;
	var sMsg = "";
	var sId = "";
	var aIds = new Array();
	
	if (oBanners && oBanners.length)
	{		
		for (var i = 0; i < oBanners.length; i++)
		{
			
			oCurrent = oBanners[i];
			
			aIds = oCurrent.id.split("_");
						
			if (key == aIds[1])
			{
							
				oDiv = document.getElementById("divBannerKey_" + aIds[1]);				
				oParent = oCurrent.parentNode;
				oParent = oParent.parentNode;
				sMsg = oParent.id;				
				for (var j = 0; j < oParent.childNodes.length;j++ )
				{
				    sId = oParent.childNodes[j].id;
				    oChilds =  oParent.childNodes[j];
				    for (var k = 0; k < oChilds.childNodes.length;k++ )
				    {
				        if (oChilds.childNodes[k].style)
				        {
				            if (oChilds.childNodes[k].style.display)
				            {
    				            
			                    if(oChilds.childNodes[k].style.display == "block")
			                    {
			                        oChilds.childNodes[k].style.display = "none";
			                    }
			                    			                    
			                }
			            }
				    }
				}				
				oDiv.style.display = "block";
			}
			
		}
	}
	
		
}

function updateFields()
{
    objtxtClient = document.getElementById("txtClient");
    objtxtProject = document.getElementById("txtProject");
    objtxtDay = document.getElementById("txtDay");
    objtxtMonth = document.getElementById("txtMonth");
    objtxtYear = document.getElementById("txtYear");
    objtxtLong = document.getElementById("txtLong");
    objddlHeight = document.getElementById("ddlHeight");
    objtxtCotWidth = document.getElementById("txtCotWidth");
    objtxtCotHeight = document.getElementById("txtCotHeight");    
    objtxtCotGates = document.getElementById("txtCotGates");
    objtxtGates = document.getElementById("txtGates");
    objtxtComments = document.getElementById("txtComments");
    objtxtCotComments = document.getElementById("txtCotComments");    
    objtxtPanelHeight = document.getElementById("txtPanelHeight");
    objtxtPanels = document.getElementById("txtPanels");
    objtxtPosts = document.getElementById("txtPosts");
    objtxtPostsHeight = document.getElementById("txtPostsHeight");
    objtxtHolders = document.getElementById("txtHolders");
    objtxtBolts = document.getElementById("txtBolts");
    
    
	spanClient.innerText = objtxtClient.value;
	spanProject.innerText = objtxtProject.value;
	spanDay.innerText = objtxtDay.value;
	spanMonth.innerText = objtxtMonth.value;
	spanYear.innerText = objtxtYear.value;
	spnHeight.innerText = objddlHeight.options[objddlHeight.selectedIndex].value;
	objtxtCotHeight.value =  objddlHeight.options[objddlHeight.selectedIndex].value;
	spnWidth.innerText = objtxtLong.value;
	objtxtCotWidth.value =  objtxtLong.value;	
	objtxtCotGates.value =  objtxtGates.value;	
	objtxtCotComments.value = objtxtComments.value;
	objtxtPanelHeight.value = objddlHeight.options[objddlHeight.selectedIndex].value;
	var iWidth = objtxtLong.value;
	if (iWidth >= 2.5)
	{
		objtxtPanels.value = Math.round(iWidth/2.5);
	}
	else
	{
		objtxtPanels.value = 1;
	}
	var iPosts = 0;
	iPosts = (objtxtPanels.value * 1) + (objtxtCotGates.value * 1) + 1;
	objtxtPosts.value = iPosts;
	var iHeight = objtxtPanelHeight.value * 1;
	switch(iHeight)
	{	
	case 0.63:
		objtxtPostsHeight.value = "1.00";
		objtxtHolders.value = iPosts * 2;
		break;
	case 1:
		objtxtPostsHeight.value = "1.50";
		objtxtHolders.value = iPosts * 2;
		break;
	case 1.5:
		objtxtPostsHeight.value = "2.00";
		objtxtHolders.value = iPosts * 3;
		break;
	case 2:
		objtxtPostsHeight.value = "2.50";
		objtxtHolders.value = iPosts * 4;
		break;
	case 2.5:
		objtxtPostsHeight.value = "3.10";
		objtxtHolders.value = iPosts * 5;
		break;
	}
	objtxtBolts.value = objtxtHolders.value * 2;
}

function showCotizador()
{
    objDiv = document.getElementById("divCotizador");
    objDiv.style.display = '';
    objDiv.style.width = '600px';        
    objDiv.style.top = Math.round((document.documentElement.clientHeight/2)-(objDiv.clientHeight/2)+document.documentElement.scrollTop)+'px';    
    objDiv.style.left = Math.round((document.documentElement.clientWidth/2)-(objDiv.clientWidth/2))+"px";
    
    
    grayOut(true);        

    document.body.appendChild(objDiv);
    

    objDiv.style.position = 'absolute';
    objDiv.style.zIndex = 100;          
}

function printCot()
{
    //objFrame = document.frames["iframeCotPrint"];
    var objFrame = window.open("/about_blank.htm","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=480, height=450");    
    objDiv = document.getElementById('divCotizador');
    objBtnClose = document.getElementById('btnPrintCot');
    objBtnPrint = document.getElementById('btnCloseCot');       
    objBtnClose.style.display = 'none';
    objBtnPrint.style.display = 'none';
    objFrame.document.open();
    objFrame.document.write("<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"/App_Themes/cms/StyleSheet.css\" /></head><body><div id=\"divCotizador\" class=\"CotResult2\">" + objDiv.innerHTML + "</div></body></html>");
    objFrame.document.close();
    closeCotizador();

    objFrame.focus();
    objFrame.print();

    objBtnClose.style.display = '';
    objBtnPrint.style.display = '';

    //objFrame.focus();
    //objFrame.print();
    //objFrame.document.body.innerHTML = objDiv.innerHTML;
}

function closeCotizador()
{
    objDiv = document.getElementById('divCotizador');
    objDiv.style.display = 'none';
    grayOut(false);
}

function writeMoviePlayer(sTitulo,sFlv)
{
	var sObjectFlash;
	var oDiv = document.getElementById("divMoviePlayer");
	sObjectFlash = '<object id="fla_MoviePlayer" type="application/x-shockwave-flash" data="/Content/Banners/VideoPlayer.swf"  height="307" width="391" > \
					<param name="Movie" value="/Content/Banners/VideoPlayer.swf"> \
					<param name="Src" value="/Content/Banners/VideoPlayer.swf"> \
					<param name="Menu" value="0"> \
					<param name="FlashVars" value="vFLV=' + sFlv + '&vTitulo=' + sTitulo + '"> \
					<param name="WMode" value="Transparent"> \
					</object>'    
	oDiv.innerHTML = sObjectFlash;
}


function goToProduct(idProduct,idSubproduct)
{
    var sQueryString = "/Default.aspx?Id=16";
    if(idProduct)
    {
        if(idSubproduct)
        {
            sQueryString += "&ProductId=" + idProduct + "&SubProductId=" + idSubproduct + "#anchor_subprod_" + idSubproduct;
        }
        else
        {
            sQueryString += "&ProductId=" + idProduct;
        }
    }
    document.location.href = sQueryString;
}