// JavaScript Document


function changenews(srcData,divid){  // 變化留言類別
	var XMLHttpRequestObject = false;
	if (window.XMLHttpRequest){
		XMLHttpRequestObject = new XMLHttpRequest();
	}else if (window.ActiveXObject){
		XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if(XMLHttpRequestObject){
		XMLHttpRequestObject.open("GET", srcData);
		XMLHttpRequestObject.onreadystatechange = function(){
		if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200){
			document.getElementById(divid).innerHTML=XMLHttpRequestObject.responseText;
		}}
	XMLHttpRequestObject.send(null); 
	}
}

function secnavi(url,locations,divid,number){
	changenews(url+'.php?item='+locations,divid);
	for(i=1;i<=number;i++){
		document.getElementById("secnavi0"+i).className="secnavi0"+i;
	}
	document.getElementById("secnavi0"+locations).className="secnavi0"+locations+"m";
}

function news(locations,divid,num){
	if(locations=='6'){
	changenews('promote.php',divid);
	}else{
	changenews('news.php?newstype='+locations+'&num='+num,divid);
	}
	for(i=1;i<=6;i++){
		document.getElementById("secnavi0"+i).className="secnavi0"+i;
	}
	document.getElementById("secnavi0"+locations).className="secnavi0"+locations+"m";
}

function category(srcData,divid,number,locations){
	changenews(srcData,divid);
	for(i=1;i<=number;i++){
		document.getElementById("download-navi0"+i).className="download-navi0"+i;
	}
	document.getElementById("download-navi0"+locations).className="download-navi0"+locations+"m";
}

function changecategory(divid){
 for(i=1;i<9;i++){
 document.getElementById("div"+i).style.display="none";
 }
document.getElementById("div"+divid).style.display="";
}

function index(locations,divid){
	
switch (locations) {
    case 1:
        url="homefocus.php";
		break;
    case 2:
		url="homenews.php";
        break;
    case 3:
		url="homemap.php";
        break;
}
	changenews(url,divid);
	for(i=1;i<=3;i++){
		document.getElementById("index0"+i).className="index0"+i;
	}
	document.getElementById("index0"+locations).className="index0"+locations+"m";
}


function getweather(page){
 if(page=="all"){	
  document.getElementById("weather").style.display="none";
  document.getElementById("weather_all").style.display="";
 }else{
  document.getElementById("weather").style.display="";
  document.getElementById("weather_all").style.display="none";	 
 }
}

function realtime(locations){
	changerealtime(locations);
	for(i=1;i<=2;i++){
		document.getElementById("realtime0"+i).className="realtime0"+i;
	}
	document.getElementById("realtime0"+locations).className="realtime0"+locations+"m";
}

function changerealtime(divid){
 for(i=1;i<=2;i++){
 document.getElementById("div00"+i).style.display="none";
 }
document.getElementById("div00"+divid).style.display="";
}

function about(locations){
	changeaboutus(locations);
	for(i=1;i<=3;i++){
		document.getElementById("about0"+i).className="about0"+i;
	}
	document.getElementById("about0"+locations).className="about0"+locations+"m";
}

function changeaboutus(divid){
 for(i=1;i<=3;i++){
 document.getElementById("magazine0"+i).style.display="none";
 }
document.getElementById("magazine0"+divid).style.display="";
}

function service(locations,num){
	changeservive(locations,num);
	for(i=1;i<=num;i++){
		document.getElementById("service0"+i).className="service0"+i;
	}
	document.getElementById("service0"+locations).className="service0"+locations+"m";
}

function changeservive(divid,num){
 for(i=1;i<=num;i++){
 document.getElementById("service00"+i).style.display="none";
 }
document.getElementById("service00"+divid).style.display="";
}

function course(locations){
	changecourse(locations);
	for(i=1;i<=6;i++){
		document.getElementById("course0"+i).className="course0"+i;
	}
	document.getElementById("course0"+locations).className="course0"+locations+"m";
}

function changecourse(divid){
 for(i=1;i<=6;i++){
 document.getElementById("position0"+i).style.display="none";
 }
document.getElementById("position0"+divid).style.display="";
}

function target(locations,url,divid){
	changenews('page03_content.php?val='+url,divid);
	for(i=1;i<=7;i++){
		document.getElementById("thnavi0"+i).className="thnavi0"+i;
	}
	document.getElementById("thnavi0"+locations).className="thnavi0"+locations+"m";
}

function tynews(locations,url,divid){
	changenews('page06_content.php?types='+url,divid);
	for(i=1;i<=2;i++){
		document.getElementById("thnavi0"+i).className="thnavi0"+i;
	}
	document.getElementById("thnavi0"+locations).className="thnavi0"+locations+"m";
}

function predict(locations,url,divid){
	changenews('page04_'+url+'.php',divid);
	for(i=1;i<=3;i++){
		document.getElementById("thnavi0"+i).className="thnavi0"+i;
	}
	document.getElementById("thnavi0"+locations).className="thnavi0"+locations+"m";
}

function info(locations,url,divid){
	changenews('page05_'+url,divid);
	for(i=1;i<=8;i++){
		document.getElementById("thnavi0"+i).className="thnavi0"+i;
	}
	document.getElementById("thnavi0"+locations).className="thnavi0"+locations+"m";
}

function typhoon(num,locations,divid){
	if(num=='6'){
	location.href="http://map.tenki.tw";
	}else{
	changenews('page0'+locations+'.php',divid,num);
	}
	for(i=1;i<=6;i++){
		document.getElementById("secnavi0"+i).className="secnavi0"+i;
	}
	document.getElementById("secnavi0"+num).className="secnavi0"+num+"m";
}


function news1(locations,divid,num,date){
	if(locations=='6'){
	changenews('promote.php',divid);
	}else{
	changenews('news.php?newstype='+locations+'&num='+num+'&setdate='+date,divid);
	}
	for(i=1;i<=6;i++){
		document.getElementById("secnavi0"+i).className="secnavi0"+i;
	}
	document.getElementById("secnavi0"+locations).className="secnavi0"+locations+"m";
}

function openall(){
	document.getElementById("focus_all").style.display="";
	document.getElementById("focus_part").style.display="none";	
}

function closeall(){
	document.getElementById("focus_part").style.display="";
	document.getElementById("focus_all").style.display="none";
}

function newstoplurk(){
	plurkstr=document.getElementById("short_text").innerHTML;
	untagplurkstr=RemoveAH(plurkstr);
	untagplurkstr=untagplurkstr.substr(0,95);
	untagplurkstr='@itenki: [天氣]' + untagplurkstr + 'http://www.tenki.tw (...more)'
	enplurkstr=encodeURI( untagplurkstr );
	url='http://www.plurk.com/?qualifier=shares&status='+enplurkstr;
	window.open(url,'new');
}
function RemoveAH ( strText ){
    var regEx = /(<a[^>]*>)|(<[^>]a>)/g;
    var regExB = /(<A[^>]*>)|(<[^>]A>)/g;
    A = strText.replace(regEx, "");
	return A.replace(regExB, "");
}
function aboutus(url,locations,divid,number){
	changenews(url+'.php',divid);
	for(i=1;i<=number;i++){
		document.getElementById("secnavi0"+i).className="secnavi0"+i;
	}
	document.getElementById("secnavi0"+locations).className="secnavi0"+locations+"m";
}
function fbs_click(){
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent('http://www.tenki.tw/facebook/index_video.php')+'&t='+encodeURIComponent(t)+ new Date().getTime(),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}







