﻿        function loadMenu(pos1, pos2, type)
        {
            var menu = '';
            menu += '<a name="menuType" href="http://xemphim.eu/movie-home/" class="" onmouseover="activeMenu(this); loadSubmenu(0'+','+pos2+','+type+');">Trang chủ</a>';
            menu += '<a name="menuType" href="http://xemphim.eu/movie-list/cinema.html" class="" onmouseover="activeMenu(this); loadSubmenu(1'+','+pos2+','+type+');">Phim Chiếu Rạp</a>';
            menu += '<a name="menuType" href="http://xemphim.eu/movie-cat/vien_tuong-34.html" class="" onmouseover="activeMenu(this); loadSubmenu(1'+','+pos2+','+type+');">Phim Viễn Tưởng</a>';
            menu += '<a name="menuType" href="http://xemphim.eu/movie-cat/hai_huoc-3.html" class="" onmouseover="activeMenu(this); clearSubMenu();">Phim Hài</a>';
            menu += '<a name="menuType" href="http://xemphim.eu/movie-cat/kinh_di-4.html" class="" onmouseover="activeMenu(this); clearSubMenu();">Phim Ma</a>';
            menu += '<a name="menuType" href="http://xemphim.eu/tivi" class="" onmouseover="activeMenu(this); clearSubMenu();">Xem Tivi Online</a>';
            document.getElementById('mainmenu').innerHTML = menu;
            var arrType = document.getElementsByName('menuType');
            arrType[pos1].className = 'curnav';	
            loadSubmenu(pos1, pos2, type);		
        }

        function clearSubMenu()
		{
		    document.getElementById('submenu').innerHTML = '';
		}
		function activeMenu(obj)
		{
		    var arrType = document.getElementsByName('menuType');
			for (var i = 0; i < arrType.length; i++) {
				arrType[i].className = '';
			}
			obj.className = 'curnav';
		}
        function applyType(obj, value)
		{
			var arrType = document.getElementsByName('searchType');
			for (var i = 0; i < arrType.length; i++) {
				arrType[i].className = '';
			}
			obj.className = 'curnav';
			$('t').value = value;
		}
		//Open popup
        function openWindow(filename, winname, width, height, feature) {
	        var features, top, left;
	        var reOpera = /opera/i ;
	        var winnameRequired = ((navigator.appName == "Netscape" && parseInt(navigator.appVersion) == 4) || reOpera.test(navigator.userAgent));
        	
	        left = (window.screen.width - width) / 2;
	        top = (window.screen.height - height) / 2;	
	        if(feature == '')
		        features = "width=" + width + ",height=" + height + ",top=" + top + ",left=" + left + ",status=0,location=0";
	        else
		        features = "width=" + width + ",height=" + height + ",top=" + top + ",left=" + left + "," + feature;
        //	if(!winnameRequired)	winname = "";
	        newwindow = window.open(filename,winname,features);
	        newwindow.focus();
        }
        function SubmitVote(type)
        {                
                if (type == 1) {
                    answers = document.getElementsByName('surveyresponse');
                    id = -1;
                    for (var i = 0; i < answers.length; i++) {
                        if (answers[i].checked) {
				            id = answers[i].value;
				            break;
				        }
			        }
			        if (id == -1) {
			            alert("Hãy chọn một trong các mục trước khi bình chọn.");
			        }
			        else {
			            var x = readCookie('zingmovievote')
                        if (x) {
	                        alert("Bạn chỉ được bình chọn 1 lần ^^");
                        }
                        else {
			                //createCookie("zingmovievote", "zmovie", 1);
			                openWindow("/Movie/SurveyResult.aspx?t=1&a="+id,"",600,300,"");
			            }
			        }
			    }
			    else
			        openWindow("/Movie/SurveyResult.aspx?t=0","",600,300,"");
                return false;
        }
        function createCookie(name,value,days) {
	        if (days) {
		        var date = new Date();
		        date.setTime(date.getTime()+(days*24*60*60*1000));
		        var expires = "; expires="+date.toGMTString();		        
	        }
	        else var expires = "";
	        document.cookie = name+"="+value+expires+"; path=/";
        }
        function readCookie(name) {
	        var nameEQ = name + "=";
	        var ca = document.cookie.split(';');
	        for(var i=0;i < ca.length;i++) {
		        var c = ca[i];
		        while (c.charAt(0)==' ') c = c.substring(1,c.length);
		        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	        }
	        return null;
        }
        function logout1()
		{
			if (confirm('Bạn thực sự muốn thoát?')) {
				window.location.href = '/Movie/login/Logout.aspx';
			} else {
				return;
			}
		}
		