function GetId(id)
{
	return document.getElementById(id);
}
//获取对象y坐标
function getY(e)
{
 var   obj   =   e; 
 var   getTop   =   obj.offsetTop;
 while(obj   =   obj.offsetParent) 
 {
    getTop   +=   obj.offsetTop;  
 }
 return getTop;
}
//获取对象x坐标
function getX(e)
{
 var   obj   =   e; 
 var   getLeft   =   obj.offsetLeft; 
 while(obj   =   obj.offsetParent) 
 {
    getLeft   +=   obj.offsetLeft; 
 }
 return getLeft;
}
	//--------------------
//图片交换
//--------------------
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//bottom logo
/*function bottom_logo_init(){

	GetId("bottom_logo").style.left=(getX(GetId("footer"))-54)+"px";
	GetId("bottom_logo").style.top=getY(GetId("footer"))+"px";
	GetId("bottom_logo").style.visibility="visible";
}

if(window.attachEvent){
	 window.attachEvent("onload",bottom_logo_init);
	 window.attachEvent("onresize",bottom_logo_init);
}else if(window.addEventListener){
	 window.addEventListener('load',bottom_logo_init,  false);
	 window.addEventListener('resize',bottom_logo_init,  false);
}
*/
function display_news(obj){
	location.href='About_us_news.php?news_date=2010-11';
	document.getElementById(obj).style.display='none';
}

 /*function createRequest(){
        var httpRequest;
        if (window.XMLHttpRequest) {
            httpRequest = new XMLHttpRequest();
        }
        else 
            if (window.ActiveXObject) {
                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
            }
        return httpRequest;
}*/

/*function replaceTable(obj){

        var req = createRequest();
        req.open('GET', 'news_content.php?news_id='+obj+'', true);
        req.send(null);
        req.onreadystatechange = function(){
            if (req.readyState == 4) {
				//alert(req.responseText);
				//arrOption=eval('('+req.responseText+')');
				//countForld=arrOption.length;
				//var fragment=buildFragment(arrOption);
				document.getElementById("news_content").innerHTML=req.responseText;
				bottom_logo_init();
            }
        }
    }*/
	
function GetID(obj){
	return document.getElementById(obj);
}

function displayOrHidden(meval,url1,url2){
	var left_n=GetID(meval);
	if(left_n.style.display=="none"){
		left_n.style.display="block";
		GetID("img_"+meval).src=url2;
	}else{
		left_n.style.display="none";
		GetID("img_"+meval).src=url1;
	}
}

function displayError(){
	$('#subscribe_notes').html("");
}

function subscribe_email(){
	var subscribe_email=$('#subscribe_email').val();
	if(subscribe_email==""){
		return;
	}
	 var   sReg   =   /[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/;   
	  if   (   !   sReg.test(subscribe_email)   )   
	  {   	
	  		$('#subscribe_notes').show();
	  		$('#subscribe_notes').html("Invalid Email Address");
	  return   false;   
	  }else{
		  $.get("subscribe_email.php", { subscribe_email: subscribe_email },
			  function(data){
				$('#subscribe_notes').show();  
				  $('#subscribe_notes').html("Subscription completed");
				  $('#subscribe_email').val("");

		 			 return   true;   
			  });
		
	  }
		  
}

function changecolor(obj){
	$("#gmap_large").css("color","#8CBC3A");
}

function changecolor1(obj){
	$("#gmap_large").css("color","#333333");
}

// JavaScript Document
function checkreg(){

	var media = $("#media").val();
	if(media==""){
		return false;
	}	
	var city = $("#city").val();
	if(city==""){
		return false;
	}
	var country = $("#country").val();
	if(country==""){
		return false;
	}
	var sex = $("#sex").val();
	if(sex==""){
		return false;
	}
	var firstname = $("#firstname").val();
	if(firstname==""){
		return false;
	}
	var lastname = $("#lastname").val();
	if(lastname==""){
		return false;
	}
	var position = $("#position").val();
	if(position==""){
		return false;
	}
	var tel = $("#tel").val();
	/*if(tel!=""){
		return false;
	}*/
	var fax = $("#fax").val();
	/*if(fax!=""){
		return false;
	}*/
	var mobile = $("#mobile").val();
	/*if(mobile!=""){
		return false;
	}*/
	var email = $("#email").val();
	if(email==""){
		return false;
	}
	var arrival_date = $("#arrival_date").val();
	/*if(arrival_date!=""){
		alert(arrival_date);
	}*/
	var departure_date = $("#departure_date").val();
	/*if(departure_date!=""){
		alert(departure_date);
	}*/
	var hotel_name = $("#hotel_name").val();
/*	if(hotel_name!=""){
		alert(hotel_name);
	}*/
	var username = $("#username").val();
	if(username==""){
		return false;
	}
	var password = $("#password").val();
	if(password==""){
		return false;
	}
	$.get("pressreg.php", { media: media, city: city,country:country,sex:sex,firstname:firstname, lastname:lastname,position:position,tel:tel,fax:fax,mobile:mobile,email:email,arrival_date:arrival_date,departure_date:departure_date,hotel_name:hotel_name,username:username,password:password},
   		function(data){

				window.location.href="press_release.php";

   		});
}
function checklogin(obj){

	var username = $("#username").val();
	if(username==""){
		$("#press_login_error").html("Username can not be empty!");
		return false;
	}
	
	var password = $("#password").val();
	if(password==""){
		$("#press_login_error").html("Password can not be empty!");
		return false;
	}
	$.get("checklogin.php", { username: username, password: password},
   		function(data){
				//alert(data);
				if(data=="success"){
					window.location.href="press_release.php";
				}else if(data=="error"){
					$("#press_login_error").html("Username or Password does not exist, please re-enter!!");
					return false;
				}
				
   		});
	return false;
}

function mouseOver(obj){
	document.getElementById(obj.id+"_icon").src ="images/right_red.jpg"
}

function mouseOut(obj){
	document.getElementById(obj.id+"_icon").src ="images/right_black.jpg"
}

function city_select_is_other(obj){
	var country = obj.value;
	$.get("city.php", { country: country},
   		function(data){
			
			$("#city_space").html(data);
			
   		});
	
}

function delUpload(file) {
	//alert(file);
	document.getElementById('show_'+file).style.display='none';
	document.getElementById(file).value='';
}

function delBackUpload(file) {
	//alert(file);
	arr=file.split("|");
	
	document.getElementById('show_'+arr[0]).className='b_none';
	document.getElementById(arr[0]).value='';
	$.get("del_press_image.php", { upload_name: arr[2], upload_path: arr[1] } );
}

