﻿// JScript File
// JScript File
/*JS function for News Tools*/
agt= navigator.userAgent.toLowerCase();
is_ie	   = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
is_opera  = (agt.indexOf("opera") != -1);
is_mac	   = (agt.indexOf("mac") != -1);
is_mac_ie = (is_ie && is_mac);
is_win_ie = (is_ie && !is_mac);
is_gecko  = (navigator.product == "Gecko");
function playMediaSound(id,mtype){
    if(!id)return;
    if(typeof mtype=="undefined")mtype=0;
    var mediaURL=HOST_URL+'/contents/newstools/playmedia.aspx?id='+id+'&type='+mtype;
    popup(mediaURL,'',150,100,"no");
}
function popup(url, ext_url, w, h, scrollable){
	var popup, left, top, setting;
	left=screen.width?(screen.width-w)/2:0;
	top=screen.width?(screen.height-h)/2:0;
	setting="width=" + w + ",height=" + h + ", scrollbars=" + scrollable + ", dependent=yes, " + "top=" + top + ",left=" + left + "'";
	popup = window.open(url + ext_url,"DBMD",setting);
	if (popup.opener == null){ 
   		popup.opener = self; 
	}
}
function isEmail(emailStr){
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; 
	// not valid 
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; 
	// valid 
	if ( !reg1.test( emailStr ) && reg2.test( emailStr ) ) { 
		return true; 
	} else { 
		return false; 
	} 
}
function IsNumeric(ch){
	if (ch=="0"||ch=="1"||ch=="2"||ch=="3"||ch=="4"||ch=="5"||ch=="6"||ch=="7"||ch=="8"||ch=="9")return true;
	else return false;
}
function IsNumber(str){
	var i, ch;
	for (i=0; i<str.length; i++){
		ch = str.substring(i,i+1);
		if (!IsNumeric(ch))return false;
	}
	return true;
}

