function QueryResult(object)
{
	var MLI_mk = '<ww:property value="email"/>'
	if(MLI_mk == null || MLI_mk == "")
	{
		if(object.loginResult == 0)
		{
			location.href = "/index.htm?checksum="+object.checksum+"&mobilekey="+object.mobilekey;
		}
	}	
}
function writeCookie(name, value, seconds, domain)
{
  var expire = "";

  if(seconds != 0)
  {
	expire = new Date((new Date()).getTime() + seconds);
	expire = "; expires=" + expire.toGMTString() ;
	expire = expire + "; path=/; domain="+domain; 
	document.cookie = name + "=" + escape(value) + expire;    
  }else
  {
	expire = expire + "; path=/; domain="+domain; 
	document.cookie = name + "=" + escape(value) + expire;    
  }
} 
function get_city_cookie(){	
	var name="MAIZUOCITYMSG";
	var value = "";
	var arry = new Array();
	var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)")); 
	if(arr != null) {
		value = arr[2];
	}
	return value;		
}

String.prototype.endWith=function(str){
if(str==null||str==""||this.length==0||str.length>this.length)
  return false;
if(this.substring(this.length-str.length)==str)
  return true;
else
  return false;
return true;
}

function removeCookie(){
	writeCookie('Hayxn_Name','',0,'maizuo.com');
	writeCookie('Hayxn_Session','',0,'maizuo.com');
	writeCookie('Hayxn_Key','',0,'maizuo.com');
	writeCookie('MaizuoViewName','',0,'maizuo.com');
	writeCookie('MaizuoUserId','',0,'maizuo.com');
	if(location.href.endWith("emailSign=1")){location = "jf/jfindex.htm";}
	else location.reload();
}

function reachMovie()
{
	location.href = "/movie_list.htm";
}
/*
function bookQuickTicket(){
	var maizuo_fastbook_sel = document.getElementById("maizuo_fastbook_sel");
	var book_ticket_num = document.getElementById("book_ticket_num");
	var arrcity_3word = document.getElementById("arrcity_3word");
	if(maizuo_fastbook_sel.value == 0){
		alert("请选择您要订票的影院！");
		return;
	}
	if(book_ticket_num.value > 0){
		this.location.href="/book.htm?cityId="+arrcity_3word.value+"&cinemaId="+maizuo_fastbook_sel.value+"&count="+book_ticket_num.value;
		
	}else{
		alert("请认真填写订票数量！");
		return;
	}
}
*/
function sethref()
{
	var url = escape(top.location.href);
	var loginhref = document.getElementById("loginhref");
	loginhref.href = "/divlogin.htm?goUrl="+url+"&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=280&width=573&modal=true"; 
}

/*
var _selectCityValue = 0;
function getCinemaList(){
	var cityValue = document.getElementById("arrcity_3word").value;
	if(cityValue == "" || cityValue == "0") return;
	else{
		var cityId = 0;
		try{
			cityId = parseInt(cityValue);
		}catch(e){ cityId = 0;}
		if(cityId > 0)
		DWRGetCinema.getCinema(cityId,getCinemaHandler);
	}
}
*/
function getCinemaHandler(re){	
	var maizuo_fastbook_sel = document.getElementById("maizuo_fastbook_sel");
	for(var t=maizuo_fastbook_sel.length;t>=0;t--){
		try{
		maizuo_fastbook_sel.options.remove(t);}catch(e){maizuo_fastbook_sel.remove(t);}
	}	
	var objOption = document.createElement("OPTION");
	var num = 0;
	if(re != 'null' && re != null) num = re.length; 
  	objOption.text = "选择影院(共"+num+"家)";   
  	objOption.value = 0; 
  	maizuo_fastbook_sel.options.add(objOption);   
  	
	if(re != 'null' && re != null) {
		for(var i=0;i<re.length;i++){
			var objOption = document.createElement("OPTION");   
		  	objOption.text = re[i].name;   
		  	objOption.value = re[i].cid; 
		  	maizuo_fastbook_sel.options.add(objOption);   
		}
	}
}

function HYXCheckIEVersion()
{
	if (document.all) 
	{
		//IE
		if ( /MSIE 6.0/ig.test(navigator.appVersion) ) 
		{
		  //为ie6
	  		return "ie6";
		}

	}
	return "";
}

/*登录调用函数thickboxClick()，参数说明：传入 0 代表什么都不做，传入1 代表登录后要刷新页面， 2代表 登录后要执行自己的函数，函数名字为 doYourOwnBusiness(),传入3  代表登录页面弹出后没后关掉的叉 */
function thickboxClick(doType,skipurl,width,height){
	var loginhref = escape(top.location.href);
	if(skipurl == null || skipurl == undefined || skipurl == "") skipurl= "divlogin.htm";
	if(width == null || width == undefined || width == 0) width= 514;
	if(height == null || height == undefined || height == 0) height= 346;
	if(document.all){
		var a = document.getElementById("thickbox_a");
		a.href = "/"+skipurl+"?goUrl="+loginhref+"&doType="+doType+"&placeValuesBeforeTB_=savedValues&TB_iframe=true&height="+height+"&width="+width+"&modal=true";
		a.click();
	}else{
		var a = document.getElementById("thickbox_a");
		a.href = "/"+skipurl+"?goUrl="+loginhref+"&doType="+doType+"&placeValuesBeforeTB_=savedValues&TB_iframe=true&height="+height+"&width="+width+"&modal=true";
		
		var evt = document.createEvent("MouseEvents"); 
		evt.initEvent("click", true, true); 
		document.getElementById("thickbox_a").dispatchEvent(evt); 
	}
	
}	

function openCityHref(cityId,cityName,count,type){
	var h = 7*24;
	var seconds = h*60*60;
	var domain = "maizuo.com";
	
	var value = cityId+"|"+count+"|"+cityName;
	value = escape(value);
	var name="MAIZUOCITYMSG";
	writeCookie(name, value, seconds, domain);
	var hrefStr = top.location.href;
	if(type == 0){
		if(hrefStr.indexOf('movieId=')>0 || hrefStr.indexOf('commentId=')>0){
			if(hrefStr.indexOf('&')>0){
				hrefStr = hrefStr.substring(0,hrefStr.indexOf('&'));
			}else if(hrefStr.indexOf('#')>0){
				hrefStr = hrefStr.substring(0,hrefStr.indexOf('#'));
			}
		}else{
			if(hrefStr.indexOf('.html')<=0){
				hrefStr = hrefStr.substr(0,hrefStr.indexOf('.htm'));
				hrefStr += ".htm";				
			}else{
				hrefStr = "/index.htm";				
			}
	
		}
		top.location.href = hrefStr;
	}else{
		_doYourFunction(cityId,cityName);
	}
}

function slcCityClick(type,url){
	var city_click = document.getElementById("thickbox_a");
	if(type == 0)
		city_click.href = "/selectcity.htm?placeValuesBeforeTB_=savedValues&TB_iframe=true&height=203&width=416&modal=true";
	else if(type == 1)
		city_click.href = "/selectcity.htm?openCityType=1&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=203&width=416&modal=true";
	else if(type == 2)
		city_click.href = url+"&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=193&width=456&modal=true";
	
	
	if(document.all){
		city_click.click();
	}else{
		var evt = document.createEvent("MouseEvents"); 
		evt.initEvent("click", true, true); 
		city_click.dispatchEvent(evt); 
	}
}	
function regist()
{
	location.href ="/registerindex.htm";
}
function forgetpass()
{
	location.href ="/forgetpass.htm";
}

var _tab_index = -1;
function changeTopMenu(tabIndex,type)
{
	var css = "";
	if(tabIndex == 3)
	{
		document.getElementById("selectmenu3").style.display = "";
	}
	else
	{
		if(_tab_index != 3)
		{
			document.getElementById("selectmenu3").style.display = "none";
		}
	}
	for(var i=0;i<7;i++)
	{
		var div = "_top_tab_div_"+i;
		if(type == 0)
		{												
			if(i == tabIndex)
			{
				document.getElementById(div).className = "zxtb1 f16px fB";
			}
			else if(_tab_index == i)
			{
				document.getElementById(div).className = "zxtb1 f16px fB";
			}
			else
			{
				document.getElementById(div).className = "zxtb2 f16px fB cwhite";
			}
		}
		else
		{
			if(_tab_index == i)
			{
				document.getElementById(div).className = "zxtb1 f16px fB";
			}
			else
			{						
				document.getElementById(div).className = "zxtb2 f16px fB cwhite";
			}
		}
	}
}
function gotoHREF(href){
	top.location.href = href;
}
function SetTopTab(index){
	_tab_index = index;	
	changeTopMenu(index,0);
}

var _small_Menu = -1;

function changeSmallMenu(smallIndex,type)
{
	var css = "";	
	for(var i=0;i<4;i++)
	{
		var div = "smallMenu"+i;
		var Linka = "smaillMenuLink"+i;
		if(type == 0)
		{												
			if(i == smallIndex)
			{
				document.getElementById(div).className = "zxtb3t1";
				document.getElementById(Linka).className = "cwhite";
			}
			else if(_small_Menu == i)
			{
				document.getElementById(div).className = "zxtb3t1";
				document.getElementById(Linka).className = "cwhite";
			}
			else
			{
				document.getElementById(div).className = "zxtb3t2";
				document.getElementById(Linka).className = "huis";
			}
		}
		else
		{
			if(_small_Menu == i)
			{
				document.getElementById(div).className = "zxtb3t1";
				document.getElementById(Linka).className = "cwhite";
			}
			else
			{						
				document.getElementById(div).className = "zxtb3t2";
				document.getElementById(Linka).className = "huis";
			}
		}
	}
}
function SetSmallTab(index){
	_small_Menu = index;
	changeSmallMenu(index,0);
}
function userinfo()
{
	top.location.href = "/userinfo.htm";
}

function registehref()
{
	var url = escape(top.location.href);
	if(url.indexOf("goUrl")>0)
	{
		location.reload();
	}
	else
	{
		location.href = "/registerindex.htm?goUrl="+url+"&doType=0";
	}
}

function floatRegistClick(doType){
	var reghref = escape(top.location.href);
	if(HYXCheckIEVersion()=='ie6')
	{
		var a = document.getElementById("thickbox_a");
			a.href = "/floatregist.htm?goUrl="+reghref+"&doType="+doType+"&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=364&width=516&modal=true";
		a.click();
	}else{
		if(document.all){
		var a = document.getElementById("thickbox_a");
		a.href = "/floatregist.htm?goUrl="+reghref+"&doType="+doType+"&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=346&width=514&modal=true";
		a.click();
	}else{
		var a = document.getElementById("thickbox_a");
		a.href = "/floatregist.htm?goUrl="+reghref+"&doType="+doType+"&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=346&width=514&modal=true";
		
		var evt = document.createEvent("MouseEvents"); 
		evt.initEvent("click", true, true); 
		document.getElementById("thickbox_a").dispatchEvent(evt); 
	}
		}
	
}


function isLogin()
{
	var userId = getCookieValue("MaizuoUserId");
	if(userId != null)
	{
		return userId;
	}
	else
	{
		return 0;
	}
}

function openPlayMovie(type){
	var length = "180px";
	if(type == 0) length="73px";
	try{document.getElementById("maizuo_fastbook_sel").style.width=length;}catch(e){}
	var play_movie_div = document.getElementById("play_movie_div");
	if(type == 0) play_movie_div.style.display = "";
	else play_movie_div.style.display = "none";
}
function mOOPlayingTab(index,length){
	var searchmv = "searchmv__";
	var str = "";
	for(var i=0;i<length;i++){
		str = searchmv+i;
		if(i == index){
			document.getElementById(str).className = "maizuo_searchmv_4";
		}else{
			document.getElementById(str).className = "maizuo_searchmv_3";
		}
	}
}
function mClPlayingTab(id){
	top.location.href="/movie.htm?movieId="+id
}



function floatCommentClick(doType,alterCommentId){
	var reghref = escape(top.location.href);
	if(HYXCheckIEVersion()=='ie6')
	{
		var a = document.getElementById("thickbox_a");
		a.href = "/floatcomment.htm?goUrl="+reghref+"&doType="+doType+"&alterCommentId="+alterCommentId+"&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=390&width=610&modal=true";
		a.click();
	}else{
		if(document.all){
		var a = document.getElementById("thickbox_a");
		a.href = "/floatcomment.htm?goUrl="+reghref+"&doType="+doType+"&alterCommentId="+alterCommentId+"&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=390&width=610&modal=true";
		a.click();
	}else{
		var a = document.getElementById("thickbox_a");
		a.href = "/floatcomment.htm?goUrl="+reghref+"&doType="+doType+"&alterCommentId="+alterCommentId+"&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=390&width=610&modal=true";
		
		var evt = document.createEvent("MouseEvents"); 
		evt.initEvent("click", true, true); 
		document.getElementById("thickbox_a").dispatchEvent(evt); 
	}
		}
	
}

function floatCinemaComment(doType,cinemaId){
	if(isLogin() == 0)
	{
		thickboxClick(0);  
		return false;
	}
	if(HYXCheckIEVersion()=='ie6')
	{
		var a = document.getElementById("thickbox_a");
		a.href = "/floatcinemacomment.htm?doType="+doType+"&cinemaId="+cinemaId+"&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=350&width=610&modal=true";
		a.click();
	}else{
		if(document.all){
		var a = document.getElementById("thickbox_a");
		a.href = "/floatcinemacomment.htm?doType="+doType+"&cinemaId="+cinemaId+"&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=350&width=610&modal=true";
		a.click();
		}else{
			var a = document.getElementById("thickbox_a");
			a.href = "/floatcinemacomment.htm?doType="+doType+"&cinemaId="+cinemaId+"&placeValuesBeforeTB_=savedValues&TB_iframe=true&height=350&width=610&modal=true";
			
			var evt = document.createEvent("MouseEvents"); 
			evt.initEvent("click", true, true); 
			document.getElementById("thickbox_a").dispatchEvent(evt); 
		}
	}
	
}
function getCookieValue(name)
{
var cookieValue = "";
	var search = name + "=";
	
	if(document.cookie.length > 0)
	{
		offset = document.cookie.indexOf(search);
	if (offset != -1)
	{
		offset += search.length;
		end = document.cookie.indexOf(";", offset);
		if (end == -1) end = document.cookie.length;
		cookieValue = unescape(document.cookie.substring(offset, end))
		}
	}

	if(cookieValue == "")
		return null;
  	return cookieValue;
}

function showcitydiv(type,number)
{
	var play_city_div = document.getElementById("play_city_div_"+number);
	if(type == 0) play_city_div.style.display = "block";
	else play_city_div.style.display = "none";
}

function gotoActiveCashCard()
{
	var userId = isLogin();
	if(	userId == 0){
		thickboxClick(2);
		return false; 
	}
	top.location.href  = "/userinfo.htm?index=7";
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  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;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
