
	var Rinn = {

		Products: {

			lastclicked: null,
			lastshown: null,
			spaceToShow: 620,
			col_id:0,
			crn_id:0,

			/*
			 * Rinn.Products.getColors
			 */
			getColors: function(page_id, cn_id, crnid, type, firstTab, firstCnId, firstColor) {
        
        jQuery.ajax({
					url: 'index.php' + '?page_id=' + page_id + '&cn_id=' + cn_id + '&crnid=' + crnid + '&type=' + type + '&sf=1', 
					type: "GET",
					dataType: "html",
					complete: function(res, status) {
						
            $('#Crown_Layer').html(res.responseText);
            $('#colors_gross').css("display", "inline");
            Rinn.Products.bordermarkFirstColor(firstTab);
            Rinn.Products.getSf(page_id, firstCnId, cn_id, crnid, firstColor);
						positionLinkList();
						
					}
				});

			},

			/*
			 * Rinn.Products.getSf
			 */
			getSf: function(page_id, cn_id, sysid, crnid, colid) {
        
        jQuery.ajax({
					url: 'index.php' + '?page_id=' + page_id + '&cn_id=' + cn_id + '&crnid=' + crnid + '&colid=' + colid + '&sysid=' + sysid + '&sf=1', 
					type: "GET",
					dataType: "html",
					complete: function(res, status) {
						
            $('#Product_Overview').html(res.responseText);
            Rinn.Products.getStnFrmts(page_id, sysid, crnid, colid);
            Rinn.Products.col_id = colid;
            Rinn.Products.crn_id = crnid;
						positionLinkList();
						
					}
				});
				
			},


			/*
			 * Rinn.Products.getStnFrmts
			 */
			getStnFrmts: function(page_id, sysid, crnid, colid) {
        
        jQuery.ajax({
					url: 'index.php' + '?page_id=' + page_id + '&crnid=' + crnid + '&colid=' + colid + '&sysid=' + sysid + '&sfs', 
					type: "GET",
					dataType: "html",
					complete: function(res, status) {
						
            $('#Stoneformats').html(res.responseText);
						positionLinkList();
						
					}
				});
        
			},

			/*
			 * Rinn.Products.showCharacteristics
			 */
			showCharacteristics: function() {
				this.lastclicked = null;
				Rinn.Products.showhideLayer('Product_Overview');
				positionLinkList();
			},


			/*
			 * Rinn.Products.getDrws
			 */
			getDrws: function(page_id, sysid) {
        
        jQuery.ajax({
					url: 'index.php' + '?page_id=' + page_id + '&sysid=' + sysid + '&drw', 
					type: "GET",
					dataType: "html",
					complete: function(res, status) {
						
            $('#Drawings').html(res.responseText);
  					Rinn.Products.showhideLayer('Drawings');
						positionLinkList();
						
					}
				});
				
			},

			/*
			 * Rinn.Products.getGal
			 */
			getGal: function(page_id, sysid) {
        
         jQuery.ajax({
					url: 'index.php' + '?page_id=' + page_id + '&sysid=' + sysid + '&gal', 
					type: "GET",
					dataType: "html",
					complete: function(res, status) {
						
            $('#Gallery').html(res.responseText);
						Rinn.Products.showhideLayer('Gallery');
						Rinn.Products.makeScrollTimeOut('Gallery_Table','galBtnRight');
						positionLinkList();
						
					}
				});
				
			},


			/*
			 * Rinn.Products.getPtns
			 */
			getPtns: function(page_id, sysid) {
        
        jQuery.ajax({
					url: 'index.php' + '?page_id=' + page_id + '&sysid=' + sysid + '&ptn',  
					type: "GET",
					dataType: "html",
					complete: function(res, status) {
						
            $('#Patterns').html(res.responseText);
						Rinn.Products.showhideLayer('Patterns');
						Rinn.Products.makeScrollTimeOut('Pattern_Table','ptnsBtnRight');
						positionLinkList();
						
					}
				});
				
			},


			/*
			 * Rinn.Products.getSpecs
			 */
			getSpecs: function(page_id, sysid) {
        
        jQuery.ajax({
					url: 'index.php' + '?page_id=' + page_id + '&sysid=' + sysid + '&spc',
					type: "GET",
					dataType: "html",
					complete: function(res, status) {
						
            $('#Specs').html(res.responseText);
  					Rinn.Products.showhideLayer('Specs');
						positionLinkList();
						
					}
				});
        
			},


			/*
			 * Rinn.Products.getAttrs
			 */
			getAttrs: function(page_id, sysid) {
        
        jQuery.ajax({
					url: 'index.php' + '?page_id=' + page_id + '&sysid=' + sysid + '&att',
					type: "GET",
					dataType: "html",
					complete: function(res, status) {
						
            $('#Attribs').html(res.responseText);
  					Rinn.Products.showhideLayer('Attribs');
						positionLinkList();
						
					}
				});
       
			},


			/*
			 * Rinn.Products.getDld
			 */
			getDld: function(page_id, sysid, fldid) {
        
        jQuery.ajax({
					url: 'index.php' + '?page_id=' + page_id + '&sysid=' + sysid +	'&fldid=' + fldid + '&dl_check',
					type: "GET",
					dataType: "html",
					complete: function(res, status) {
						
            if(res.responseText == 1) {

              document.location.href =
                'index.php' +
                '?page_id=' + page_id +
                '&sysid=' + sysid +
                '&fldid=' + fldid +
                '&dl';

            } else {

              Rinn.Products.getNoDl(page_id, sysid);

            }
						
					}
				});        
				
			},

			/*
			 * Rinn.Products.getNoDl
			 */
			getNoDl: function(page_id, sysid) {
        
        jQuery.ajax({
					url: 'index.php' + '?page_id=' + page_id + '&sysid=' + sysid +	'&nodl',
					type: "GET",
					dataType: "html",
					complete: function(res, status) {
						
            $('#Download').html(res.responseText);
  					Rinn.Products.showhideLayer('Download');
						Rinn.Products.lastshown = 'Download';
						positionLinkList();
						
					}
				});        
        
			},


	  	/*
			 * Rinn.Products.bordermark
			 */
			 bordermark: function(thmb_id) {
				if(thmb_id == "")
					return;

				if(this.lastclicked != null)
					$("#" + this.lastclicked).css("background-color", '#FFFFFF');

				$("#" + thmb_id).css("background-color", '#E68C1F');
				this.lastclicked = thmb_id;
      },

			/*
			 * Rinn.Products.bordermarkFirstColor
			 */
			 bordermarkFirstColor: function(thmb_id) {
				if(!$("#" + thmb_id)) {
					setTimeout("Rinn.Products.bordermarkFirstColor('" + thmb_id + "');", 100);
					return;
				}
				Rinn.Products.bordermarkFirstColor_Do(thmb_id);

      },

			/*
			 * Rinn.Products.bordermarkFirstColor_Do
			 */
			 bordermarkFirstColor_Do: function(thmb_id) {

				$("#" + thmb_id).css("background-color", '#E68C1F');
				this.lastclicked = thmb_id;
      },


			/*
			 * Rinn.Products.showhideLayer
			 */
			showhideLayer: function(layerID) {
				if(this.lastshown) {
    			$("#" + this.lastshown).css("display", "none");
					$("#" + this.lastshown + "_td").css("background-color", '#FBF7EB');
					$("#" + this.lastshown + "_td").css("padding", '1px 0px 4px 4px');
					$("#" + this.lastshown + "_lnk").css("color", '#0C889E');
    		}
				if($(layerID + "_td") != null){
	    		$("#" + layerID).css("display", "inline");
					$("#" + layerID + "_td").css("background-color", '#6B919F');
					$("#" + layerID + "_td").css("padding", '14px 0px 5px 6px');
					$("#" + layerID + "_lnk").css("color", '#FFFFFF');
					this.lastshown = layerID;
				}

				//adjust gallery_pic_navigation_buttons

				if(document.getElementById('Gallery_td')) {
					o = document.getElementById('Gallery_td');

					var r = { top:0, left:0 };
					if(!o) return r;
					else if(typeof o == 'string' ) o = document.getElementById(o);
					if( typeof o != 'object' ) return r;
					if(typeof o.offsetTop != 'undefined') {
							 r.left = r.top = 0;
							 while (o && o.tagName != 'BODY')
							 {
                  r.top  += parseInt( o.offsetTop );
                  r.left += parseInt( o.offsetLeft );
                  o = o.offsetParent;
							 }
					}

					if(document.getElementById('galBtnRight'))
						document.getElementById('galBtnRight').style.top = r.top+200;
				}
				if(document.getElementById('galBtnLeft')){
					document.getElementById('galBtnLeft').style.top = r.top+200;
				}

    	},


			hideLayer: function(layerID) {
    		$("#" + layerID).css("display", "none");
    	},



			/*
       * Rinn.Products.showOnStartup
       */
			showOnStartup: function(){
				$('#start_grossproj_trenner').css("display", "block");
				$('#start_grossproj_farben').css("display", "block");
				$('#Product_Overview_td').css("display", "block");
			},


      /*
       * Rinn.Products.makeScrollTimeOut
       */
			spaceToScroll: 0,
			tableID:null,
			btnID:null,
  		makeScrollTimeOut: function(tableID, btnID) {

				Rinn.Products.tableID = tableID;
				Rinn.Products.btnID = btnID;
				
  		},

      /*
       * Rinn.Products.makeScroll
       */
  		makeScroll: function() {
				
        if(!document.getElementById(Rinn.Products.tableID))
					return;
  			spaceToScroll = document.getElementById(Rinn.Products.tableID).offsetWidth;

    		if (spaceToScroll > this.spaceToShow)
    			$("#" + Rinn.Products.btnID).css("visibility", "visible");

				return spaceToScroll;
  		},


			/*
			 * Rinn.Products.showhideBtnRight
			 */
  		showhideBtnRight: function(layerID, tableID, btnRightID, btnLeftID, scrollStep) {
				
        spaceToScroll = document.getElementById(tableID).offsetWidth;
				
				$("#" + layerID).css("margin-left", (parseInt(document.getElementById(layerID).style.marginLeft) - scrollStep) + "px");

				if(parseInt(document.getElementById(layerID).style.marginLeft)-620 <= -1*spaceToScroll) {
    			$("#" + btnRightID).css("display", "none");
    		} else {
    			$("#" + btnRightID).css("display", "inline");
  				$("#" + btnRightID).css("visibility", "visible");
				}
				
				if(parseInt(document.getElementById(layerID).style.marginLeft) < 0) {
  				$("#" + btnLeftID).css("display", "inline");
  				$("#" + btnLeftID).css("visibility", "visible");
				}
			},


			/*
			 * Rinn.Products.showhideBtnLeft
			 */
  		showhideBtnLeft: function(layerID, tableID, btnRightID, btnLeftID, scrollStep) {

				spaceToScroll = document.getElementById(tableID).offsetWidth;

  			$("#" + layerID).css("margin-left", (parseInt(document.getElementById(layerID).style.marginLeft) + scrollStep) + "px");
  			if(parseInt($("#" + layerID).css("margin-left")) >= 0) {
  				$("#" + btnLeftID).css("display", "none");
  			} else {
  				$("#" + btnLeftID).css("display", "inline"); 
  				$("#" + btnLeftID).css("visibility", "visible");
				}
				
				
				if(parseInt($("#" + layerID).css("margin-left"))-620 > -1*spaceToScroll) {
  				$("#" + btnRightID).css("display", "inline");
  				$("#" + btnRightID).css("visibility", "visible");
				}
				
			},

  		/*
			 * Rinn.Products.linkToPrint
			 */
  		linkToPrint: function(PAGE_ID, CN_ID) {
				window.open('index.php?page_id=' + PAGE_ID + '&cn_id=' + CN_ID + '&crn_id=' + Rinn.Products.crn_id + "&sys_id=" +CN_ID
					+ '&col_id=' + Rinn.Products.col_id + '&print','RINNPRINT','');
			},

			/*
			 * Rinn.Products.linkToPdf
			 */
  		linkToPdf: function(PAGE_ID, CN_ID) {
				window.open('index.php?page_id=' + PAGE_ID + '&cn_id=' + CN_ID + '&crn_id=' + Rinn.Products.crn_id
					+ '&col_id=' + Rinn.Products.col_id + '&pdf','RINNPDF','');
			},
      
      /*
       * Rinn.animateBorder
       */
      animateBorder: function (elementID, colorcode){
        if(colorcode){          
          $("#"+elementID).animate({
            borderTopColor: "#"+ colorcode, 
            borderBottomColor: "#"+ colorcode,
            borderLeftColor: "#"+ colorcode,
            borderRightColor: "#"+ colorcode
         }, '500');
        } else {
          document.getElementById(elementID).className = "normal";
        }
      },
      
      /*
       * Rinn.showDetailsTip
       */
      showDetailsTip: function(id) {
        Rinn.Products.animateBorder("pointerImg"+id, "ec8e1d");
        $("#ToolTip"+id).show('slide','',500);
      },

      /*
       * Rinn.closeDetailsTip
       */
      closeDetailsTip: function(id) {
        Rinn.Products.animateBorder("pointerImg"+id, "ffffff");
        $("#ToolTip"+id).fadeOut("slow");
      }
      
		}
    
	}

  function showPortalLayer(layerId){
    document.getElementById(layerId).style.backgroundColor='#3d6d81';
    document.getElementById(layerId).style.zIndex=5;
    document.getElementById('layer_' + layerId).style.zIndex=6;
    document.getElementById('layer_' + layerId).style.display="inline";
    document.getElementById(layerId).style.cursor="hand";
    document.getElementById('layer_' + layerId).style.cursor="hand";
  }

  function hidePortalLayer(layerId){
    document.getElementById(layerId).style.backgroundColor='#c8d0d8';
    document.getElementById(layerId).style.zIndex=1;
    document.getElementById('layer_' + layerId).style.zIndex=1;
    document.getElementById('layer_' + layerId).style.display="none";
    document.getElementById('layer_' + layerId).style.cursor="auto";
    document.getElementById('layer_' + layerId).style.cursor="auto";
  }

	function positionLinkList() {
		var position = $('div#link_list').position();
		var margin = position.top%68;
		var offset = 68-margin+4+204;
		$('div#link_list').css('margin-top', offset+'px');
	}
	
  setInterval("Rinn.Products.makeScroll()", 100);
	
	// Link-Liste am Raster ausrichten
	$(document).ready(function() {
		positionLinkList();
	});

