﻿// JScript File
//添加邮件订阅的脚本
   function  MailSendRequest()
   {
   
        var eadr=document.getElementById("studyezMsSubscribeEmailAddress").value;
        var re=/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/i;
        var res=eadr.search(re);
        if(res==-1)
        {
             alert("格式不对！");
             return ;
        }
        var url=document.getElementById("urlPostAddress").value +encodeURI(eadr)+"&tid="+document.getElementById("urlPostAddressId").value ;
        window.location.href=url;

   }
   
   //邮件订阅的脚本

function closewindow()
{
	  if(confirm("确认关闭?"))
	  {
	   //window.opener.location.reload(false);
	   window.opener.location.href=window.opener.location.href;
	   window.close();
	  }
}
	
 function openmodule(moduleid,pagename,paraname)
 {
   window.open(pagename+"?"+paraname+"="+moduleid,"ModuleEdit","left=200,top=100, width=700,height=700,toolbar=no","");
 }

function openContent(id,vPath)
 {
//debugger;
 var pageUrl=window.location.pathname;
 strEditorUrl=vPath+"HtmlEdit/EditContent.aspx?id="+id+"&pageUrl="+pageUrl;
 var editWin= window.open(strEditorUrl,"页面编辑器", 'left=200,top=100, width=700,height=700,toolbars=0,resizable=1');
 editWin.focus();
 }
 function Clear()
	{
	var inputs=document.getElementsByTagName("input");
	var textareas=document.getElementsByTagName("textarea");
	for(var j=0;j<textareas.length;j++)
	{
		textareas[j].value="";
	}
	for(var i=0;i<inputs.length;i++)
	{
	if(inputs[i].type=="text")
	{
	inputs[i].value="";
	}
	}
	}
	
/**************************************/
/* Js cookies 工具类                  *  
/**************************************/

<!--
 //使用cookie时的一个工具类（面向对象，原型）
 //构造函数：用指定的名字和可选的性质为指定的文档创建一个cookie对象。
 //参数：
 //document:保存cookie的Document对象，必须的。
 //name:指定cookie名的字符串。必须的。
 //hours:一个可选的数字，指定从现在起到过期时间的小时数
 //path:一个可选的字符串，指定了cookie的路径性质
 //domain:一个可选的字符串，指定了cookie的域性质
 //secure:一个可选的布尔值，为true ，需要一个安全的cookie

 function Cookie(document, name, hours, path, domain, secure)
{
    // 该对象的所有预定义的属性都以'$'开头。
    // 这是为了与存储在cookie中的属性值区分开。
    this.$document = document;
    this.$name = name;
    if (hours)  //当字符串为空时，为false, 不为空时，为true
        this.$expiration = new Date((new Date()).getTime() + hours*3600000);
    else this.$expiration = null;
    if (path) this.$path = path; else this.$path = null;
    if (domain) this.$domain = domain; else this.$domain = null;
    if (secure) this.$secure = true; else this.$secure = false;
}

// 该函数是cookie对象的 store() 方法。
Cookie.prototype.store = function () {
    // 首先，遍历cookie对象的属性，并且将cookie值连接起来。
    // 由于cookie将等号和分号作为分隔符。
    // 所以我们使用冒号和&来分隔存储在单个cookie值中的状态变量。
    // 注意：我们对每个状态变量的值进行了转义，以防它含有标点符号或其它非法字符。
    var cookieval = "";
    for(var prop in this) {
        // 忽略所有名字以$开头的属性和所有方法（typeof的用法）
        if ((prop.charAt(0) == '$') || ((typeof this[prop]) == 'function')) 
            continue;
        if (cookieval != "") cookieval += '&';
        cookieval += prop + ':' + escape(this[prop]);
    }

    // 既然我们已经有了cookie只，就可以连接完成的cookie串。
 //其中包括名字和创建cookie对象时指定的各种性质.
    var cookie = this.$name + '=' + cookieval;
    if (this.$expiration)
        cookie += '; expires=' + this.$expiration.toGMTString();
    if (this.$path) cookie += '; path=' + this.$path;
    if (this.$domain) cookie += '; domain=' + this.$domain;
    if (this.$secure) cookie += '; secure';

    // 下面设置Document.cookie属性来保存cookie  
    this.$document.cookie = cookie;
}


// 该函数是cookie对象的load()方法
Cookie.prototype.load = function() { 
    // 首先得到属于该文档的所有cookie的列表,
    // 通过读Document.cookie属性可以实现这一点.
    var allcookies = this.$document.cookie;
    if (allcookies == "") return false;

    // 下面从该列表中提取已命名的cookie.
    var start = allcookies.indexOf(this.$name + '=');
    if (start == -1) return false;   // 该页未定义cookie
    start += this.$name.length + 1;  // 跳过名字和等号.
    var end = allcookies.indexOf(';', start);
    if (end == -1) end = allcookies.length;
    var cookieval = allcookies.substring(start, end);

    // 既然我们已经提取出了已命名的cookie 的值,就可以把它分割存储到状态变量名和值.
 // 名字/值对由&分隔,名字和值之间则由冒号分隔.
 //我们使用split()方法解析所有数据.
    var a = cookieval.split('&');//a 表示一个数组了    // 分隔成名字/值对.
    for(var i=0; i < a.length; i++)  // 把每对值存入数组.
        a[i] = a[i].split(':'); //a表示二维数组

    // 既然我们已经解析了cookie值
    // 就可以设置cookie对象中的状态变量的名字和值.
    // 注意我们对属性值调用了unescape(),因为存储它们时调用了escape()方法.
    for(var i = 0; i < a.length; i++) {
        this[a[i][0]] = unescape(a[i][1]);  //a[][]参数从0开始.
    }

    // 返回成功
    return true;
}

// 该函数是cookie对象的remove() 方法.
Cookie.prototype.remove = function() {
    var cookie;
    cookie = this.$name + '=';
    if (this.$path) cookie += '; path=' + this.$path;
    if (this.$domain) cookie += '; domain=' + this.$domain;
    cookie += '; expires=Fri, 02-Jan-1970 00:00:00 GMT';

    this.$document.cookie = cookie;  //原来的被覆盖了.
}
function ShowPictures(_pics,_links,_width,_height,_src)
{
    var writeText = "<embed id=\"focus_flash1\" src=\""+_src+"\" wmode=\"opaque\" bgcolor=\"#FDD248\"";
    writeText += " FlashVars=\"pics=";
    writeText += _pics;
    writeText += "&links=";
    writeText += _links;
    writeText += "&borderwidth="+_width+"&borderheight="+_height+"\" ";
    writeText += "menu=\"false\" quality=\"high\"  width=\""+_width+"\" height=\""+_height+"\" ";
    writeText += " allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" ";
    writeText += " pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />";
    document.write(writeText);
}
//-->


//Tab切换
//说明：示例如下
//      <div>
//          <div><div>
//              <ul>
//                  <li onmouseout="javascript:clearShift()" onmouseover="javascript:startShift(this)"><a href="#">Tab标题一</a></li>
//                  <li onmouseout="javascript:clearShift()" onmouseover="javascript:startShift(this)"><a href="#">Tab标题二</a></li>
//              </ul>
//          </div></div>
//          <div>Tab标题一对应的内容</div>
//          <div>Tab标题二对应的内容</div>
//      </div>
var tm;
function startShift(o,s)
{      
    window.setTimeout2 = function(handle,minisecond,obj)
    {
        var arg = Array.prototype.slice.call(arguments,2);
        var cb =  handle;
        if(typeof(handle) == "function")
        {
	        cb = function()
	        {
		        handle.apply(null,arg);
	        }
        }
     
        return window.setTimeout(cb,minisecond);
    }
     switch(startShift.arguments.length)
        {
            case 1:
                var obj = o;
	            tm = window.setTimeout2(chShift,180,obj);
                break;
            case 2:
                var obj = o;
                var src = s;
	            chShiftIMG(obj,src);
                break;
        }
}

function clearShift()
{
    window.clearTimeout(tm);
}

function findA(obj)
{
	TagA=obj.getElementsByTagName("a");
	if (TagA.length>0)
		return TagA[0];

}

function findContentDIV(obj)
{
	TagDiv=obj.parentNode.parentNode.childNodes;
	var arrDiv = new Array;
	for(i=0;i<TagDiv.length;i++)
	{
		var objDiv = TagDiv[i];
		var re = /div/i;
		var arr = re.exec(objDiv.tagName);
		if(arr != null)
		{
			if(arr.index == 0)
			{
				arrDiv.push(objDiv);
			}
		}			 
	}
	return arrDiv;
}
function chShift(o)
{
    o.style.cursor="pointer";
	var t=o.parentNode;
	var tA=t.getElementsByTagName("a");
			
	var tParent=t.parentNode;
	var tParentDIV=findContentDIV(tParent);
	
	for(i=0;i<tA.length;i++)
	{	
		tA[i].className= null;			
		tParentDIV[i+1].style.display="none";
		if(tA[i]==findA(o))
		{
			tA[i].className="on";
			tParentDIV[i+1].style.display="block";
		}
	}
	
	
	if(tm != null)
	{
	    clearShift();
	    tm=null;
	}
} 

//切换后替换<a></a>中的图片路径
function chShiftIMG(o,s)
{
    o.style.cursor="pointer";
    var picName=["Free_BigBtn","ExamOnline_BigBtn","KB_BigBtn","LiveClass_BigBtn"];
	var t=o.parentNode;
	var tA=t.getElementsByTagName("a");
			
	var tParent=t.parentNode;
	var tParentDIV=findContentDIV(tParent);
	
	for(i=0;i<tA.length;i++)
	{	
	    tA[i].getElementsByTagName("img")[0].src="Themes/home0804/images/"+picName[i]+".gif";
		tParentDIV[i+1].style.display="none";
		if(tA[i]==findA(o))
		{
		    tA[i].getElementsByTagName("img")[0].src="Themes/home0804/images/"+s+"_on.gif";
			tParentDIV[i+1].style.display="block";
		}
	}
} 

function CosmosStart(vPath,file,realfile,page)
{
    var pageUrl=window.location.pathname;
    strEditorUrl=vPath+"HtmlEdit/CosmosStrip.aspx?f="+file+"&rf="+realfile+"&p="+page;
    var editWin= window.open(strEditorUrl,"页面编辑器", 'left=200,top=100, width=700,height=700,toolbars=0,resizable=1');
    editWin.focus();
}
function switchTag(tag,content,k,n,stylea,styleb)
{	
	for(i=1; i <=n; i++)
	{
		if (i==k)
		{
			document.getElementById(tag+i).className=stylea;
			document.getElementById(content+i).className="h_lsit_show";
		}else{
			document.getElementById(tag+i).className=styleb;
			document.getElementById(content+i).className="h_lsit_none";
		}
	}
}

function switchTagbeta(tag,content,k,n,stylea,styleb,astyle,aurlstr)
{	
	for(i=1; i <=n; i++)
	{
		if (i==k)
		{
			document.getElementById(tag+i).className=stylea;
			document.getElementById(content+i).className="h_lsit_show";
		}else{
			document.getElementById(tag+i).className=styleb;
			document.getElementById(content+i).className="h_lsit_none";
		}
	}
	document.getElementById(astyle).href = aurlstr;
}
function switch_Tag(tag,content,k)
{
	for(i=1; i < 4; i++)
	{
		if (i==k)
		{
			document.getElementById(tag+i).className="l1";
			document.getElementById(content+i).className="h_lsit";
		}else{
			document.getElementById(tag+i).className="l2";
			document.getElementById(content+i).className="h_lsit_none";
		}
	}
}

function changecontent(conid,num)
{
var tempcontent;
  for(i = 1;i<= num;i++)
     {
	 tempcontent = document.getElementById(conid+i).innerHTML;
	 document.getElementById(conid+i).innerHTML = document.getElementById((conid+i)+i).innerHTML;
	 document.getElementById((conid+i)+i).innerHTML = tempcontent;
	 }
}




function seccBoard(parentId,n,class1,class2)
{ 
 
 var sameL = document.getElementById(parentId).getElementsByTagName("li");
 var sameL_Text = document.getElementById(parentId+"_Text").getElementsByTagName("li");
 
 for(var i=0;i<sameL.length;i++)
 sameL[i].className=class1;
 sameL[n].className=class2;
 
 for(i=0;i<sameL_Text.length;i++)
 sameL_Text[i].style.display = "none";
 sameL_Text[n].style.display = "block";
 
}