﻿//<--
//    if (document.layers){
//        document.captureEvents(Event.MOUSEDOWN);
//        document.onmousedown=clickNS4;
//    }
//    else if (document.all&&!document.getElementById){
//        document.onmousedown=clickIE4;
//    }
//    
//    document.oncontextmenu=new Function("return false")

    function SetAllWindowsModal() { 
        var winMgr = GetRadWindowManager(); 
        var windowCollection = winMgr.GetWindowObjects(); 
        for (var i in windowCollection) 
        { 
            windowCollection[i].SetModal(true); 
        } 
    }

    //set the default statusbar message and base it on the document title
    defaultStatus = document.title;
    var anchors = document.getElementsByTagName("A"); 
    for(var i = 0; i < anchors.length; i++) { 
        if (a.href.indexOf("javascript:__doPostBack") == 0) { 
            a.onmouseover = function() { 
                status = a.innerText; 
            } 
            a.onmouseout = function() { 
                status = defaultStatus; 
            } 
        }
    }

    function CreateWindow(name,url) 
    {
        //get the radWindowManager object
        var oManager = GetRadWindowManager();
        if (oManager) 
        {
            if (oManager.GetWindowByName("Window")) 
            {
                var oWnd = oManager.GetWindowByName("Window");
                oWnd.SetTitle(name);
                oWnd.Status = false;
                oWnd.SetUrl(url);
                oWnd.SetModal(true);
                oWnd.SetSize(700, 600);
                oWnd.Show();
             }
        }
        else
        {
            //create new radWindow
            var oNew = oManager.Open(url, "Content");
            if (oNew){
                //set radWindow properties
                oNew.SetModal(true);
                oNew.SetTitle(name);
                oNew.SetSize(700, 600);
                oNew.Show();
            }
        }
    }
    
    function CreateStaticContentWindow(name,content) 
    {
        //get the radWindowManager object
        var oManager = GetRadWindowManager();
        if (oManager) 
        {
            if (oManager.GetWindowByName("Window")) 
            {
                var oWnd = oManager.GetWindowByName("Window");
                oWnd.SetTitle(name);
                oWnd.Status = false;
                oWnd.SetContent(content);
                oWnd.SetModal(true);
                oWnd.SetSize(485, 500);
                oWnd.Show();
             }
        }
        else
        {
            //create new radWindow
            var oNew = oManager.Open("Content");
            if (oNew){
                //set radWindow properties
                oNew.SetModal(true);
                oWnd.SetContent(content);
                oNew.SetTitle(name);
                oNew.SetSize(485, 500);
                oNew.Show();
            }
        }
    }


    function CreateImageWindow(name,url) 
    {
        //get the radWindowManager object
        var oManager = GetRadWindowManager();
        if (oManager) 
        {
            if (oManager.GetWindowByName("Window")) 
            {
                var oWnd = oManager.GetWindowByName("Window");
                oWnd.SetTitle(name);
                oWnd.Status = false;
                oWnd.SetUrl(url);
                oWnd.SetModal(true);
                oWnd.SetSize(700, 600);
                oWnd.Show();
             }
        }
        else
        {
            //create new radWindow
            var oNew = oManager.Open(url, "Content");
            if (oNew){
                //set radWindow properties
                oNew.SetModal(true);
                oNew.SetTitle(name);
                oNew.SetSize(700, 600);
                oNew.Show();
            }
        }
    }

    function CreateCustomWindow(name,url) 
    {
        //get the radWindowManager object
        var oManager = GetRadWindowManager();
        if (oManager) {
            //create new radWindow
            var oNew = oManager.Open(url, "Content");
            if (oNew){
                //set radWindow properties
                oNew.SetModal(true);
                oNew.SetTitle(name);
                oNew.SetSize(640,480);
            }
        }
    }

    //set the window content to nothing on close
    function OnClientClose(radWindow) {
        radWindow.SetContent("<br/>");
    }
    

    //set the radWindow status to empty
    function OnClientPageLoad(radWindow) {
        radWindow.SetStatus(" ");
    }

    //set the default statusbar message and base it on the document title
    defaultStatus = document.title;
    var anchors = document.getElementsByTagName("A"); 
    for(var i = 0; i < anchors.length; i++) { 
        if (a.href.indexOf("javascript:__doPostBack") == 0) { 
            a.onmouseover = function() { 
                status = a.innerText; 
            } 
            a.onmouseout = function() { 
                status = defaultStatus; 
            } 
        }
    }

    function clickIE4(){
        if (event.button==2){
            return false;
        }
    }

    function clickNS4(e){
        if (document.layers||document.getElementById&&!document.all){
            if (e.which==2||e.which==3){
                return false;
            }
        }
    }
    
    function loadContent( contentArea ) 
    {
        var oSubContent = document.getElementById( contentArea + "TMP");
        var oContent    = document.getElementById(contentArea);            
        
        oSubContent.parentNode.removeChild( oSubContent);
        
        oContent.innerHTML = "";
        oSubContent.style.display = "block";
        oContent.appendChild( oSubContent );
    }
    
    /* Main menu */
    function GetChannelContent(pchannel, channel, title)
    {
        window.location.href = "/Default.aspx?ch=" + channel + "&pch=" + pchannel + "&title=" + title.toLowerCase();
    }
    
    function GetChannel( channelID )
    {
        var url = "../../Redirector.aspx?ch=" + channelID;
        
        if(channelID == '2041')
        {
            window.location.href = "/3DCreation.aspx";
        }
        else
        {
            window.location.href = url;
        }
        return false;
    }
    
    function GetProductDetail(title, pg, spg, cl, coi)
    {
        window.location.href = "/Default.aspx?title=" + title + "&pg=" + pg + "&spg=" + spg + "&cl=" + cl + "&coi=" + coi;
    }

    var bdyTimer;
    var currBtn = "";
    var linkBtn = "";

    function divOn(item) 
    {
	    try { clearTimeout(bdyTimer); }
	    catch (ex) { }

        if(currBtn != "")
        {
		    divOffAfterPause(currBtn);
	    }

        var baseID = item.id.replace("lbMenu", "");
        var baseID = baseID.replace("left", "");
        var baseID = baseID.replace("right", "");
        var baseID = baseID.replace("lbSubMenu", "");             
        
	    if(baseID)
	    {
	        currBtn = item.id;
    	    
	        var leftBtn = document.getElementById(baseID + 'left');
	        var rightBtn = document.getElementById(baseID + 'right');
	        var middleBtn = document.getElementById(baseID + 'middle');
    	    
	        if(leftBtn != null)
	        {
	            leftBtn.src = "../App_Images/Global/menu_left_on.gif";
	        }
	        if(rightBtn != null)
	        {
	            rightBtn.src = "../App_Images/Global/menu_right_on.gif";
	        }
	        if(middleBtn != null)
	        {
	            middleBtn.style.backgroundImage = "url(../App_Images/Global/menu_middle_on.gif)";
	        }
	    }
	   	if (document.getElementById(baseID + 'subMenu') != null)
	   	{
	     	document.getElementById(baseID + 'subMenu').style.left = parseInt(getOffsetLeft(document.getElementById(baseID + 'left')) + 1) + "px";
	   		document.getElementById(baseID + 'subMenu').style.top = 25;
	   		document.getElementById(baseID + 'subMenu').style.display = "block";
	   	}
	}
	function divOff(item) {
	    bdyTimer = setTimeout("divOffAfterPause('"+ item.id + "')", 700);
	}
	
	function divOffAfterPause(itemID) {
	
	    try {   
		    clearTimeout(bdyTimer);
		    }
		catch (ex) { }
		
		var baseID = itemID.replace("lbMenu", "");
        var baseID = baseID.replace("left", "");
        var baseID = baseID.replace("right", "");
        var baseID = baseID.replace("lbSubMenu", "");
        
        if(baseID && baseID != linkBtn)
		{
		    var leftBtn = document.getElementById(baseID + 'left');
		    var rightBtn = document.getElementById(baseID + 'right');
		    var middleBtn = document.getElementById(baseID + 'middle');
		    
		    if(leftBtn != null)
		    {
		        leftBtn.src = "../App_Images/Global/menu_left_off.gif";
		    }
		    if(rightBtn != null)
		    {
		        rightBtn.src = "../App_Images/Global/menu_right_off.gif";
		    }
		    if(middleBtn != null)
		    {
		        middleBtn.style.backgroundImage = "url(../App_Images/Global/menu_middle_off.gif)";
		    }
		}
		if (document.getElementById(baseID + 'subMenu') != null)
		{
			document.getElementById(baseID + 'subMenu').style.display = "none";
		}
		
		//if (document.getElementById('arr' + p) != null) 
		//	document.getElementById('arr' + p).style.display = "block";
	}
	
	function getOffsetLeft(el)
	{ 
		var eltemp = el;
		var ol = el.offsetLeft; 
		while((eltemp = eltemp.offsetParent) != null) 
		ol += eltemp.offsetLeft;
		return ol;
	}
	
	function setButtonModeOn(itemID)
	{
	    var baseID = itemID.replace("lbMenu", "");
        var baseID = baseID.replace("left", "");
        var baseID = baseID.replace("right", "");
        var baseID = baseID.replace("lbSubMenu", "");             
        
	    if(baseID)
	    {
	        linkBtn = itemID;
    	    
	        var leftBtn = document.getElementById(baseID + 'left');
	        var rightBtn = document.getElementById(baseID + 'right');
	        var middleBtn = document.getElementById(baseID + 'middle');
    	    
	        if(leftBtn != null)
	        {
	            leftBtn.src = "../App_Images/Global/menu_left_on.gif";
	        }
	        if(rightBtn != null)
	        {
	            rightBtn.src = "../App_Images/Global/menu_right_on.gif";
	        }
	        if(middleBtn != null)
	        {
	            middleBtn.style.backgroundImage = "url(../App_Images/Global/menu_middle_on.gif)";
	        }
	    }
	}
    
    /* End Main menu Script */
    
    /* -- ShoppinCart -- */
    function MM_findObj(n, d) {
        var p,i,x; 
        if(!d) 
            d=document; 
        if((p=n.indexOf("?"))>0&&parent.frames.length) 
        {
            d=parent.frames[n.substring(p+1)].document; 
            n=n.substring(0,p);
        }
        if(!(x=d[n])&&d.all) 
            x=d.all[n]; 
        
        for (i=0;!x&&i<d.forms.length;i++) 
            x=d.forms[i][n];

        for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
            x=MM_findObj(n,d.layers[i].document);
        
        if(!x && d.getElementById) 
            x=d.getElementById(n);
         return x;
    }

    // Detect if the browser is IE or not.
    // If it is not IE, we assume that the browser is NS.
    var IE = document.all?true:false;
     
    // If NS -- that is, !IE -- then set up for mouse capture
    if (!IE) document.captureEvents(Event.MOUSEMOVE)
     
    // Set-up to use getMouseXY function onMouseMove
    document.onmousemove = getMouseXY;
     
    // Temporary variables to hold mouse x-y pos.s
    var tempX = 0;
    var tempY = 0;
     
    // Main function to retrieve mouse x-y pos.s
     
    function getMouseXY(e) {

        IE = document.all?true:false;
        
        try {
            if (IE && (document.documentElement) && (!document.documentElement.scrollTop) && (!document.body.scrollTop)) {
                tempX = event.clientX + 12;
                tempY = event.clientY + 2;
            } else if (IE && document.documentElement && document.documentElement.scrollTop) {
                tempX = event.clientX + document.documentElement.scrollLeft + 12;
                tempY = event.clientY + document.documentElement.scrollTop + 2;
            } else if (IE && document.body && document.body.scrollTop) {
                tempX = event.clientX + document.body.scrollLeft + 12;
                tempY = event.clientY + document.body.scrollTop + 2;
            } else {
                tempX = e.pageX + 12;
                tempY = e.pageY + 2;
            }
        } catch(ex){}

      // catch possible negative values in NS4
      if (tempX < 0){tempX = 0};
      if (tempY < 0){tempY = 0};
      return true
    }

    function MM_showHideLayers() {
        var i,p,v,strText,obj,args=MM_showHideLayers.arguments;
        var display;

        for (i=0; i<(args.length-3); i+=4) 
	        if ((obj=MM_findObj(args[i]))!=null) 
	        { 
		        v=args[i+2];
		        
		        strText = args[i+3];
		        obj.innerHTML = '<table bgcolor="#000000"><tr><td style="color:white;">' + strText + '</td></tr></table>';
		        
                if (obj.style) 
                { 
                    obj=obj.style; 
                    display = (v=='show')?"block":(v=='hide')?"none":"none";
                    v = (v=='show')?'visible':(v=='hide')?'hidden':v;
                    
                    obj.left = tempX + 'px';
                    obj.top = tempY + 'px';
                    
                }
                obj.visibility=v;
                obj.display = display;
            }
    }
    
    /* End Shoppingcart */
    
    function trapEnter(e, enterFunction)
    {
        try 
        {
            var key = e.keyCode || e.which;
             if (key == 13){
                    e.cancelBubble = true;
                    if (e.returnValue) e.returnValue = false;
                    if (e.stopPropagation) e.stopPropagation();
                    if (enterFunction) eval(enterFunction);
                    return false;
         }
         else 
         {
            return true;
         }     
        }
        catch (e) {}
    }
    
    function openPrintWin() {
        try
        {
	        var	W = 530;
	        var H = 500;
	        var L = (screen.width - W) / 2;
	        var T = (screen.height - H) / 2;
	        day = new Date();
	        id = day.getTime();
	        var sRef = "PrintContent.aspx";
	        
	        eval("page" + id + " = window.open(sRef, '" + id + "', 'toolbar=1,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+W+',height='+H+',left ='+L+',top ='+T+'');");
	    }
	    catch (ex) {}
    } 
    
    function TrimString(s) 
    {
        var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
        return (m == null) ? "" : m[1];
    }
    
    function AddToCart()
    {
        var ctrl = document.getElementById("ctl00_cphMainContent_ucProductDetail_txtAmount");
        var value = ctrl.value;
        
        var rx = new RegExp("\\d+");
        var matches = rx.exec(value);
        
        if (matches != null && value == matches[0] && TrimString(value).length > 0 && TrimString(value).length < 6 && (TrimString(value)).indexOf("0") != 0  && value != "0")
        {
            return confirm("Dit product wordt in uw winkelwagen geplaatst.\r\nVanuit de winkelwagen kunt u een offerte aanvragen of een bestelling plaatsen.");
        }
        else
        {
            return false;
        }
    }
    
    function placeOrder(e, val)
    {
        try 
        {
        
            var key = e.keyCode || e.which;
            
            if (key == 13){
                e.cancelBubble = true;
                if (e.returnValue) e.returnValue = false;
                if (e.stopPropagation) e.stopPropagation();
                
                if (val)
                {
                    var ctrl = document.getElementById(val);
                    
                    if(ctrl)
                    {
                        ctrl.click();
                    }
                }
                return false;
         }
         else 
         {
            return true;
         }     
        }
        catch (e) {}
    }
//-->