﻿function ShowProfile(szID)
{
	//var szURl = "TeacherProfile.aspx?ID=" + szID;
	//popWin (szURl, "Profile", 738, 600, 1);
	
	var szRoot = location.href.toLowerCase();
	var szUrl = "./";
	
	if (szRoot.indexOf('/myzone/') > 0)
		szUrl = "../";
	else if (szRoot.indexOf('/teacherzone/') > 0)
		szUrl = "../";
	else if (szRoot.indexOf('/admin/') > 0)
		szUrl = "../";
	else if (szRoot.indexOf('/forum/') > 0)
		szUrl = "../";
	else if (szRoot.indexOf('/help/') > 0)
		szUrl = "../";
	else if (szRoot.indexOf('/login/') > 0)
		szUrl = "../";
	else if (szRoot.indexOf('/member/') > 0)
		szUrl = "../";
	else if (szRoot.indexOf('/trans/') > 0)
		szUrl = "../";
	//alert (szUrl + "Teacher.aspx?ID=" + szID);
	location =  szUrl + "Teacher.aspx?ID=" + szID;
	
}

function popWin(mypage, myname,  w, h, scroll) {
	//var scroll=1;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=0,status=1'
	win = window.open (mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function popWin1(mypage, myname,  w, h, scroll) {
	//var scroll=1;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=0,status=0'
	win = window.open (mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}



function ShowDocument(ID)
{
    var szUrl = "../../Templates/ShowDocument.aspx?DocID=" + ID +"&r=" + (Math.random() * 100) ;
	popWin1(szUrl, "ShowDoc", 700, 500, 0);
}

function ShowDocument1(ID)
{
    var szUrl = "Templates/ShowDocument.aspx?DocID=" + ID +"&r=" + (Math.random() * 100) ;
	popWin1(szUrl, "ShowDoc", 700, 500, 0);
}

function ShowDocViewLogDetails(ID)
{
    location = "DocViewLogDetails.aspx?ID=" + ID  +"&r=" + (Math.random() * 100) ;
}

function BuyCourse(ID, Cat)
{
	var szUrl = "Trans/BuyCourse.aspx?ID=" + ID + "&Cat=" + Cat;
	popWin(szUrl, "BuyCouse", 700, 500, 1);
}

function ViewCourse(ID, StartPos)
{
	var szUrl = "../Templates/Play.aspx?CourseID=" + ID + "&VType=VOD&StartTime="+ StartPos +"&r=" + (Math.random() * 100) ;
	popWin1(szUrl, "ViewCourse", 700, 500, 0);
}

function ViewCourse1(ID, StartPos)
{
	
	var szUrl = "Templates/Play.aspx?CourseID=" + ID + "&VType=VOD&StartTime="+ StartPos +"&r=" + (Math.random() * 100) ;
	popWin1(szUrl, "ViewCourse", 700, 500, 0);
}

function ViewCourse2(ID, StartPos)
{
	var szUrl = "../../Templates/Play.aspx?CourseID=" + ID + "&VType=VOD&StartTime="+ StartPos +"&r=" + (Math.random() * 100) ;
	popWin1(szUrl, "ViewCourse", 700, 500, 0);
}

function PreviewCourse(ID, StartPos)
{
	
	ViewCourse1(ID, StartPos);
	//var szUrl = "Templates/Play.aspx?CourseID=" + ID + "&VType=VOD&StartTime="+ StartPos +"&r=" + (Math.random() * 100) ;
	//popWin(szUrl, "ViewCourse", 700, 500, 0);
}


function RememberPWD()
{
	var szUrl = "RememberPassword.aspx"
	popWin(szUrl, "RememberPassword", 450, 270, 1);
}

function RememberPWD1()
{
	var szUrl = "../RememberPassword.aspx"
	popWin(szUrl, "RememberPassword", 450, 270, 1);
}

function ExchangeCupon(CuponNo, ChapterID)
{
	
	var szUrl = "ExchangeCupon.aspx?CuponNo=" + CuponNo + "&ChapterID=" + ChapterID + "&r=" + (Math.random() * 100);
	popWin(szUrl, "ExchangeCupon", 500, 450, 1);
	
}

function showhidepicture(oLink, szPicID)
{
	var oPic = document.getElementById(szPicID);	
	if (oPic)
	{
		if (oPic.style.display == "")
		{
			oPic.style.display =  "none";
			oLink.innerText = "顯示圖示";
		}
		else
		{
			oPic.style.display =  "";
			oLink.innerText = "隱藏圖示";
		}
	}
}

function IsValidBrowserVersion()
{
	//Detect IE5.5+
	var iVersion = 0;

	if (navigator.appVersion.indexOf("MSIE")!=-1)
	{
		var temp = navigator.appVersion.split("MSIE");
		iVersion=parseFloat(temp[1]);
	}

	return (iVersion >= 5.5);
		
}

function BuyPoints()
{
	popWin ("../Trans/BuyPoints.aspx", "WndTrans", 700, 500, 0);
}


function AttachEvent(obj, eventName, handler) 
{
	if ( document.attachEvent ) 
	{
		// MSIE only, event names always start with "on" (onload, onerror, etc)
		obj.attachEvent(eventName, handler);	
	} 
	else if ( document.addEventListener ) 
	{
		// Mozilla only, parse leading "on" off of event names (load, error, etc)
		obj.addEventListener(eventName.substring(2, eventName.length), handler, false);	
	} 
	else 
	{
		eval(obj.id + "." + eventName + " = " + handler);
	}
}

function fGetXY(obj)
{	
	
	
	var oPos = new Point();
	var oTmp = obj; 
	
	while (oTmp.tagName != "BODY")
	{
		oPos.x += oTmp.offsetLeft;
		oPos.y += oTmp.offsetTop;
		oTmp = oTmp.offsetParent;
	}
	return oPos;
}


function Point()
{
	this.x = 0;	this.y = 0;
}
