
var indicatorText = "<div id=\"indicatorText\" style=\"position: fixed; left: 50%;top: 50%;display:none;color:red\">页面加载中，请等待...</div>";


var win;
function openwindow(url, name, iWidth, iHeight){

    if (win == null || win.closed) {
        var url; //转向网页的地址;
        var name; //网页名称，可为空;
        var iWidth; //弹出窗口的宽度;
        var iHeight; //弹出窗口的高度;
        var iTop = (window.screen.availHeight - 30 - iHeight) / 2; //获得窗口的垂直位置;
        var iLeft = (window.screen.availWidth - 10 - iWidth) / 2; //获得窗口的水平位置;
        //打开模式窗口
        win = window.showModalDialog(url, name, 'dialogHeight:' + iHeight + 'px;dialogWidth:' + iWidth + 'px;center:yes;toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
        //win = window.open(url, name, 'height=' + iHeight + ',,innerHeight=' + iHeight + ',width=' + iWidth + ',innerWidth=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
    }
    //win.focus();
}
function openwindow2(url, name, iWidth, iHeight){

    if (win == null || win.closed) {
        var url; //转向网页的地址;
        var name; //网页名称，可为空;
        var iWidth; //弹出窗口的宽度;
        var iHeight; //弹出窗口的高度;
        var iTop = (window.screen.availHeight - 30 - iHeight) / 2; //获得窗口的垂直位置;
        var iLeft = (window.screen.availWidth - 10 - iWidth) / 2; //获得窗口的水平位置;
        //打开模式窗口
       // win = window.showModalDialog(url, name, 'dialogHeight:' + iHeight + 'px;dialogWidth:' + iWidth + 'px;center:yes;toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
        win = window.open(url, name, 'height=' + iHeight + ',,innerHeight=' + iHeight + ',width=' + iWidth + ',innerWidth=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
    }
    //win.focus();
}

function loadjscssfile(filename, filetype, id){
    if (filetype == "js") { //判断文件类型 
        var fileref = document.createElement('script')//创建标签 
        fileref.setAttribute("type", "text/javascript")//定义属性type的值为text/javascript 
        fileref.setAttribute("src", filename)//文件的地址 
    }
    else 
        if (filetype == "css") { //判断文件类型 
            var fileref = document.createElement("link")
            fileref.setAttribute("id", id)
            fileref.setAttribute("rel", "stylesheet")
            fileref.setAttribute("type", "text/css")
            fileref.setAttribute("href", filename)
        }
    if (typeof fileref != "undefined") 
        document.getElementsByTagName("head")[0].appendChild(fileref)
}


/*  用于注册页面 */
function load(){    
    var Sugar_color_style = Get_Cookie("Sugar_color_style");
    var Sugar_font_style = Get_Cookie("Sugar_font_style");
    
    if (Sugar_font_style == null || Sugar_font_style == '') {
        loadjscssfile("themes/Sugar/fonts.normal.css", "css", "current_font_style");
    }
    else {
        loadjscssfile("themes/Sugar/fonts." + Sugar_font_style + ".css", "css", "current_font_style");
    }
    if (Sugar_color_style == null || Sugar_color_style == '') {
        loadjscssfile("themes/Sugar/colors.sugar.css", "css", "current_color_style");
    }
    else {
        loadjscssfile("themes/Sugar/colors." + Sugar_color_style + ".css", "css", "current_color_style");
    }    

}

/*
*   【智捷教育门户网站使用】
*/
function load1(){

	    
    var path = window.location.pathname;
    var pos = path.lastIndexOf("/");
    var pos2 = path.lastIndexOf(".");

	if (path.substring(pos, pos2) != "/MyCartItem!input" && path.substring(pos, pos2) != "/OrderConfirm!input") {
    
		var url = 'Welcome.php';
		new Ajax.Request(url, {
			onSuccess: function(response){
				var resstring = response.responseText.split(',');
				//alert(resstring);
				if (resstring == '') {
					document.getElementById('welcome').innerHTML = '';
					document.getElementById('myaccount').innerHTML = '0';
				}
				else {
					document.getElementById('welcome').innerHTML = resstring[1];
					document.getElementById('myaccount').innerHTML =  resstring[2];
				}
			}
		});

    }
	
    var Sugar_color_style = Get_Cookie("Sugar_color_style");
    var Sugar_font_style = Get_Cookie("Sugar_font_style");

    if (Sugar_font_style == null || Sugar_font_style == '') {
        loadjscssfile("themes/Sugar/fonts.normal.css", "css", "current_font_style");
    }
    else {
        loadjscssfile("themes/Sugar/fonts." + Sugar_font_style + ".css", "css", "current_font_style");
    }
    if (Sugar_color_style == null || Sugar_color_style == '') {
        loadjscssfile("themes/Sugar/colors.sugar.css", "css", "current_color_style");
    }
    else {
        loadjscssfile("themes/Sugar/colors." + Sugar_color_style + ".css", "css", "current_color_style");
    }
    
    if (path.substring(pos, pos2) == "/member_register") {
        return;
    }
	
	//Java就业课程
    if (path.substring(pos, pos2) == "/java_course" ||
    path.substring(pos, pos2) == "/java_course" ||
    path.substring(pos, pos2) == "/java_course_javase" ||
    path.substring(pos, pos2) == "/java_course_javaee" ||
    path.substring(pos, pos2) == "/java_course_interview" ||
    path.substring(pos, pos2) == "/java_course_get" ||
    path.substring(pos, pos2) == "/java_course_db" || 
    path.substring(pos, pos2) == "/java_course_ajax" ||
    path.substring(pos, pos2) == "/java_course_mode" ||
    path.substring(pos, pos2) == "/java_course_spring" ||
    path.substring(pos, pos2) == "/java_course_uml" ||
    path.substring(pos, pos2) == "/java_course_test"  ) {
        document.getElementById('JavaTabLeft').className = "currentTabLeft";
        document.getElementById('JavaTab').className = "currentTab";
        document.getElementById('JavaTabLink').className = "currentTabLink";
        document.getElementById('JavaTabRight').className = "currentTabRight";
        return;
    }
    
	//我们的特色   
    if (path.substring(pos, pos2) == "/women_tese") {
        document.getElementById('women_teseTabLeft').className = "currentTabLeft";
        document.getElementById('women_teseTab').className = "currentTab";
        document.getElementById('women_teseTabLink').className = "currentTabLink";
        document.getElementById('women_teseTabRight').className = "currentTabRight";
        return;
    }
	
	//账户充值
	if (path.substring(pos, pos2) == "/account_chongzhi") {
        document.getElementById('account_chongzhiTabLeft').className = "currentTabLeft";
        document.getElementById('account_chongzhiTab').className = "currentTab";
        document.getElementById('account_chongzhiTabLink').className = "currentTabLink";
        document.getElementById('account_chongzhiTabRight').className = "currentTabRight";
        return;
    }
    
	//师资介绍
    if (path.substring(pos, pos2) == "/shi_zjj") {
        document.getElementById('TeacherCenterTabLeft').className = "currentTabLeft";
        document.getElementById('TeacherCenterTab').className = "currentTab";
        document.getElementById('TeacherCenterTabLink').className = "currentTabLink";
        document.getElementById('TeacherCenterTabRight').className = "currentTabRight";
        return;
    }
    
    //实训项目
    if (path.substring(pos, pos2) == "/project") {
        document.getElementById('ProjectTabLeft').className = "currentTabLeft";
        document.getElementById('ProjectTab').className = "currentTab";
        document.getElementById('ProjectTabLink').className = "currentTabLink";
        document.getElementById('ProjectTabRight').className = "currentTabRight";
        return;
    }
    
	//考试中心
    if (path.substring(pos, pos2) == "/test_center" ||
		path.substring(pos, pos2) == "/test_center_java" ||
		path.substring(pos, pos2) == "/test_center_javaee" ||
		path.substring(pos, pos2) == "/test_center_db") {
        document.getElementById('TestCenterTabLeft').className = "currentTabLeft";
        document.getElementById('TestCenterTab').className = "currentTab";
        document.getElementById('TestCenterTabLink').className = "currentTabLink";
        document.getElementById('TestCenterTabRight').className = "currentTabRight";
        return;
    }
    
	//学习社区
    if (path.substring(pos, pos2) == "/study_center" ||
		path.substring(pos, pos2) == "/study_center_technology_qa" ||
		path.substring(pos, pos2) == "/study_center_errors" ||
		path.substring(pos, pos2) == "/study_center_software" ||
		path.substring(pos, pos2) == "/study_center_technology_article") {
        document.getElementById('studyCenterTabLeft').className = "currentTabLeft";
        document.getElementById('studyCenterTab').className = "currentTab";
        document.getElementById('studyCenterTabLink').className = "currentTabLink";
        document.getElementById('studyCenterTabRight').className = "currentTabRight";
        return;
    }

	//帮助中心
    if (path.substring(pos, pos2) == "/help_center"
		|| path.substring(pos, pos2) == "/help_about"
		|| path.substring(pos, pos2) == "/zi-swd"
		|| path.substring(pos, pos2) == "/gong-sjj"
		|| path.substring(pos, pos2) == "/lian-xwm"
		|| path.substring(pos, pos2) == "/xue-ygx") {
        document.getElementById('HelpTabLeft').className = "currentTabLeft";
        document.getElementById('HelpTab').className = "currentTab";
        document.getElementById('HelpTabLink').className = "currentTabLink";
        document.getElementById('HelpTabRight').className = "currentTabRight";
        return;
    }
    
    //精品在线课程
    if (path.substring(pos, pos2) == "/online_course" 
		 || path.substring(pos, pos2) == "/online_course_ajax" 
		 || path.substring(pos, pos2) == "/online_course_net" 
		 || path.substring(pos, pos2) == "/online_course_struts2") {
        document.getElementById('onlineTabLeft').className = "currentTabLeft";
        document.getElementById('onlineTab').className = "currentTab";
        document.getElementById('onlineTabLink').className = "currentTabLink";
        document.getElementById('onlineTabRight').className = "currentTabRight";
        return;
    }

    //开班信息
    if (path.substring(pos, pos2) == "/zui-xkb" 
		 || path.substring(pos, pos2) == "/zui-xkb_project"
		|| path.substring(pos, pos2) == "/zui-xkb_java_online"
		 ||  path.substring(pos, pos2) ==  "/zui-xkb_vip_online") {
        document.getElementById('zui_xkbTabLeft').className = "currentTabLeft";
        document.getElementById('zui_xkbTab').className = "currentTab";
        document.getElementById('zui_xkbTabLink').className = "currentTabLink";
        document.getElementById('zui_xkbTabRight').className = "currentTabRight";
        return;
    }

    //网上商城 
    if (path.substring(pos, pos2) == "/shopping" 
		 || path.substring(pos, pos2) == "/MyCartItem!input" 
		 || path.substring(pos, pos2) == "/OrderConfirm!input" 
		 || path.substring(pos, pos2) == "/OrderConfirmFinish")
		 
    {
        document.getElementById('shoppingTabLeft').className = "currentTabLeft";
        document.getElementById('shoppingTab').className = "currentTab";
        document.getElementById('shoppingTabLink').className = "currentTabLink";
        document.getElementById('shoppingTabRight').className = "currentTabRight";
        return;
    }

    /*	
    if (path.substring(pos, pos2) == "/study_center") {
        document.getElementById('StudyCenterTabLeft').className = "currentTabLeft";
        document.getElementById('StudyCenterTab').className = "currentTab";
        document.getElementById('StudyCenterTabLink').className = "currentTabLink";
        document.getElementById('StudyCenterTabRight').className = "currentTabRight";
        return;
    }
    */

    //if (path.substring(pos, pos2) == "/index" ) {
    document.getElementById('HomeTabLeft').className = "currentTabLeft";
    document.getElementById('HomeTab').className = "currentTab";
    document.getElementById('HomeTabLink').className = "currentTabLink";
    document.getElementById('HomeTabRight').className = "currentTabRight";
    // } 

}



function getPlace(){

    var path = window.location.pathname;
    var pos = path.lastIndexOf("/");
    var pos2 = path.lastIndexOf(".");
    
    
    if (path.substring(pos, pos2) == "/java_course") {
        return ">>Java就业课程";
    }
    
    if (path.substring(pos, pos2) == "/java_course_mode") {
        return ">>Java就业课程>>学习模式";
    }
    
    if (path.substring(pos, pos2) == "/java_course_get") {
        return ">>Java就业课程>>获得教程和视频";
    }
    
    if (path.substring(pos, pos2) == "/java_course_javase") {
        return ">>Java就业课程>>Java SE";
    }
    
    if (path.substring(pos, pos2) == "/java_course_javaee") {
        return ">>Java就业课程>>Java EE";
    }
    
    if (path.substring(pos, pos2) == "/java_course_db") {
        return ">>Java就业课程>>数据库";
    }

	if (path.substring(pos, pos2) == "/java_course_ajax") {
        return ">>Java就业课程>>AJAX技术";
    }
	
	if (path.substring(pos, pos2) == "/java_course_spring") {
        return ">>Java就业课程>Spring框架";
    }
	
	if (path.substring(pos, pos2) == "/java_course_uml") {
        return ">>Java就业课程>>OOAD与UML";
    }

    if (path.substring(pos, pos2) == "/shi_zjj") {
        return ">>师资介绍";
    }
    
    if (path.substring(pos, pos2) == "/test_center") {
        return ">>考试中心";
    }
    
    if (path.substring(pos, pos2) == "/test_center_java") {
        return ">>考试中心>>核心Java考试详细信息";
    }
    
    if (path.substring(pos, pos2) == "/test_center_db") {
        return ">>考试中心>>数据库考试详细信息";
    }
    
    if (path.substring(pos, pos2) == "/test_center_javaee") {
        return ">>考试中心>>JavaEE考试详细信息";
    }

	if (path.substring(pos, pos2) == "/account_chongzhi") {
        return ">>账户充值";
    }
    
	if (path.substring(pos, pos2) == "/shopping"
	   || path.substring(pos, pos2) == "/MyCartItem!input" 
	   || path.substring(pos, pos2) == "/OrderConfirm!input"
	   || path.substring(pos, pos2) == "/OrderConfirmFinish") {
        return ">>网上商城";
    }

    if (path.substring(pos, pos2) == "/help_center") {
        return ">>帮助中心";
    }
    
    if (path.substring(pos, pos2) == "/online_course" 
		 || path.substring(pos, pos2) == "/online_course_struts2"
	     || path.substring(pos, pos2) == "/online_course_net" 
		 || path.substring(pos, pos2) =="/online_course_ajax") {
        return ">>精品在线课程";
    }
    
    if (path.substring(pos, pos2) == "/study_center") {
        return ">>学习社区>>社区说明";
    }
        
    if (path.substring(pos, pos2) == "/study_center_technology_qa") {
        return ">>学习社区>>技术问题回答";
    }
        
    if (path.substring(pos, pos2) == "/study_center_technology_article") {
        return ">>学习社区>>技术文章";
    }
	
    if (path.substring(pos, pos2) == "/study_center_video") {
        return ">>学习社区>>视频下载区";
    }
    if (path.substring(pos, pos2) == "/study_center_software") {
        return ">>学习社区>>课程配套软件";
    }	
    if (path.substring(pos, pos2) == "/study_center_errors") {
        return ">>学习社区>>教材勘误表";
    }	

	if (path.substring(pos, pos2) == "/women_tese") {
        return ">>我们的特色";
    }
	if (path.substring(pos, pos2) == "/project") {
        return ">>实训项目";
    }
    if (path.substring(pos, pos2) == "/zui-xkb"
	  || path.substring(pos, pos2) == "/zui-xkb_project" 
	 ||  path.substring(pos, pos2) == "/zui-xkb_java_online" 
	  || path.substring(pos, pos2) == "/zui-xkb_vip_online") {
        return ">>开班信息";
    }
	//if (path.substring(pos, pos2) == "/index") {
    return ">>首页";
    //}

}

function Logout(){

    var handler = confirm('安全退出系统？');
    if (handler == 1) {
        var url = 'Logout.php';
        new Ajax.Request(url, {
            onSuccess: function(response){
                document.getElementById('welcome').innerHTML = '';
				document.getElementById('myaccount').innerHTML = '';
            }
        });
		window.location.href = 'index.html';
    }
}

function addCart(courseId,courseName){
    var url = 'MyCart!add.php?courseId='+courseId;
    new Ajax.Request(url, {
        onSuccess: function(response){
            if (response != null && response.responseText == '0') {
                document.getElementById('message').innerHTML=courseName+'添加到购物车';
                slide_default.start();
            } else {
                document.getElementById('message').innerHTML = '';
            }
        }
    });    
}


function seeCart(){

    var url = 'MyCartItem!see.php';
    new Ajax.Request(url, {
        onSuccess: function(response){
            if (response != null && response.responseText == '1') {
                window.location.href = 'MyCartItem!input.php';
            } else if (response != null && response.responseText == '0') {
				alert('您的购物车中没有任何的东西。');
			} else {
				alert('您还没登录，请登录系统再查看购物车。');
            }
        }
    });    
}


function confirmCart(){

	var bla = parseInt(document.getElementById('myaccount').innerHTML,10);
	if (bla >= 0) {
		var url = 'MyCartItem!confirm.php';
		var params = Form.serialize('form1');
		new Ajax.Request(url, {
			method: 'post',
			parameters: params,
			encoding: 'utf-8',
			onSuccess: function(response){				
				if (response != null && response.responseText == '0') {
				   // alert('您还没有登录系统，请登录。');
					window.location.href = 'member_register_login.html';
				}
				else {
					window.location.href = 'OrderConfirm!input.php?myaccount='+bla;
				}
			}
		}); 
	} else {
		alert('您的账户余额不足，请重新修改数量或选择。');
	}
}

function next(){
    var url = 'MyCartItem!next.php';
    new Ajax.Request(url, {
        onSuccess: function(response){
            if (response != null && response.responseText == '0') {
                alert('您没有登录请先登录。');
            } else if (response != null && response.responseText == '1') {
				alert('您的购物车中没有任何的东西。');
            } else if (response != null && response.responseText == '2') {
				// window.location.href = 'loading.html?url=OrderConfirm!input.php';
				 window.location.href = 'OrderConfirm!input.php';
            }
        }
    });  
}


function getPlace2(){

	var path = window.location.href;
    var pos = path.lastIndexOf("=");
	if (pos != -1)
	{		
		path = path.substring(pos+1);
	}
    return "<meta http-equiv=\"refresh\" content=\"2;url="+path+"\">";

}
