//电影首页调用 || ajax替换热映影片　即将上映　老片回顾　
function setTab(name,cursel,n){
	$('.bank_nav02 ul li').removeClass('hover');	
	var menu = document.getElementById(name+cursel);		 
	menu.className = "hover";	
	$.ajax({
		type: 'GET',
		url: 'ajaxgetFilm.php',
		data:'type='+cursel+'&d='+new Date(),
		dataType:"xmlDocument" ,			
		success: function(msg){							
			$('#dvfilmlist').html(msg);
		} 
	});  	
};
//电影首页调用 || 热映影片　即将上映　老片回顾　分页
function chpage(page,type){
	$.ajax({
		type: 'GET',
		url: 'ajaxgetFilm.php',
		data:'type='+type+'&page='+page+'&d='+new Date(),	
		dataType:"xmlDocument" ,			
		success: function(msg){							
			$('#dvfilmlist').html(msg);
		} 
	}); 
};
//显示\隐藏　排期区域
$(function(){
	$(".film_tt1 a").toggle(function () {
		$("#spChe").hide();	    	    
		$('#spnds').html('打开 <img src="http://www.hipiao.com/res/images/film/icon3.gif" />');
	},
	function () {
		$("#spChe").show();	    
		$('#spnds').html('收起 <img src="http://www.hipiao.com/res/images/film/icon2.gif" />');	    
	}); 
});
//取影片的有效排期
function getPlan(sValue,sign,obj,index){
	var pixnumber = $("#pixnumber").val();
	var HpCityId = $("#HpCityId").val();
	
	var HpCity = $("#HpCity").val();
	
	var plandate = $("#tdate").val();
	var cinemaNumber = $("#tcinema").val();
	if (sign == 0){//时间列表处调用
		plandate = sValue;
		$("#tdate").val(sValue);
		$(".ad").removeClass('ttday01');
		
	}else if(sign == 1){//电影列表处调用
		cinemaNumber = sValue;
		$("#tcinema").val(sValue);
		$(".ahf").removeClass('ttday01');
	}
	$(obj).addClass("ttday01");
	$.ajax({
		type: "GET",
		url:"ajaxgetFilmPlan.php?pixnumber="+encodeURIComponent(pixnumber)+"&ddate="+plandate+"&HpCityId="+ HpCityId +"&cinemaNumber="+ cinemaNumber +"&HpCity="+encodeURIComponent(HpCity)+"&d="+new Date(),
		dataType:"xmlDocument" ,
		success: function(msg){
			$("#sclist").html(msg);
			if ((msg.indexOf('暂无该影片排期') != -1)&&index=='index'){
				$('#spnds').html('打开 <img src="http://www.hipiao.com/res/images/film/icon3.gif" />');
				$('#spChe').hide();
				$("#sclist").html();
				$('#sclist').hide();
			}else $('#sclist').show();
		}
	});
};
//电影详情页剧照弹出层功能
function alpic(val,pcur){
	$("#pcur").val(pcur);
	$("#bigpic").attr('src',val);
	DrawImage(val,450);
    //setWinIndex("dvPlayPic");
};
//电影详情页剧照弹出层　图片分页
function chpic(type){
	var picurl = '';
	var pcur = $("#pcur").val();
	var pnum =  $("#pnum").val();
	if (type == 0){
		if (pcur == 1) return false;
		pcur = parseInt(pcur)-1;
	}else{
		if (pcur == pnum) return false;
		pcur = parseInt(pcur)+1;
	}
	$("#pcur").val(pcur);
	picurl = $("#img"+pcur).attr('src');
	
	picurl = picurl.replace(/s./g,'.');
	$("#bigpic").attr('src',picurl);
	DrawImage(picurl,450);
};
//等比例缩放图片
function DrawImage(ImgD,iheight){
	var image=new Image();
	image.onload = function(){
	   	var s_w = image.width;
	   	var s_h = image.height;
	   	var s_hn = 1;
		if(s_h>iheight){
			s_hn = s_h/iheight;
		}
		var sw = s_w/s_hn;
		var sn = s_h/s_hn;
		
		$("#bigpic").width(sw);
		$("#bigpic").height(sn);
		
		$("#dvPlayPic").width(sw);
		$("#dvPlayPic").height(sn);
		
		setWinIndex("dvPlayPic");
	}
	image.src=ImgD;
};
