
//////////////////////////////////////////////////////////////////////	
/**********************************************************************
* USED IN SEVERAL FILES
**********************************************************************/	
    function detailWindow(url, w, h) {
        var leftPoint = (top.screen.width - w) / 2;
        var topPoint = (top.screen.height - h) / 2;
    
        winDetails = window.open(url, 'detail', 'toolbar=no,location=no,directories=no,status=no,menubar=0,scrollbars=yes,left=' + leftPoint + ',top=' + topPoint + ',resizable=yes,width=' + w + ',height=' + h + '')
    }
	
	
	

	function MM_goToURL() { //v3.0
		var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
		for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	}

	/*
	<!-- Idea by:  Nic Wolfe (Nic@TimelapseProductions.com) -->
	<!-- Web URL:  http://fineline.xs.mw -->	
	<!-- This script and many more are available free online at -->
	<!-- The JavaScript Source!! http://javascript.internet.com -->
	
	<!-- Begin
	*/
	function popUp(URL, w, h) {
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + w + ",height=" + h + ",left=200,top=200');");
	}
	
	function popUpScroll(URL, w, h) {
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=" + w + ",height=" + h + ",left=200,top=200');");
	}
	// End -->
		

	/**
	* Hides all drop down form select boxes on the screen so they do not appear above the mask layer.
	* IE has a problem with wanted select form tags to always be the topmost z-index or layer
	*
	* Thanks for the code Scott!
	*/
	function hideSelectBoxes() {
		for(var i = 0; i < document.forms.length; i++) {
			for(var e = 0; e < document.forms[i].length; e++){
				if(document.forms[i].elements[e].tagName == "SELECT") {
					document.forms[i].elements[e].style.visibility="hidden";
				}
			}
		}
	}
	
	
	
	/**
	* Makes all drop down form select boxes on the screen visible so they do not reappear after the dialog is closed.
	* IE has a problem with wanted select form tags to always be the topmost z-index or layer
	*/
	function displaySelectBoxes() {
		for(var i = 0; i < document.forms.length; i++) {
			for(var e = 0; e < document.forms[i].length; e++){
				if(document.forms[i].elements[e].tagName == "SELECT") {
					document.forms[i].elements[e].style.visibility="";
				}
			}
		}
	}

    
    function formatPhoneNumber(txt, e)
    {
        var validChars = "0123456789";
        var str = txt.value;
        var len = str.length;			
        var aChar = str.charAt(len-1);
        var keyCode;
        
        if (document.all)
            keyCode = event.keyCode;
        else
            keyCode = e.which;
        
        if (keyCode == 8)
            return;
        
        
        if (validChars.indexOf(aChar) != -1)
        {
            if ((len == 3) || (len == 7))
                txt.value = str + "-";
        }
        else
            txt.value = str.substr(0, len-1);
    
        
        txt.focus();		
    }
    
    
    
    
    function formatNumberInput(txt, e)
    {
        var validChars = "0123456789";
        var str = txt.value;
        var len = str.length;			
        var aChar = str.charAt(len-1);
        var keyCode;
        
        if (document.all)
            keyCode = event.keyCode;
        else
            keyCode = e.which;
        
        if (keyCode == 8)
            return;
        
        
        if (validChars.indexOf(aChar) == -1)
            txt.value = str.substr(0, len-1);
    
        
        txt.focus();		
    }
    
    
    function formatFloatNumber(txt, e)
    {
        var validChars = "0123456789.";
        var str = txt.value;
        var len = str.length;			
        var aChar = str.charAt(len-1);
        var keyCode;
        
        if (document.all)
            keyCode = event.keyCode;
        else
            keyCode = e.which;
        
        if (keyCode == 8)
            return;
        
        
        if (validChars.indexOf(aChar) == -1)
            txt.value = str.substr(0, len-1);
    
        
        txt.focus();		
    }
    
    
    
    function formatDateOfBirth(txt, e)
    {
        var validChars = "0123456789";
        var str = txt.value;
        var len = str.length;			
        var aChar = str.charAt(len-1);
        var keyCode;
        
        if (document.all)
            keyCode = event.keyCode;
        else
            keyCode = e.which;
        
        if (keyCode == 8)
            return;
        
        if (len > 10)
            txt.value = str.substr(0, len-1);
        else
        {
        
            if (validChars.indexOf(aChar) != -1)
            {
                if ((len == 2) || (len == 5))
                    txt.value = str + "/";
            }
            else
                txt.value = str.substr(0, len-1);
            }
        txt.focus();		
    }
    
    
    
    function changeFocus(field1, field2, len) {
        if (field1.value.length == len) {
            field2.focus();
            field2.select();
            return false;
        }
        return true;
    }	
	
	
	
	function cleanFocusField(field) {
		var clean = false;
		
		if (field.name == "globeSearch") 	{
			if ((field.value == "product search")  || (field.value == "recherche de produits")){
				clean = true;
			}
		}
		
		else if (field.name == "email") {
			if ((field.value == "enter email here")  || (field.value == "entrez votre courriel ici")){
				clean = true;
			}
		}
		
		if (clean) {
			field.value = "";
			field.focus();
			field.select();
			return false;			
		}
		
		
        return true;
    }	

