﻿
    $(function() {
	    var so = new SWFObject('nav.swf', 'menu-flash', '760', '101', '9');
	    so.skipDetect = true;
	    so.addParam('wmode', 'transparent');
	    so.addVariable('menuPath', 'MenuXml.aspx');
	    so.addVariable('geturl', window.location.href);
	    so.write('menu');
    });
    
    $(document).ready(function() {
        function filterPath(string) {
            return string
	        .replace(/^\//,'')
	        .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
	        .replace(/\/$/,'');
        }
        var locationPath = filterPath(location.pathname);
        $('a[href*=#]').each(function() {
	        var thisPath = filterPath(this.pathname) || locationPath;
	        if (  locationPath == thisPath
	        && (location.hostname == this.hostname || !this.hostname)
	        && this.hash.replace(/#/,'') ) {
	        var $target = $(this.hash), target = this.hash;
	        if (target && ($target.length > 0)) {
		        var targetOffset = $target.offset().top;
		        $(this).click(function(event) {
		        event.preventDefault();
		        $('html, body').animate({scrollTop: targetOffset}, 400, function() {
			    location.hash = target;
		    });
		 });
	    }
	    }
    });
    });
    
    function checkQualityForm()
    {
        var errorMsg = "請輸入以下欄位:\n";
        var errorMsg2 = "請檢查 Email";
        var emailReg = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
        
        var bool = true;
        var bool2 = true;
        var c1 = document.getElementById('ctl00_ContentPlaceHolder1_chkQuality1');
        var c2 = document.getElementById('ctl00_ContentPlaceHolder1_chkQuality2');
        var c3 = document.getElementById('ctl00_ContentPlaceHolder1_chkQuality3');
        var c4 = document.getElementById('ctl00_ContentPlaceHolder1_chkQuality4');
        var c5 = document.getElementById('ctl00_ContentPlaceHolder1_chkQuality5');
        var c6 = document.getElementById('ctl00_ContentPlaceHolder1_chkQuality6');
        var c7 = document.getElementById('ctl00_ContentPlaceHolder1_chkQuality7');
        var c8 = document.getElementById('ctl00_ContentPlaceHolder1_chkQuality8');
        
        if (((c1!=null) && (c1.checked == false)) && ((c2!=null) && (c2.checked == false)) && ((c3!=null) && (c3.checked == false)) &&
            ((c4!=null) && (c4.checked == false)) && ((c5!=null) && (c5.checked == false)) && ((c6!=null) && (c6.checked == false)) &&
            ((c7!=null) && (c7.checked == false)) && ((c8!=null) && (c8.checked == false)))
        {
            bool = false;
            errorMsg = errorMsg + " - 通訊品質\n";
        }
        var f = document.getElementById("ctl00_ContentPlaceHolder1_txtLocation");
         if((f!=null) && (f.value.length==0))
        {
            bool = false;
            errorMsg = errorMsg + " - 反應地點\n";
        }
        
        f = document.getElementById("ctl00_ContentPlaceHolder1_txtUserNameQ");
        if((f!=null) && (f.value.length==0))
        {
            bool = false;
            errorMsg = errorMsg + " - 姓名\n";
        }
        f = document.getElementById("ctl00_ContentPlaceHolder1_txtMobilePhoneQ");
        if((f!=null) && (f.value.length==0))
        {
            bool = false;
            errorMsg = errorMsg + " - 手機號碼\n";
        }
        f = document.getElementById("ctl00_ContentPlaceHolder1_txtEmailQ");
        if((f!=null) && (f.value.length==0))
        {
            bool = false;
            errorMsg = errorMsg + " - E-mail\n";
        }
        //檢查格式
        if((f!=null) && (f.value.length>0))
        {
            if (f.value.match(emailReg)==null)
            {
                bool2 = false;
            }
        }
        f = document.getElementById("ctl00_ContentPlaceHolder1_txtLinePhoneQ");
        if((f!=null) && (f.value.length==0))
        {
            bool = false;
            errorMsg = errorMsg + " - 市話號碼\n";
        }
        
        if(bool == false)
        {
            alert(errorMsg);
            return false;
        }
        else
        {
            if(bool2 == false)
            {
                alert(errorMsg2);
                return false;
            }
            return true;
        }
    }