//异步获取页面内容
function GetPageByAjax(url,courseid)
{
	CreateDivOnParentDocument("divInfoSpace",200,30,screen.width-300,top.window.document.body.scrollTop+5,"red",1000,"系统正在处理您的报名请求,请稍候!");
	 $.ajax({
            type: "GET",//使用get方法访问后台
            url: url,//要访问的后台地址
			cache:true,
			complete :function(){$("#divInfoSpace").hide();},//AJAX请求完成时隐藏loading提示
            success: function(response){_CallBack(response,courseid);} //回调函数
           });
}
function _CallBack(page_request,courseid)
{
		 if(top.window.document.getElementById("showInfo"))
			top.window.document.body.removeChild(top.window.document.getElementById("showInfo")); 

		 //处理报名结果
	   switch(page_request)
	   {
		   //报名成功
			case "1"  : alert("报名成功");top.window.location.reload();break;
			//未登录,弹出登录窗口
			//case "-1" : CreateDivOnParentDocumentWithFrame("showInfo",480,350,screen.width/2-300,top.window.document.body.scrollTop+100,"#CCCCCC",1000,"","http://zj.eee114.com/UserLogins.aspx");break;
			case "-1":AlertBeforLogin(courseid); break;
			//已报考此课程
			case "0"  : alert("您已经报考该课程");break;
			//其它情况
			default   : alert("报考未成功");break;
	   }  		
}
/*
在父窗口中创建带Frame的Div
参数说明: 例如 CreateDiv(this,"MemoDiv",300,200,40,50,"blue",1,"sdfsdfdsfs2134234<br><input id=close type=button value=取消 onclick=RemoveDiv(\"MemoDiv\") />")' />
e--引发此事件的控件
id --Div的ID 和Name
width -- Div宽度
height --Div高度
pLeft --Div相对引发创建事件控件的左偏移量
pTop -- Div相对引发创建事件控件的顶偏移量
backcolor --Div背景色
zIndex --Div在垂直方向位置
innerHTML -- 层所显示内容
*/
function CreateDivOnParentDocumentWithFrame(id,width,height,pLeft,pTop,backcolor,zIndex,innerHTML,url)
{
    if(top.window.document.getElementById(id))
       top.window.document.body.removeChild(top.window.document.getElementById(id));
	//创建背景层
	CreateDivInBackGround(zIndex);
    var ttop = 0//确定引发此事件的控件的位置
    var tleft = 0;
	//alert(ttop+'--'+tleft);
    var s = top.window.document.createElement("DIV"); 
      s.id = id;
      s.name = id;      
      s.style.position="absolute";
      s.style.left = tleft + pLeft;  //距左边偏移量
      s.style.top = ttop + pTop ;  //距顶部的偏移量
      //s.style.left=(window.screen.width-600)/2+"px" ;
     // s.style.top=(window.screen.height)/2+15+"px";      
      s.style.width = width +"px";
      s.style.height = height +"px";
      s.style.border = "black 0px solid";
      //s.style.backgroundColor = backcolor;
	  s.style.backgroundColor = "transparent";
      s.style.zIndex=zIndex;  
      s.style.display="";   
      s.innerHTML=innerHTML;

	 // 生成iframe
     var f=top.window.document.createElement("IFRAME");
     f.name="frmDiv";
     f.id="frmDiv";      
     f.width=width;    
     f.height=height;
     f.scrolling="no";
     f.frameBorder=0;  
	 f.allowTransparency = true;
     f.style.zIndex=s.style.zIndex-1;
     f.src= url;
     // 附加f到s
     s.appendChild(f);
     top.window.document.body.appendChild(s);
	  setInterval('AutoMoveOnParentDocument("'+id+'")',200);    
}
/*
功能:在交窗口中创建Div
参数说明: 例如 CreateDiv(this,"MemoDiv",300,200,40,50,"blue",1,"sdfsdfdsfs2134234<br><input id=close type=button value=取消 onclick=RemoveDiv(\"MemoDiv\") />")' />
e--引发此事件的控件
id --Div的ID 和Name
width -- Div宽度
height --Div高度
pLeft --Div相对引发创建事件控件的左偏移量
pTop -- Div相对引发创建事件控件的顶偏移量
backcolor --Div背景色
zIndex --Div在垂直方向位置
innerHTML -- 层所显示内容
*/
function CreateDivOnParentDocument(id,width,height,pLeft,pTop,backcolor,zIndex,innerHTML)
{
    if(top.window.document.getElementById(id))
       top.window.document.body.removeChild(top.window.document.getElementById(id));
    var ttop = 0;//确定引发此事件的控件的位置
    var tleft = 0;
	//alert(ttop+'--'+tleft);
    var s = top.window.document.createElement("DIV"); 
      s.id = id;
      s.name = id;      
      s.style.position="absolute";
      s.style.left = tleft + pLeft;  //距左边偏移量
      s.style.top = ttop + pTop ;  //距顶部的偏移量
      //s.style.left=(window.screen.width-600)/2+"px" ;
     // s.style.top=(window.screen.height)/2+15+"px";      
      s.style.width = width +"px";
      s.style.height = height +"px";
      s.style.border = "black 1px solid";
      s.style.backgroundColor = backcolor;
      s.style.zIndex=zIndex;  
      s.style.display="";   
      s.innerHTML=innerHTML;
      top.window.document.body.appendChild(s);
	    setInterval('AutoMoveOnParentDocument("'+id+'")',200);
}
/*
在父窗口中创建背景层
*/
function CreateDivInBackGround(zIndex)
{
		if(top.window.document.getElementById("bgDiv"))
			 top.window.document.body.removeChild(top.document.getElementById("bgDiv"));	
        var sWidth,sHeight;
		sWidth=top.document.body.scrollWidth;
		//sHeight=top.window.document.documentElement.scrollHeight;
		sHeight = top.document.body.scrollHeight;
		var bgObj=top.window.document.createElement("div");
		bgObj.setAttribute('id','bgDiv');
		bgObj.style.position="absolute";
		bgObj.style.top="0";
		bgObj.style.background="#CCCCCC";
		bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
		bgObj.style.opacity="0.6";
		bgObj.style.left="0";
		bgObj.style.width=sWidth + "px";
		bgObj.style.height=sHeight + "px";
		bgObj.style.zIndex = zIndex-1;
		top.window.document.body.appendChild(bgObj);
}
//滚动
function AutoMoveOnParentDocument(id)
{
	if(top.window.document.getElementById(id))
	{
		top.window.document.getElementById(id).style.top = top.window.document.documentElement.scrollTop + 100;
	}
}
//关闭层
function ColseDivOnParentDocument()
{
	if(top.document.getElementById("bgDiv"))
		top.document.body.removeChild(top.document.getElementById("bgDiv"));
	if(top.document.getElementById("showInfo"))
		top.document.body.removeChild(top.document.getElementById("showInfo"));
}

//弹出登陆窗口前提示信息
function AlertBeforLogin(courseid)
{
	var str ='<table width="413" height="202" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#DB463F" style="border-collapse:collapse;">';
	       str +='<tr> <td height="27" valign="top" background="http://image.chinahqc.com/chinahqc.V2/images/index_16.gif">';
		   str +='<table width="100%" border="0" cellspacing="0" cellpadding="0">';
		   str +='<tr><td width="5%" height="25" background="http://image.chinahqc.com/chinahqc.V2/images/index_16.gif">&nbsp;</td>';
		   str +='<td width="85%" background="http://image.chinahqc.com/chinahqc.V2/images/index_16.gif" class="bai12_text">提 示 信 息 </td>';
		   //str +='<td width="10%" align="right"><img src="http://image.chinahqc.com/chinahqc.V2/images/tsxx_gb.gif" onclick="document.getElementById(\'bgDiv\').style.display=\'none\';document.getElementById(\'showInfo\').style.display=\'none\';" style="cursor:hand" width="30" height="27" /></td>';
		   str +='<td width="10%" align="right"><img src="http://image.chinahqc.com/chinahqc.V2/images/tsxx_gb.gif" onclick="ColseDivOnParentDocument()" style="cursor:hand" width="30" height="27" /></td>';
		   str +='</tr></table></td></tr>';
		   str +='<tr><td height="150" align="center" valign="middle">';
		   str +='<table width="373" height="137" border="0" cellpadding="0" cellspacing="0" style="margin-top:12px;">';
		   str +='<tr>';
		   str +=' <td width="85" rowspan="2" align="right" valign="middle"><img src="http://image.chinahqc.com/chinahqc.V2/images/yellow_icon_0332.gif" width="85" height="85" /></td>';
		   str +='</tr><tr> <td width="288" colspan="2" align="left" valign="middle">';
		   str +='<table width="100%" border="0" cellpadding="0" cellspacing="0">';
		   str +='<tr><td width="48%" align="left">1、未注册会员</td>';
	       str +=' <td width="52%">';
		   str +='<a href=javascript:LoginRegist("'+courseid+'")>';
		   str +='<img src="http://image.chinahqc.com/chinahqc.V2/images/suotijiaoc.gif" width="148" height="48" vspace="3" border = 0/>';
		   str +='</a>';
		   str +='</td></tr><tr>';
		   str +='<td height="54" align="left">2、已注册未登录会员</td>';
		   str +='<td><span class="content_text2">';
		   str +='<a href="javascript:void(0)" onclick=Logins("'+courseid+'")>';
		   str +='<img src="http://image.chinahqc.com/chinahqc.V2/images/suotijiaod.gif" width="148" height="48" vspace="3" border=0/>';
		   str +='</a>';
		   str +='</td> </tr></table></td></tr>';
		   str +='<tr> <td height="80" colspan="3" align="left" valign="middle">请选择操作,不明事宜，请拨打报名专线:<br />';
		   str +='010-62690232  62690279  </td>';
		   str +=' </tr> </table></td></tr></table>';
		CreateDivInBackGround(9);
        CreateDivOnParentDocument("showInfo",413,202,screen.width/2-300,top.window.document.body.scrollTop+100,"white",10,str);
		// window.setTimeout('Logins()',3000);
}
//已注册,快速报名
function Logins(courseid)
{
	if(top.document.getElementById("showInfo"))
		top.document.body.removeChild(top.document.getElementById("showInfo"));
	CreateDivOnParentDocumentWithFrame("showInfo",480,350,screen.width/2-300,top.window.document.body.scrollTop+100,"#CCCCCC",1000,"","");
	if(top.document.getElementById("frmDiv"))
		top.document.getElementById("frmDiv").src = "/UserLogins.aspx?courseid="+courseid+"&time="+Math.random();
}
//未注册,快速报名
function LoginRegist(courseid)
{
	window.location.href = '/Register/Register.aspx?CareerCourseId='+courseid;
}
//实际页面调用方法
function baoming(careercourseid)
{
		GetPageByAjax("/Course/AddUserExamInfo.aspx?CareerCourseID="+careercourseid,careercourseid);
}
//检测用户登陆状态
function CheckMemberLoginState(redirectUrl)
{
	var url = '/Common/CheckMemberLoginState.aspx?rondom='+Math.random();
	$.get(url,function(response){_CallBack_Login_Behind(response,redirectUrl);});
//	var x = new Ajax();
//	x.setRecvType('HTML');//类型有HTML\XML
//	//x.setWaitId('showinfo'); //设置显示加载进度图片的载体
//	x.get(url,function(s){DoSomeThingIfNoLogin(s,index);});
}
function _CallBack_Login_Behind(response,redirectUrl)
{
	if(response >0)
	{
		top.window.location.href = redirectUrl;
	}
	else
	{
		CreateDivOnParentDocumentWithFrame("showInfo",480,350,screen.width/2-300,top.window.document.body.scrollTop+100,"#CCCCCC",1000,"","");
		if(top.document.getElementById("frmDiv"))
		{
			top.document.getElementById("frmDiv").src = "/UserLogins.aspx?RedirectUrl="+redirectUrl+"&RedirectTarget=top&time="+Math.random();
		}
			
	}
}
//异步请求新闻页面
function GetNewsByAjax(flag,showid)
{
	var url;
	switch(flag)
	{
		case 1:url="http://newsgzw.eee114.com/newscenter/";break;
		case 2:url="http://newsgzw.eee114.com/notice/";break;
		case 3:url="http://newsgzw.eee114.com/ksfd/";break;
	}
	var x = new Ajax();
	x.setRecvType("HTML");
	x.get(url,function(s){$(showid).innerHTML=s;});
}
function GetHtmlFile(type,file,flag)
{
    var strUrl ;
    if(type == 1)
    {
        strUrl = "/HtmlFile/CourseMenu/"+file+".htm";
    }
    else
    {
        strUrl = "/HtmlFile/"+file;
    }
    
    $.ajax({
          url: strUrl,
          cache: true,
          error:function (){
              //$("#divCareerCourseMemo").html("请求页面失败:"+strUrl); 
			  $("#divCareerCourseMemo").html("近期将上传该课程目录!");
          },
          success: function(html){
            $("#divCareerCourseMemo").html(html);
          }
    }); 
    for(var i=1;i<6;i++)
    {
         if($("#span_"+i))
             $("#span_"+i).removeClass("ggnnnbtoponmose");
    }
    if($("#span_"+flag))
    {
         $("#span_"+flag).addClass("ggnnnbtoponmose");
    }
}
