function Finish()
{
	alert("Finish!");
}
function Hello()
{
	alert("Hello");
}
function OpenFullScreen(href, windowname)
{
	alert(" Press Alt-F4 to exit full screen\n You might need to turn Pop-Up Blocker off to see this page.");	
	window.open(href, windowname, ',type=fullWindow,fullscreen,scrollbars=yes');
}
function openWin(url, w, h) 
{ 
	var winprop = "width=" + w + ",height=" + h + ",toolbar=no,scrollbars=no,menubar=no"; 
	window.open(url,'',winprop); 
} 
function openNewWin(url) 
{ 
	window.open(url); 
} 
function MuteFlash()
{		
	var url = "<a href='javascript:BindFlash();'>Click here to reload content.</a> ";
	if (document.getElementById("flashcontent") != null)
	{
		var content = document.getElementById("flashcontent");
		content.innerHTML = url;
	}									
}
function OpenHomework(OpenUrl, HomeworkTitle)
{	
	var closelink = "&nbsp;/&nbsp;<a href='#' class='lightwindow_action' rel='deactivate'><font color='white'>close</font></a>";
	HomeworkTitle = HomeworkTitle + closelink;
	
	if (document.getElementById("flashcontent") != null)
	{
		MuteFlash(); //on Lesson.aspx
	}	
	if (document.getElementById("PopUpBBSDialog") != null)
	{
		CloseDialog(); //on MyClass.aspx
	}
	if (HomeworkTitle == undefined)
	{
		HomeworkTitle = "Assignment";
	}
	
	myLightWindow.activateWindow({	        
							href: OpenUrl, 	        
							title: HomeworkTitle,
							width:760, 	        
							height:480
							});
}	
function OpenHomeworkDetail(OpenUrl, HomeworkTitle)
{
	var closelink = "&nbsp;/&nbsp;<a href='#' class='lightwindow_action' rel='deactivate'><font color='white'>close</font></a>";
	HomeworkTitle = HomeworkTitle + closelink;
	
	myLightWindow.activateWindow({	        
							href: OpenUrl, 	        
							title: HomeworkTitle,
							width:760, 	        
							height:480
							});
}
function OpenPreviewWin(OpenUrl, HeaderTitle)
{
	openWin(OpenUrl, 1000, 720);
	//OpenFullScreen(OpenUrl, "Homework");
	/*myLightWindow.activateWindow({	        
							href: OpenUrl, 	        
							title: HeaderTitle,
							width:1000, 	        
							height:720
							});*/
}			
function OpenLessonRecording(LessonID, AccountID, LessonTitle)
{
	var strServerHostIP = document.getElementById("hdnServerHostIP").value;	
	var strMediaServerName = document.getElementById("hdnMediaServerName").value;
	var strCultureName = document.getElementById("hdnCultureName").value;	
	var OpenUrl = "LessonRecording/ReadAlong.htm?LessonID=" + LessonID + "&CultureName=" + strCultureName + "&AccountID=" + AccountID + "&ServerHostIP=" + strServerHostIP + "&MediaServerName=" + strMediaServerName;
	//window.open(OpenUrl);
	if (document.getElementById("hdnFlashUrl") != null)
	{
		MuteFlash(); 
	}
	myLightWindow.activateWindow({	        
							href: OpenUrl, 	        
							title: LessonTitle
							});
}

function OpenReadAlong(LessonID, AccountID, LessonTitle, CultureName, AssignID)
{
	/*
	var strServerHostIP = document.getElementById("hdnServerHostIP").value;	
	var strMediaServerName = document.getElementById("hdnMediaServerName").value;
	var strCultureName = document.getElementById("hdnCultureName").value;	
	var OpenUrl = "LessonRecording/ReadAlong.htm?LessonID=" + LessonID + "&CultureName=" + strCultureName + "&AccountID=" + AccountID + "&ServerHostIP=" + strServerHostIP + "&MediaServerName=" + strMediaServerName;
	*/
	var OpenUrl = "ReadAlong.aspx?LessonID=" + LessonID + "&CultureName=" + CultureName + "&AccountID=" + AccountID + "&AssignID=" + AssignID;
	//window.open(OpenUrl);
	if (document.getElementById("hdnFlashUrl") != null)
	{
		MuteFlash(); 
	}
	myLightWindow.activateWindow({	        
							href: OpenUrl, 	        
							title: LessonTitle
							});
}
function ShowMediaRecording(PackageID, CourseID, LessonID, AccountID, Type, LessonTitle, AssignID)
{
	var url = "Lesson.aspx?PackageID=" + PackageID + "&CourseID=" + CourseID + "&LessonID=" + "&ShowMediaRecord=true&MediaRecordingType=" + Type + "&AssignID=" + AssignID;
	location.href = url;
}

function SeeStudentMediaRecording(RecordID, LessonID, AccountID, Type, LessonTitle, AssignID)
{
	var strServerHostIP = document.getElementById("hdnServerHostIP").value;	
	var strMediaServerName = document.getElementById("hdnMediaServerName").value;
	var strCultureName = document.getElementById("hdnCultureName").value;
	
	var OpenUrl = "MediaRecording.aspx?LessonID=" + LessonID + "&Type=" + Type + "&CultureName=" + strCultureName + "&AccountID=" + AccountID + "&ServerHostIP=" + strServerHostIP + "&MediaServerName=" + strMediaServerName + "&RecordID=" + RecordID + "&AssignID=" + AssignID;
	
	location.href = OpenUrl;
	
}
function OpenMediaRecording(RecordID, LessonID, AccountID, Type, LessonTitle, AssignID)
{
	
	var strServerHostIP = document.getElementById("hdnServerHostIP").value;	
	var strMediaServerName = document.getElementById("hdnMediaServerName").value;
	var strCultureName = document.getElementById("hdnCultureName").value;
	
	var OpenUrl = "MediaRecording.aspx?LessonID=" + LessonID + "&Type=" + Type + "&CultureName=" + strCultureName + "&AccountID=" + AccountID + "&ServerHostIP=" + strServerHostIP + "&MediaServerName=" + strMediaServerName + "&RecordID=" + RecordID + "&AssignID=" + AssignID;
	
	if (document.getElementById("hdnFlashUrl") != null)
	{
		MuteFlash(); 
	}
	myLightWindow.activateWindow({	        
							href: OpenUrl, 	        
							title: LessonTitle
							});
							
}

function SeeStudentReadAlong(RecordID, AccountID, Title)
{
	
	var strServerHostIP = document.getElementById("hdnServerHostIP").value;	
	var strMediaServerName = document.getElementById("hdnMediaServerName").value;
	OpenUrl = strServerHostIP + "LessonRecording/LessonRecordingReview.htm?RecordID=" + RecordID + "&AccountID=" + AccountID + "&ServerHostIP=" + strServerHostIP + "&MediaServerName=" + strMediaServerName;

	location.replace(OpenUrl);
}
function OpenLessonRecordingReview(RecordID, AccountID, Title)
{
	
	var strServerHostIP = document.getElementById("hdnServerHostIP").value;	
	var strMediaServerName = document.getElementById("hdnMediaServerName").value;
	OpenUrl = strServerHostIP + "LessonRecording/LessonRecordingReview.htm?RecordID=" + RecordID + "&AccountID=" + AccountID + "&ServerHostIP=" + strServerHostIP + "&MediaServerName=" + strMediaServerName;

	myLightWindow.activateWindow({	        
							href: OpenUrl, 	        
							title: Title
							});
}
function doleave(IsLeave)
{
	document.getElementById("Ctrl_Header_hdnLeave").setAttribute("value", IsLeave);
}

function ProductKeywordSearch()
{
	var strKeyword = document.getElementById("txtKeyword").value;	
	//var strKeyword = document.getElementById("txtKeyword").getAttribute("value").toString();
	if (strKeyword != "")
	{
		var strOpenUrl = "http://www.betterchinese.com/ProductKeywordSearch.aspx?Keywords=" + strKeyword;
		location.replace(strOpenUrl);
	}
}

function SearchClicked()
{
	
	var siteSearchPrefix = document.getElementById("Ctrl_Footer_hdnSiteSearchPrefixUrl").value;
	var strKeyword = document.getElementById("Ctrl_Footer_txtSiteSearchKeyWords").value;
	if (strKeyword != "")
	{		
		var strOpenUrl = siteSearchPrefix + strKeyword;
		window.open(strOpenUrl,'','');
	}
}

function RedirectPage(PageUrl)
{
	if (PageUrl != "")
	{
		location.replace(PageUrl);
	}
}
	
function WebLogout(Level)
{
	//if (document.getElementById("hdnLanguageIndexChange").getAttribute("value") != "false")
	//{
		if (Level == 0)
		{
			alert("Logout");			
			//window.open("www.msn.com.tw","","location=no,toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=no,width=150,height=200");
			//window.open("Logout.aspx","","location=no,toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=no,width=150,height=200");
		}
	//}
}	

function SetFocusOnControl()
{
	if (document.getElementById("hdnSetFocus").value != "txtUserName")
	{
		if (document.getElementById("txtPassword") != null)
		{
			document.getElementById("txtPassword").focus();
		}
	}
	else
	{
		if (document.getElementById("txtUserName") != null)
		{
			document.getElementById("txtUserName").focus();
		}
	}
	/*
	if (document.getElementById(ControlName) != null)
	{
		document.getElementById(ControlName).focus();
	}*/
}

function SetFocusOn(ControlName)
{
	if (document.getElementById(ControlName) != null)
	{
		document.getElementById(ControlName).focus();
	}
}

function ShowErrMsg()
{

	var strErrMsg = document.getElementById("hdnErrMsg").value;
	if ((strErrMsg != "") && (strErrMsg != null))
	{
		document.getElementById("hdnErrMsg").setAttribute("value", "");
		alert(strErrMsg);					
	}
}


// This function parses the userAgent string returned from
// navigator.appVersion.  For example it may contain something
// like this:
// Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; COM+ 1.0.2204)
// So in this case you would call it as follows:
//      CheckBrowsere("MSIE", 5.5);
function CheckBrowser(name, version)
{    
    var sub = navigator.userAgent;
    var p = sub.indexOf(name);
    var v = 0;
    if (p > 0) {
        var q = sub.indexOf(";",p);
        var str = sub.substr(p,q-p);
        var sa = str.split(" ");
        if (sa.length > 1) {
            v = parseFloat(sa[1]);
        }
    }
    if (p < 0 || v < version) {
    	document.open();
    	document.write("<b><font color=red>ERROR: this sample requires " + name + " version " + version + " or higher.</font></b>");
    	document.close();
    }
}

function LaunchWindow(winurl,winname,winfeatures)
{
	window.open(winurl,winname,winfeatures);
}

function CheckCookieEnabled()
{			
	testCookie = navigator.cookieEnabled;
	
	if (testCookie)
	{
		//var mystr = "cookie upport!";
		//alert(mystr);					
	}
	else
	{
		//var mystr = "cookie not upport!";
		//alert(mystr);
		var WarningWin = window.open("http://www.betterchinese.com/BCWeb4SysAdmin/warning/nocookiesupported.htm", "Warning4NoCookie", "left=100, top=100, location=no,toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=no,width=320,height=375,dependent=yes,alwaysRaised=yes");
		if(WarningWin != null)
		{
			WarningWin.focus();
		}
	}
}

function SeeDifferent()
{
	var url="http://www.betterchinese.com/Difference.htm";
	openWin(url, '400', '150');
}

function PrintThisPage()
{
	print();
	/*if (document.getElementById(ControlName) != null)
	{
		ControlName.print();
	}*/
}
function SetClientTimeZone()
{
	offsetDate = new Date();
	offset = -(offsetDate.getTimezoneOffset()/60);
	document.getElementById("hdnClientTimeZone").setAttribute("value", offset);
}


/*using (div+css+js) to make a round table
	<!--Sample-->
	<div style="z-index:1;position:absolute;left:0;top:0;display:none;" id="test">
		<div style='text-align:center;line-height:28px;'>123456</div>
	</div>
	<div>
		<div style="float:left;margin-left:10px;"><script>div_round_model(60,30,"#cf3","#fff",10,"1px solid #999","123456",1);</script></div>
		<div style="float:left;margin-left:10px;"><script>div_round_model(160,30,"#cfd","#fff",30,"1px solid #999","<div style='text-align:center;'>123456</div>",2);</script></div>
		<div style="float:left;margin-left:10px;"><script>div_round_model(160,30,"#fff","#fff",15,"1px dotted red",document.getElementById("test").innerHTML,3);</script></div>
	</div>
*/
function div_round_model(div_width,div_height,div_bgcolor,div_parent_bgcolor,div_r,div_border_style,div_content,id)
{
  document.write('<style type="text/css"><!--');
  document.write('.div_RoundedCorner_model_'+id+'{position:relative;width:'+div_width+'px;height:'+div_height+'px;background-color:'+div_bgcolor+';}');
  document.write('.div_RoundedCorner_model_border_'+id+'{border:'+div_border_style+';width:'+(div_width-2)+'px;height:'+(div_height-2)+'px;}');
  document.write('.Rounded_left_'+id+',.Rounded_right_'+id+'{height:1px;border-right:'+div_border_style+';background:'+div_parent_bgcolor+';position:absolute;z-index:1;}');
  document.write('.Rounded_right_'+id+'{border:0;border-left:'+div_border_style+';right:0;}');
  document.write('.div_RoundedCorner_model_content_'+id+'{width:'+(div_width-2)+'px;height:'+(div_height-2)+'px;left:5px;top:2px;z-index:2;position:absolute;}');
  document.write('//--></style>');
  
  document.write('<div class="div_RoundedCorner_model_'+id+'">');
  document.write('<div class="div_RoundedCorner_model_border_'+id+'"></div>');
  document.write('<div class="div_RoundedCorner_model_content_'+id+'">'+div_content+'</div>');
  for(i=1;i<=div_r;i++){
    document.write('<div class="Rounded_left_'+id+'" style="width:'+(div_r-Math.sqrt((2*div_r-i)*i))+'px;left:0;top:'+(i-1)+'px;"></div>');
    document.write('<div class="Rounded_left_'+id+'" style="width:'+(div_r-Math.sqrt((2*div_r-i)*i))+'px;left:0;bottom:'+(i-1)+'px;"></div>');
    document.write('<div class="Rounded_right_'+id+'" style="width:'+(div_r-Math.sqrt((2*div_r-i)*i))+'px;top:'+(i-1)+'px;"></div>');
    document.write('<div class="Rounded_right_'+id+'" style="width:'+(div_r-Math.sqrt((2*div_r-i)*i))+'px;bottom:'+(i-1)+'px;"></div>');
  }
  document.write('</div>');
}

function DoSessionTimeOut()
{
	var Message = "You have been inactive for 60 minutes. For security reasons, you will be logged out automatically. Click 'Yes' to continue.";
	var LoginUrl = "Login.aspx";
	alert(Message);
	location.replace(LoginUrl);
}

function DoPopupSessionTimeOut()
{
	var Message = "You have been inactive for 60 minutes. For security reasons, you will be logged out automatically. Click 'Yes' to continue.";
	alert(Message);
	parent.myLightWindow.deactivate();
}

function ShoppingProcess(Action, OnlineOrderID, Quantity, Price)
{
		var strUrl = "../ShoppingProcess.aspx?Action=" + Action + "&ProductID=" + OnlineOrderID + "&Quantity=" + Quantity + "&Price=" + Price;
		location.replace(strUrl);
}

function OpenPlanIntroVideo()
{
	//	
	//
	myLightWindow.activateWindow({	        
						href: 'Upload/BCWeb4Content/OLP/Index.htm',
						title: 'Online Lesson Planner'
						});
							
}
function OpenActivityDownload(url)
{
	var blnIsableDownloadAT = "false";
	if (document.getElementById("hdnIsableDownloadAT") != null)
	{
		blnIsableDownloadAT = document.getElementById("hdnIsableDownloadAT").value;
	}
	if (blnIsableDownloadAT != "true")
	{
		myLightWindow.activateWindow({	        
						href: url,
						title: 'Activity Templates Download',
						width:745,
						height:500
						});
	}
	else
	{
		openWin(url, 200, 50);
	}
}

function Banner1Click()
{
	ClosePromotionBanner();
	var url = "Trailer.aspx";
	
	myLightWindow.activateWindow({	        
						href: url,
						title: 'Happy Chinese New Year',
						width:740,
						height:520
						});
						
	/*openWin(url, 800, 600)*/
}
function Banner1jClick()
{
	ClosePromotionBanner();
	var url = "Trailer.aspx";
	
	myLightWindow.activateWindow({	        
						href: url,
						title: 'Happy Chinese New Year',
						width:740,
						height:520
						});
						
	/*openWin(url, 800, 600)*/
}
function Banner1fClick()
{
	ClosePromotionBanner();
	var url = "Trailer.aspx";
	
	myLightWindow.activateWindow({	        
						href: url,
						title: 'Happy Chinese New Year',
						width:740,
						height:520
						});
						
	/*openWin(url, 800, 600)*/
}