// JavaScript Document
var capya ;
var now_img=1;
var now_newsmain=1;
var  nums ;
var stop_f=false;
var topstory_txt;
function open_mtmrules(){
window.open('torpak/index.php','mywin','width=540,height=319,toolbar=0,resizable=0');

}
function read_mtom(){
window.open('show_banleng.php','mywin','width=540,height=590,toolbar=0,scrollbars=1,resizable=0');
}
function livechannel(bit)
{
window.open('http://www.nationchannel.com/livechannel.php?bitrate='+bit,'mywin','width=700,height=580,toolbar=0,scrollbars=0,resizable=0');
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function get_capya()
{
new Ajax.Request('capchar.php', 
     {
 						method: 'POST',
						parameters : {page:'index'},
						onComplete:prove_capya
     }); 	
}
function prove_capya(capyatxt)
{
	var capyas = capyatxt.responseText ;
	var capyas2= new Array();
	capyas2=capyas.split('////');
	capya=capyas2[1];
	$('showcapyas').innerHTML=capyas2[0];
}
function send_mtom()
{
	 var msg1=$('mouth1').value;
	 var msg2=$('mouth2').value;
	 var name=$('names_mouth').value;
	 var capya_input=$('capya').value;
	 
	 if((msg1=='')||(msg2=='')||(name=='')||(capya_input=='')){
		alert('¡ÃØ³ÒãÊè¢éÍÁÙÅãËé¤Ãº¶éÇ¹¹Ð¤ÃÑº');      
	 }else if(capya!=capya_input){
		 alert('ÃËÑÊäÁèµÃ§¡ÑºÃÙ»¹Ð¤ÃÑº');      
	 }else{
		 //alert('ok');
		 send_msg_toserver(msg1,msg2,name,capya_input);
	 }
}
function send_msg_toserver(msg1,msg2,name,capya)
{
 new Ajax.Request('mouthtomouthinsert.php', 
     {
 						method: 'POST',
						parameters : {msg1:msg1,msg2:msg2,name:name,ip:ip,capya:capya},
						onLoading:  changeinner,
						onComplete:capyacomplete
     }); 	
}

function capyacomplete(rs)
{
	var rstxt=rs.responseText;
	//alert(rstxt);
	if(rstxt=='ok'){
			$('mouthtomouth').innerHTML='  <span class=F1>Insert Complete...</span>'; 	
			setTimeout("clearmsg()", 3000);
		          $('mouth1').value='';
				 $('mouth2').value='';
				 $('names_mouth').value='';
				 $('capya').value='';
			get_capya();
	}else{      
	$('mouthtomouth').innerHTML='  <span class=F1>Insert Not Complete...Please try again</span>'; 	     
	setTimeout("clearmsg()", 3000);
	$('capya').value='';
	get_capya();
	}

}
function changeinner()
{
$('mouthtomouth').innerHTML='<img src=images/loading.gif width=18>   <span class=F1>Loading..</span>   ';               
}
function clearmsg()
{
$('mouthtomouth').innerHTML='';	
}
function initImage(run_pic) {
  imageId = 'thephoto';
  image = document.getElementById(imageId);
  image.src= photo_gal[parseInt(run_pic)];
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}
function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  //obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
 
 
 
 // obj.style.opacity = opacity/100;
}
function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
	prove_page_pg();
  }
}

function next_img() {
now_img++;
if(now_img>max_photo){    
now_img=max_photo;  
}else{
initImage(now_img);
}
}

function prev_img() {
now_img--;
if(now_img<1){    
now_img=1;  
}else{
initImage(now_img);
}
}
function prove_page_pg()
{
	$('show_page_pg').innerHTML=	'<span class=F1><b>'+now_img+'</b> of <b>'+max_photo+'</b><span>' ;
}
function showtip()
{
new Tip('photoholder', title_gal[now_img],{
  title: 'Detail photo ',
 // style: 'protoblue',
	 border: 3,
   // borderColor: '#fff',
  hook: {target: 'topRight', tip: 'topLeft' ,mouse:'true'},
  offset: { x: 0, y: -10 },
  borderColor: '#c7c7c7',
  stem: 'topLeft',
    radius: 3

});
}
function show_breaking(tabname)
{
new Ajax.Request('breakingnews/getbreakings.php', 
     {
 						method: 'POST',
						parameters : {tab:tabname},
						onComplete:prove_breaking
     }); 	
		
}
function prove_breaking(rs)
{
    var rstxt=rs.responseText ;
	$('show_breaking').innerHTML=rstxt;
}
