﻿var currentId;

function showLayer(objId){
	if (objId == currentId){
		if ($("#"+objId).css("display") == "block"){
			hideDiv(objId);
			currentId = "";
		}
		else{
			showDiv(objId);
			currentId = objId;
		}
	}else{
		if((currentId) && (currentId != ""))
			hideDiv(currentId);
		showDiv(objId);
		currentId = objId;
	}
}

function showDiv(objId){
	$("#"+objId).addClass("showDiv");
	$("#"+objId).removeClass("hideDiv");
	$("#"+objId+"detail").css("display","block");
	$("#"+objId+"btn").css("background","center url('images/about/btn_down.gif') no-repeat");	
}

function hideDiv(objId){
	$("#"+objId).addClass("hideDiv");
	$("#"+objId).removeClass("showDiv");
	$("#"+objId+"detail").css("display","none");
	$("#"+objId+"btn").css("background","center url('images/about/btn_up.gif') no-repeat");
}

function showForm(objId){

var istring = $("#"+objId).html();

var nstring = istring.slice(4,istring.length- 3);
	
	//$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box">'+$("#"+objId).html()+'</div></div>');
	
	$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box">'+ nstring +'</div></div>');

	
	// Style overlay and show it
	var arrPageSizes = ___getPageSize();
	var arrPageScroll = ___getPageScroll();
	$('#jquery-lightbox').css({
		top:	arrPageScroll[1] + (arrPageSizes[3] / 10),
		left:	arrPageScroll[0]
	})
	$('#lightbox-container-image-box').css({
		width:				$("#"+objId+" table").attr("width"),
		height:				$("#"+objId+" table").attr("height")
	});
	$('#jquery-overlay').css({
		backgroundColor:	'#000',
		opacity:			0.8,
		width:				arrPageSizes[0],
		height:				arrPageSizes[1]
	}).fadeIn();
}

function _finish() {
	$('#jquery-overlay,#jquery-lightbox').fadeOut(function() { $('#jquery-overlay,#jquery-lightbox').remove();})
}

function ___getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
};
function ___getPageScroll() {
	var xScroll, yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}
	arrayPageScroll = new Array(xScroll,yScroll);
	return arrayPageScroll;
};


function IsValidEmail(asTempString)
{
   var atCount = 0;
   var periodCount = 0;
   var strLen = asTempString.length;
   var i;
   var temp;
   var validchar= /^\w|[@.-]$/; //valid char = a-z, A-Z, @ , . , _ , -

   if (asTempString == '')
     return false;
     
   for (i = 0; i < strLen; i++)
      {
      temp = asTempString.substring(i, i+1);
	  if (temp == '@') 
         atCount++;
      if (temp == '.') 
         periodCount++;
	  if (!validchar.test(temp)){
		return false;
		}
	  }
   if ((atCount == 1) && (periodCount > 0))
      return true;
   else
      return false;

}


/* strat email registration  */

function checkForm(){

var f = document.form2;

if(document.all.FName.value == ''){
    alert("Please enter First Name");
    document.all.FName.focus();
    return false;
}


if(document.all.LName.value == ''){
    alert("Please enter Last Name");
    document.all.LName.focus();
    return false;
}

if(document.all.Email.value == ''){
    alert("Please enter Email");
    document.all.Email.focus();
    return false;
}else {

    if (IsValidEmail(document.all.Email.value)){

        //email valid
    }else {
        alert("Please enter Valid Email");
        document.all.Email.focus();
        return false;
    }

}

f.HiddenFieldFName.value = document.all.FName.value ;
f.HiddenFieldLName.value = document.all.LName.value ;
f.HiddenFieldJob.value = document.all.Job.options[document.all.Job.selectedIndex].value;
f.HiddenFieldAge.value = document.all.Age.options[document.all.Age.selectedIndex].value;
f.HiddenFieldEmail.value = document.all.Email.value ;
f.HiddenFieldTel.value = document.all.Tel.value ;
if(document.all.Sex[0].checked){
    f.HiddenFieldSex.value = "M" ;
}else {
    f.HiddenFieldSex.value = "F" ;
}


f.submit();

}

function checkForm_c(){

var f = document.form2;

if(document.all.FName.value == ''){
    alert('請輸入姓氏');
    document.all.FName.focus();
    return false;
}


if(document.all.LName.value == ''){
    alert("請輸入名稱");
    document.all.LName.focus();
    return false;
}

if(document.all.Email.value == ''){
    alert("請輸入電郵");
    document.all.Email.focus();
    return false;
}else {

    if (IsValidEmail(document.all.Email.value)){

        //email valid
    }else {
        alert("請輸入正確電郵");
        document.all.Email.focus();
        return false;
    }

}

f.HiddenFieldFName.value = document.all.FName.value ;
f.HiddenFieldLName.value = document.all.LName.value ;
f.HiddenFieldJob.value = document.all.Job.options[document.all.Job.selectedIndex].value;
f.HiddenFieldAge.value = document.all.Age.options[document.all.Age.selectedIndex].value;
f.HiddenFieldEmail.value = document.all.Email.value ;
f.HiddenFieldTel.value = document.all.Tel.value ;
if(document.all.Sex[0].checked){
    f.HiddenFieldSex.value = "M" ;
}else {
    f.HiddenFieldSex.value = "F" ;
}


f.submit();

}


function setReset(){

document.all.FName.value = '' ;
document.all.LName.value = '' ;
document.all.Job.options[0].selected=true;
document.all.Age.options[0].selected=true;


document.all.Email.value  = '' ;
document.all.Tel.value  = '' ;
document.all.Sex[0].checked = true;
}
/* end email registration  */

/* strat  forword to friend  */
function checkFor(){    
    
    if(document.all.YEmail.value == ''){
        alert("Please enter Your Email");
        document.all.YEmail.focus();
        return false;
    }else{
    
        if (IsValidEmail(document.all.YEmail.value)){
            //email valid
        }else{
            alert("Please enter Your Valid Email");
            document.all.YEmail.focus();
            return false;
        }
    
    }
        
    
    if (document.all.Email1.value != ''){
        if(IsValidEmail(document.all.Email1.value)){
            //email valid
        }else{
            
            alert("Please enter Your Friend Valid Email");
            document.all.Email1.focus();
            return false;
        }
    
    }
    
    if (document.all.Email2.value != ''){
        if(IsValidEmail(document.all.Email2.value)){
            //email valid
        }else{
            
            alert("Please enter Your Friend Valid Email");
            document.all.Email2.focus();
            return false;
        }
    
    }
               
    if (document.all.Email3.value != ''){
        if(IsValidEmail(document.all.Email3.value)){
            //email valid
        }else{
            
            alert("Please enter Your Friend Valid Email");
            document.all.Email3.focus();
            return false;
        }
    
    }        
    
    if (document.all.Email4.value != ''){
        if(IsValidEmail(document.all.Email4.value)){
            //email valid
        }else{
            
            alert("Please enter Your Friend Valid Email");
            document.all.Email4.focus();
            return false;
        }
    
    }
            
    if (document.all.Email5.value != ''){
        if(IsValidEmail(document.all.Email5.value)){
            //email valid
        }else{
            
            alert("Please enter Your Friend Valid Email");
            document.all.Email5.focus();
            return false;
        }
    
    }   
 
var f = document.form3;
  
f.HiddenFieldYEmail.value = document.all.YEmail.value;


f.HiddenFieldEmail1.value = document.all.Email1.value;
f.HiddenFieldEmail2.value = document.all.Email2.value;
f.HiddenFieldEmail3.value = document.all.Email3.value;
f.HiddenFieldEmail4.value = document.all.Email4.value;
f.HiddenFieldEmail5.value = document.all.Email5.value;


var x ;
    
    x = 0;
     
    if (f.HiddenFieldEmail1.value != ''){
        x = x + 1;          
    }
    
    if (f.HiddenFieldEmail2.value != ''){
        x = x + 1;    
    }
    
    if (f.HiddenFieldEmail3.value != ''){
        x = x + 1;    
    }
    
    if (f.HiddenFieldEmail4.value != ''){
        x = x + 1;    
    }
    if (f.HiddenFieldEmail5.value != ''){
        x = x + 1;    
    }
    

    if (x < 1) {
        alert("Please enter Your Friend Email");
        document.all.Email1.focus();
        return false;    
    }

f.HiddenFieldTitle.value = document.all.FormViewExhi$HiddenFieldTitle.value;

f.HiddenFieldCard.value = document.all.HiddenFieldCard1.value;

f.HiddenFieldMsg.value = document.all.Msg.value;

f.submit();

}



function checkFor_c(){    
    
    if(document.all.YEmail.value == ''){
        alert("請填上你的電郵地址");
        document.all.YEmail.focus();
        return false;
    }else{
    
        if (IsValidEmail(document.all.YEmail.value)){
            //email valid
        }else{
            alert("請填上你的有效電郵地址");
            document.all.YEmail.focus();
            return false;
        }
    
    }
        
    
    if (document.all.Email1.value != ''){
        if(IsValidEmail(document.all.Email1.value)){
            //email valid
        }else{
            
            alert("請填上你朋友的有效電郵地址");
            document.all.Email1.focus();
            return false;
        }
    
    }
    
    if (document.all.Email2.value != ''){
        if(IsValidEmail(document.all.Email2.value)){
            //email valid
        }else{
            
            alert("請填上你朋友的有效電郵地址");
            document.all.Email2.focus();
            return false;
        }
    
    }
               
    if (document.all.Email3.value != ''){
        if(IsValidEmail(document.all.Email3.value)){
            //email valid
        }else{
            
            alert("請填上你朋友的有效電郵地址");
            document.all.Email3.focus();
            return false;
        }
    
    }        
    
    if (document.all.Email4.value != ''){
        if(IsValidEmail(document.all.Email4.value)){
            //email valid
        }else{
            
            alert("請填上你朋友的有效電郵地址");
            document.all.Email4.focus();
            return false;
        }
    
    }
            
    if (document.all.Email5.value != ''){
        if(IsValidEmail(document.all.Email5.value)){
            //email valid
        }else{
            
            alert("請填上你朋友的有效電郵地址");
            document.all.Email5.focus();
            return false;
        }
    
    }   
 
var f = document.form3;
  
f.HiddenFieldYEmail.value = document.all.YEmail.value;


f.HiddenFieldEmail1.value = document.all.Email1.value;
f.HiddenFieldEmail2.value = document.all.Email2.value;
f.HiddenFieldEmail3.value = document.all.Email3.value;
f.HiddenFieldEmail4.value = document.all.Email4.value;
f.HiddenFieldEmail5.value = document.all.Email5.value;


var x ;
    
    x = 0;
     
    if (f.HiddenFieldEmail1.value != ''){
        x = x + 1;          
    }
    
    if (f.HiddenFieldEmail2.value != ''){
        x = x + 1;    
    }
    
    if (f.HiddenFieldEmail3.value != ''){
        x = x + 1;    
    }
    
    if (f.HiddenFieldEmail4.value != ''){
        x = x + 1;    
    }
    if (f.HiddenFieldEmail5.value != ''){
        x = x + 1;    
    }
    

    if (x < 1) {
        alert("請填上你朋友的電郵地址");
        document.all.Email1.focus();
        return false;    
    }

f.HiddenFieldTitle.value = document.all.FormViewExhi$HiddenFieldTitle.value;

f.HiddenFieldCard.value = document.all.HiddenFieldCard1.value;

f.HiddenFieldMsg.value = document.all.Msg.value;

f.submit();

}


function checkFormSponor(){    
    
    if(document.all.YEmail.value == ''){
        alert("Please enter Your Email");
        document.all.Email.focus();
        return false;
    }else{
    
        if (IsValidEmail(document.all.YEmail.value)){
            //email valid
        }else{
            alert("Please enter Your Valid Email");
            document.all.Email.focus();
            return false;
        }
    
    }
        
    
    if (document.all.Email1.value != ''){
        if(IsValidEmail(document.all.Email1.value)){
            //email valid
        }else{
            
            alert("Please enter Your Friend Valid Email");
            document.all.Email1.focus();
            return false;
        }
    
    }
    
    if (document.all.Email2.value != ''){
        if(IsValidEmail(document.all.Email2.value)){
            //email valid
        }else{
            
            alert("Please enter Your Friend Valid Email");
            document.all.Email2.focus();
            return false;
        }
    
    }
               
    if (document.all.Email3.value != ''){
        if(IsValidEmail(document.all.Email3.value)){
            //email valid
        }else{
            
            alert("Please enter Your Friend Valid Email");
            document.all.Email3.focus();
            return false;
        }
    
    }        
    
    if (document.all.Email4.value != ''){
        if(IsValidEmail(document.all.Email4.value)){
            //email valid
        }else{
            
            alert("Please enter Your Friend Valid Email");
            document.all.Email4.focus();
            return false;
        }
    
    }
            
    if (document.all.Email5.value != ''){
        if(IsValidEmail(document.all.Email5.value)){
            //email valid
        }else{
            
            alert("Please enter Your Friend Valid Email");
            document.all.Email5.focus();
            return false;
        }
    
    }   
 
var f = document.form3;
  
f.HiddenFieldYEmail.value = document.all.YEmail.value;


f.HiddenFieldEmail1.value = document.all.Email1.value;
f.HiddenFieldEmail2.value = document.all.Email2.value;
f.HiddenFieldEmail3.value = document.all.Email3.value;
f.HiddenFieldEmail4.value = document.all.Email4.value;
f.HiddenFieldEmail5.value = document.all.Email5.value;


var x ;
    
    x = 0;
     
    if (f.HiddenFieldEmail1.value != ''){
        x = x + 1;          
    }
    
    if (f.HiddenFieldEmail2.value != ''){
        x = x + 1;    
    }
    
    if (f.HiddenFieldEmail3.value != ''){
        x = x + 1;    
    }
    
    if (f.HiddenFieldEmail4.value != ''){
        x = x + 1;    
    }
    if (f.HiddenFieldEmail5.value != ''){
        x = x + 1;    
    }
    

    if (x < 1) {
        alert("Please enter Your Friend Email");
        document.all.Name1.focus();
        return false;    
    }

f.HiddenFieldTitle.value = document.all.FormViewEvent$HiddenFieldTitle.value;

f.HiddenFieldCard.value = document.all.FormViewEvent$HiddenFieldCard1.value;

f.submit();

}


function checkFormSponor_c(){    
    
    if(document.all.YEmail.value == ''){
        alert("請填上你的電郵地址");
        document.all.Email.focus();
        return false;
    }else{
    
        if (IsValidEmail(document.all.YEmail.value)){
            //email valid
        }else{
            alert("請填上你的有效電郵地址");
            document.all.Email.focus();
            return false;
        }
    
    }
        
    
    if (document.all.Email1.value != ''){
        if(IsValidEmail(document.all.Email1.value)){
            //email valid
        }else{
            
            alert("請填上你朋友的有效電郵地址");
            document.all.Email1.focus();
            return false;
        }
    
    }
    
    if (document.all.Email2.value != ''){
        if(IsValidEmail(document.all.Email2.value)){
            //email valid
        }else{
            
            alert("請填上你朋友的有效電郵地址");
            document.all.Email2.focus();
            return false;
        }
    
    }
               
    if (document.all.Email3.value != ''){
        if(IsValidEmail(document.all.Email3.value)){
            //email valid
        }else{
            
            alert("請填上你朋友的有效電郵地址");
            document.all.Email3.focus();
            return false;
        }
    
    }        
    
    if (document.all.Email4.value != ''){
        if(IsValidEmail(document.all.Email4.value)){
            //email valid
        }else{
            
            alert("請填上你朋友的有效電郵地址");
            document.all.Email4.focus();
            return false;
        }
    
    }
            
    if (document.all.Email5.value != ''){
        if(IsValidEmail(document.all.Email5.value)){
            //email valid
        }else{
            
            alert("請填上你朋友的有效電郵地址");
            document.all.Email5.focus();
            return false;
        }
    
    }   
 
var f = document.form3;
  
f.HiddenFieldYEmail.value = document.all.YEmail.value;


f.HiddenFieldEmail1.value = document.all.Email1.value;
f.HiddenFieldEmail2.value = document.all.Email2.value;
f.HiddenFieldEmail3.value = document.all.Email3.value;
f.HiddenFieldEmail4.value = document.all.Email4.value;
f.HiddenFieldEmail5.value = document.all.Email5.value;


var x ;
    
    x = 0;
     
    if (f.HiddenFieldEmail1.value != ''){
        x = x + 1;          
    }
    
    if (f.HiddenFieldEmail2.value != ''){
        x = x + 1;    
    }
    
    if (f.HiddenFieldEmail3.value != ''){
        x = x + 1;    
    }
    
    if (f.HiddenFieldEmail4.value != ''){
        x = x + 1;    
    }
    if (f.HiddenFieldEmail5.value != ''){
        x = x + 1;    
    }
    
    if (x < 1) {
        alert("請填上你朋友的電郵地址");
        document.all.Name1.focus();
        return false;    
    }

f.HiddenFieldTitle.value = document.all.FormViewEvent$HiddenFieldTitle.value;

f.HiddenFieldCard.value = document.all.FormViewEvent$HiddenFieldCard1.value;

f.submit();

}




function resetFor(){
    
document.all.YEmail.value = '';
document.all.Email1.value = '';
document.all.Email2.value = '';
document.all.Email3.value = '';
document.all.Email4.value = '';
document.all.Email5.value = '';
document.all.Msg.value = '';

document.all.YEmail.focus();

}

/* end  forword to friend  */