﻿// JavaScript Document

 // Increase Font Size
function increaseFont(){ 
    var currentFontSize = $('#maincontents').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum - 3;
    if (newFontSize < 10)
    {
    	newFontSize = 10;
    }
    $('#maincontents').css('font-size', newFontSize);
    //createCookie('soifontsize', newFontSize, 365);
    return true; 
 
  } 
  // Decrease Font Size
  function decreaseFont(){
    var currentFontSize = $('#maincontents').css('font-size'); 
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum + 3;  
    $('#maincontents').css('font-size', newFontSize);
   // createCookie('soifontsize', newFontSize, 365);
  	return true;  
  } 	   
		
  function regs()
  {
	   var mtype     = $("#mtype").val();
	   var mname     = $("#mname").val();
	   var mpassswd  = $("#mpassswd").val();
	   var mpassswd2 = $("#mpassswd2").val();
	   var msex      = $("#msex").val();
	   var mage      = $("#mage").val();
	   var email     = $("#email").val();	 
	   var mtel      = $("#mtel").val();
	   var mfax      = $("#mfax").val();
	   var maddress  = $("#maddress").val();
	   var marea     = $("#marea").val();
	   
	 if(mname=="")
	 {
		 alert("Name can't for empty^_^");
		 return false;
	 }
	 var str = mname.replace(/[\\\/\:\?\*\<\>\|\"\=\']/g,'');
	 str = str.replace(/(^\s*)|(\s*$)/g,'');
	 if (!str.match(/[^0-9]/g)){
		alert("Name cannot pure figures^_^");
	 return false;
	 }
	 
	 if(mname.length<2 )
	 {
		 alert("In the name of length must 2 to 20 words^_^");
		 return false;
		 }
	 if(mname.length>20 )
	 {
		 alert("In the name of length must 2 to 20 words^_^");
		 return false;
	 }
	 if( mpassswd != mpassswd2 )
	 {
		alert("Two input password^_^");
		 return false;
	 }
	 if( mpassswd.length<6 || mpassswd.length>16 )
	 {
		 alert("Password length between 6 to 16^_^");
		 return false;
	 }
	 
	 var mtel = mtel.replace(/[\\\/\:\?\*\<\>\|\"\=\']/g,'');
	 mtel = mtel.replace(/(^\s*)|(\s*$)/g,'');
	 if(mtel.length>0)
	 {
		 if(mtel.length<6){
			 alert("The length of the wrong number^_^");				 
			 return false;
		 }
	 } 
	 
	 if(!isMail(email))
	 {
		alert("Your email format^_^");
		return false;
	 }
	 
	$.post("reg_s.php",{ mtype:mtype,mname:mname,mpassswd:mpassswd,msex:msex,mage:mage,email:email,mtel:mtel,mfax:mfax,maddress:maddress,marea:marea,action:"red_s" },send);
	 function send(text){			  
			 if(text==1)
			 {
				  mtype = $.trim( mtype );
				  if( mtype=="我要捐赠" )
				  {
					alert("Success, be submitted to the donation to enter the international pages！");
				    window.location="https://secure.specialolympics.org/site/apps/ka/sd/donorcustom.asp?c=mlIYIjNZJuE&b=5140039%20&msource={WDdoorg0609}";  
				  }else
				  {
				    alert("Registration renewal success！");
				    window.location="index.php";
				  }
			 }else
			 {
				 alert( text );
			 }
	 }	
	 
	 
  }
  
  
function isMail(name) // E-mail值检测
{ 
	if(!isEnglish(name))
	return false;
	i = name.indexOf("@");
	j = name.lastIndexOf("@");
	if(i == -1)
	return false;
	if(i != j)
	return false;
	if(i == name.length)
	return false;
	return true;
}

function isEnglish(name) //英文值检测
{ 
	if(name.length == 0)
	return false;
	for(i = 0; i < name.length; i++) { 
	if(name.charCodeAt(i) > 128)
	return false;
	}
	return true;
}

function search_news_en()
{
	 if (event.keyCode==13) 
	 {
		search_news(); 
	 }
}

function search_news()
{
   var key = $.trim( $("#key").val() );
   
   if(key !='' )
   {
     var url = "channel.php?ch1=xwzs&subcid=34&key="+encodeURI( key );
	 window.location = url;
   }else
   {
	   alert("Please enter the keywords");   
   }
   
}
//赞助商
function subzzs()
{
   if(!confirm("Determine submit？"))
   {
      return false;
   }
   
   var youname = $.trim( $("#youname").val() );
   var tel     = $.trim( $("#tel").val() );
   var email   = $.trim( $("#email").val() );
   var nation  = $.trim( $("#nation").val() );
   
   if( youname=="" )
   {
	     alert("Your name can't for empty^_^");
		 return false;
   }
   
   	 var tel = tel.replace(/[\\\/\:\?\*\<\>\|\"\=\']/g,'');
	 tel = tel.replace(/(^\s*)|(\s*$)/g,'');
	 if(tel.length>0)
	 {
		 if(tel.length<6){
			 alert("The length of the wrong number^_^");				 
			 return false;
		 }
	 } 
   
   if(!isMail(email))
   {
	  alert("Your email format^_^");
	  return false;
   } 
	$.post("dozzs.php",{ youname:youname ,tel:tel, email:email, nation:nation, action:"dozzzs" },send);
	function send(text){			  
			 if(text==1)
			 {
				  alert("Has been submitted to success! Thanks for your support! We will contact you as soon as possible!！");
				  window.location="index.php";
			 }else
			 {
				 alert( text );
			 }
	 }	 
}

//订阅
function dingyue()
{
   if(!confirm("Determine submit？"))
   {
      return false;
   }
   
   var name = $.trim( $("#name").val() );
   var tel     = $.trim( $("#tel").val() );
   var email   = $.trim( $("#email").val() );
   var nation  = $.trim( $("#area").val() );
   
   if( name=="" )
   {
	     alert("Your name can't for empty^_^");
		 return false;
   }
   
   	 var tel = tel.replace(/[\\\/\:\?\*\<\>\|\"\=\']/g,'');
	 tel = tel.replace(/(^\s*)|(\s*$)/g,'');
	 if(tel.length>0)
	 {
		 if(tel.length<6){
			 alert("The length of the wrong number^_^");				 
			 return false;
		 }
	 } 
   
   if(!isMail(email))
   {
	  alert("Your email format^_^");
	  return false;
   } 
   //检查邮箱是否已经订阅过了
    $.post("maillists.php",{ email:email, action:"checkemail" },sendcheck);
	function sendcheck(text){
		if( text==1 )
		{
		   alert("Your Email "+email+"Have subscribed. Thanks for your support。");	
		   window.location="index.php";
		   return false;
		}else
		{
		  
		  	 $.post("maillists.php",{ name:name ,tel:tel, email:email, nation:nation, action:"dodingyue" },send);
	function send(text){			  
			 if(text==1)
			 {
				  alert("Softcopies already subscribe to success! Thanks for your support!");
				  window.location="index.php";
			 }else
			 {
				 alert( text );
			 }
	 }
		  
		  
	    }
    }
   
	 
}

function frilist( id )
{ 
     for(var i=0;i<20;i++)
	 {
	    $('#list_'+i).hide(200); 
		$('#fri_title_'+i).css("color","#333333"); 
	 } 
	 
	 var cssstatus = $('#list_'+id).css("display");
     if(cssstatus=="none")
	 { 
		$('#list_'+id).show(200); 
		$('#fri_title_'+id).css("color","red"); 
	 }else
	 { 
		$('#list_'+id).hide(200); 
		$('#fri_title_'+id).css("color","#333333"); 
	 } 
	/* window.clearTimeout();
	 window.setTimeout("hideallfri()",5000);
	 window.clearTimeout();*/
	
}

function hideallfri()
{
     for(var i=0;i<20;i++)
	 {
	    $('#list_'+i).hide(200); 
		$('#fri_title_'+i).css("color","#333333"); 
	 }
}