// JavaScript Document 
function show(divName)
 {
   var divObject=document.getElementById(divName);
   divObject.style.display="block";
   divObject.style.visibility="visible";
 }
 
function hide(divName)
 {
   var divObject=document.getElementById(divName);
   divObject.style.display="none";
 }
 var megamenuTime;
 var megamenuFlag=0;
$(document).ready(function() {

  
//
  /* $(".showA").mouseover(function(){
	   $(this).css("display","none");
	   $(this).next().css("display","block");
	   });
    $(".hideA").mouseleave(function(){
	    $(this).css("display","none");
	   $(this).prev().css("display","block");
	   });*/
	   //
	   $(".menuDiv").mouseover(function(){
	   
	      $(".menudownlist").css("visibility","hidden");
		  
		   var downid="menudown_"+$(this).attr("id");
		  // alert(downid);
		 
		   $("#"+downid).css("visibility","visible");
		   
		   
	        
	   });
	   $(".menudownlist").mouseover(function(){
		   megamenuFlag=1;
		  // megamenuTime=setTimeout("", 10);
	       clearTimeout(megamenuTime);
	   });
	   $(".menudownlist").mouseleave(function(){
	    $(".menudownlist").css("visibility","hidden");
	   });
	   $("#menu").mouseleave(function(){
		     megamenuFlag=0;
	       megamenuTime=setTimeout("hideMegaMenu()", 3000);
	   });
 //quickdiv
 $("#quickdiv .quickitem").mouseover(function(){
	 $(this).removeClass("quicklist");
	  $(this).addClass("quicklist2");
	  $(this).find("img").attr("src",dir+"images_en/arrow2.jpg");
	 });
$("#quickdiv .quickitem").mouseleave(function(){
	  $(this).removeClass("quicklist2");
	  $(this).addClass("quicklist");
	  
	  $(this).find("img").attr("src",dir+"images_en/arrow.jpg");
	 });
//
  
 });
function hideMegaMenu()
{   
	if(megamenuFlag==0)
	$(".menudownlist").css("visibility","hidden");

}
function isEmail (s){
	if (s.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1){
		return true;
	}
	else{
		return false;
	}
}
function showAlert(str){
	//alert(str);
}
function check_version(id,vs,dir,newsid,typeflag)
{  
	var p = "&newsid="+newsid;
	if(typeflag=='event'){
		p = "&eventsid="+newsid;
	}
	var params = "static_id="+id+"&version="+vs+""+p;
	//alert(params);return;
	$.ajax({
       url: dir+'check_version.php', 
       type:'post',         
       dataType:'string',     
       data:params,         
       success:check_result 
     });   
}
//result 
function check_result (htmlurl)
{
	//alert(htmlurl);return;
	if(htmlurl!="")
	{
	   location.href=htmlurl;
	}
}
// news_page 
function getNewsList(id,curpage,num,width)
{  
	var params = "id="+id+"&curpage="+curpage+"&num="+num+"&width="+width;
	var phpfile = 'news_page.php';
	if(id=="12") phpfile = 'newsletter_page.php';
	$.ajax({
       url: dir+phpfile, 
       type:'post',         
       dataType:'string',     
       data:params,         
       success:fillnews 
     });   
}

function getEventsList(id,curpage,num,width)
{   
	var params = "id="+id+"&curpage="+curpage+"&num="+num+"&width="+width;
	var phpfile = 'events_page.php';
	$.ajax({
       url: dir+phpfile, 
       type:'post',         
       dataType:'string',     
       data:params,         
       success:fillnews_1 
     });   
}


function fillnews (htmlstr){
	$("#ldlistdiv").html(htmlstr);
	//newslist();
	twolinejs();
	
}

function fillnews_1 (htmlstr){
	$("#event_page").html(htmlstr);
	//newslist();
	twolinejs();
	
}






jQuery(document).ready(function() {

//alert($.client.os+"|"+$.client.browser);
var os=$.client.os;
var browser=$.client.browser;
if(os=="Mac")
{
  $(".inputsearch").css("margin-top","2px");
}
if(os=="Mac"&&browser=="Safari")
{
  $(".downlist").css("width","259px");
  $(".downlisttext").css("width","239px");
  $(".dropdown").css("width","257px");
}
if(os=="Mac"&&browser=="Chrome")
{	
	$(".downlist").css("width","259px");
  $(".downlisttext").css("width","239px");
  $(".dropdown").css("width","257px");
}
});

//-------------------------footer-----------------------------
var test;
$(document).ready(function(){
	test=$("#bottom").outerHeight();
	$("#bottom").addClass("oldbottom");
    bottomChange();
    $("#bottom").css("display","block");
	
    start = setInterval('init()', 200); 
   // sysTime();
});



function init() {  
	 if (document.readyState == "complete") {  
		try{  
			bottomChange();
			clearInterval(start); 
		}catch(err){return true;}  
	 }  
}  
$(window).resize(function(){
  	bottomChange();
});
function alertWidth()
{
	  var bdHeight=$('body').outerHeight();
  	  var widowHeight= $(window).height(); 
  
  
	  if(widowHeight>bdHeight+80)
	  {
		  alert(">");
	  }else	{
		  alert("<");
	  }
		  
	  bottomChange();
	 
}
function bottomChange()
{
  
    var bdHeight=$('#case').outerHeight();
    var widowHeight= $(window).height(); 
  
    var bottomHeight=$("#bottom").outerHeight();
    //$("#middle").css("height", widowHeight);
	
	//alert(widowHeight+"---"+bdHeight+"--"+bottomHeight);
  if(widowHeight>bdHeight+test)
   { 
  // alert("456");
	 test=bottomHeight;
    // $("#bottom").css("position","absolute");//ie6
  $("#bottom").removeClass("oldbottom");
     $("#bottom").addClass("newbottom");
    
    }else
    {		//806
  		test=0;
	  // $("#bottom").css("position","relative");
	  // $("#bottom").css("_top","auto");//ie6
      $("#bottom").removeClass("newbottom");
	  $("#bottom").addClass("oldbottom");
   }
 }

//-----------------------jiezifu------------------------

$(document).ready(function(){
	twolinejs();
});

function twolinejs(){
	$(".twoline_js").each(function(){
		var showStr='';
		var line=0;
		var linenum=1;
		var totalWidth=12;
		$(this).find("span").each(function(){
			line+=$(this).width();
			totalWidth+=$(this).width();
			if(line<=260&&linenum<=2){
				showStr+=$(this).html();
			}else{
				line=12+$(this).width();
				linenum++;
				if(linenum<=2) showStr+=$(this).html();
			}
		});
		if(totalWidth>260*2){
		   showStr+=" ...";
		}
		$(this).html(showStr);
	});
}

var i=1;

function imgnext(){
	if(i>=$(".popimg").length){
		i=1;
	}else{
		i=i+1;
	}
	$(".popimg").css("display","none");
	$("#popimg"+i).css("display","block");	
}
function imgpre(){
	if(i<=1){
		i=$(".popimg").length;
	}else{
		i=i-1;
	}
	$(".popimg").css("display","none");
	$("#popimg"+i).css("display","block");	
}

function hide_sendok_error(){
	  hide('sendok');
	  var id= $("#event_id").val();
	  window.location.href=dir+"download.php?id=82&eventsid="+id;
	}
$(function(){
	$('#firstname').blur( function () { 
		if($(this).val()==""||$(this).val()=="First name"){
			$("#firstname").removeClass("logininput");
    		$("#firstname").addClass("logininputalt");
		}else{
			$("#firstname").removeClass("logininputalt");
    		$("#firstname").addClass("logininput");
		}
		
	} );
	$('#lastname').blur( function () { 
		if($(this).val()==""||$(this).val()=="Last name"){
			$("#lastname").removeClass("logininput");
    		$("#lastname").addClass("logininputalt");
		}else{
			$("#lastname").removeClass("logininputalt");
    		$("#lastname").addClass("logininput");
		}
		
	} );
	$('#email_1').blur( function () { 
		if($(this).val()==""||$(this).val()=="Email address"){
			$("#email_1").removeClass("logininput");
    		$("#email_1").addClass("logininputalt");
		}else{
			$("#email_1").removeClass("logininputalt");
    		$("#email_1").addClass("logininput");
		}
		
	} );
	$('#company').blur( function () { 
		if($(this).val()==""||$(this).val()=="Company"){
			$("#company").removeClass("logininput");
    		$("#company").addClass("logininputalt");
		}else{
			$("#company").removeClass("logininputalt");
    		$("#company").addClass("logininput");
		}
		
	} );
	$('#email').blur( function () { 
		if($(this).val()==""||$(this).val()=="Email address"){
			$("#email").removeClass("logininput");
    		$("#email").addClass("logininputalt");
		}else{
			$("#email").removeClass("logininputalt");
    		$("#email").addClass("logininput");
		}
		
	} );
})



function register_check(){
  var firstname=document.getElementById("firstname").value;
  if(firstname==''||firstname=='First name'||firstname==null){
	$("#firstname").removeClass("logininput");
    $("#firstname").addClass("logininputalt");
	document.getElementById("firstname").focus();
	return false;
  }
  var lastname=document.getElementById("lastname").value;
  if(lastname==''||lastname=='Last name'||firstname==null){
	$("#lastname").removeClass("logininput");
    $("#lastname").addClass("logininputalt");
	document.getElementById("lastname").focus();
	return false;
  }
  var email=document.getElementById("email_1").value;
  if(email==''||email=='Email address'){
    $("#email_1").removeClass("logininput");
    $("#email_1").addClass("logininputalt");
	document.getElementById("email_1").focus();
	return false;
  }
  
  if(isEmail(email)==false){
    $("#email_1").removeClass("logininput");
    $("#email_1").addClass("logininputalt");
	document.getElementById("email_1").focus();
	return false;
  } 
 
  
  var password=document.getElementById("password_1").value;
  if(password==''||password=='Password'||password==null){
    $("#password_temp_1").removeClass("logininput");
    $("#password_temp_1").addClass("logininputalt");
	document.getElementById("password_1").focus();
	return false;
  }
  var confirm_password=document.getElementById("confirm_password").value;
  if(confirm_password==''||confirm_password=='Confirm Password'||confirm_password==null){
    $("#password_temp_2").removeClass("logininput");
    $("#password_temp_2").addClass("logininputalt");
	document.getElementById("confirm_password").focus();
	return false;
  }
  if(password!=confirm_password){
	 $("#confirm_password").removeClass("logininput");
     $("#confirm_password").addClass("logininputalt");
	document.getElementById("confirm_password").focus();
	return false; 
  }
  var company=document.getElementById("company").value;
  if(company==''||company=='Company'||company==null){
     $("#company").removeClass("logininput");
     $("#company").addClass("logininputalt");
	document.getElementById("company").focus();
	return false;
  }
   var id= $("#event_id").val();
  var data = 'firstname='+firstname+'&lastname='+lastname+'&email='+email+'&password='+password+'&company='+company+'&event_id='+id; 
   var url = dir+"register.php?"+data;
	$.get(url,{},function(msg){
		if(msg == "ok"){
			   show('sendok');
			   setTimeout('hide_sendok_error()',3000);
			   
			}
		else{
			    show('popbg'); show('register'); 
			}
	});
	return false;

}
function hide_login_error(){
	  hide('login_error');
	}
function login_check(){
   var email=document.getElementById("email").value;
  if(email==''||email=='Email address'||email==null){
     $("#email").removeClass("logininput");
     $("#email").addClass("logininputalt");
	document.getElementById("email").focus();
	return false;
  }
  var password=document.getElementById("password").value;
  if(password==''||password=='Password'||password==null){
     $("#password_temp").removeClass("logininput");
     $("#password_temp").addClass("logininputalt");
	document.getElementById("password").focus();
	return false;
  }
  

  
   var data = 'email='+email+'&password='+password; 
    var url = dir+"login.php?"+data;
	$.get(url,{},function(msg){
		if(msg == "false"){
			 show('login_error');
			   setTimeout('hide_login_error()',3000);
			   document.getElementById("email").focus();
			}
		else{
			   var id= $("#event_id").val();
			   window.location.href=dir+"download.php?id=82&eventsid="+id;
			}
	});
	return false;
}

function close_login(){
	 $("#email").val("Email address");
	 $("#password").val("Password");
	 hide('popbg'); hide('login');
	
	}
function close_register(){
	 $("#firstname").val("First name");
	 $("#lastname").val("Last name");
	 $("#email_1").val("Email address");
	 $("#password_temp_1").val("Password");
	 $("#password_temp_2").val("Confirm Password");
	 $("#company").val("Company");
	 hide('popbg'); hide('register');
	
	}
///////////////////////////////////////////
function userlogin(){
	    var url = dir+"checklogin.php";
		$.get(url,{},function(msg){
			if(msg=="|yes|"){
				var id= $("#event_id").val();
				window.location.href=dir+"download.php?id=82&eventsid="+id;
			}else{
				show('popbg'); show('login');
			}				  
							  
	    })
		
		
	}
$(function(){
		$('#firstname').focus(function(){
			if($(this).val()=="First name"){
				$(this).val("");
			}
		});
		$('#firstname').blur(function(){
			if($(this).val()==""){
				$(this).val("First name");
			}
		}); 
		
		$('#lastname').focus(function(){
			if($(this).val()=="Last name"){
				$(this).val("");
			}
		});
		$('#lastname').blur(function(){
			if($(this).val()==""){
				$(this).val("Last name");
			}
		});
		   
		   
		$('#email').focus(function(){
			if($(this).val()=="Email address"){
				$(this).val("");
			}
		});
		$('#email').blur(function(){
			if($(this).val()==""){
				$(this).val("Email address");
			}
		});
		
		
		$('#password_temp').focus(function(){
			$(this).hide();
		   $('#password').show();
		   $('#password').focus();
		});
		$('#password').blur(function(){
			if($(this).val()==""){
				$(this).hide();
		   		$('#password_temp').show();
			}
		});
	
	$('#email_1').focus(function(){
			if($(this).val()=="Email address"){
				$(this).val("");
			}
		});
		$('#email_1').blur(function(){
			if($(this).val()==""){
				$(this).val("Email address");
			}
		});	
	
	$('#password_temp_1').focus(function(){
			$(this).hide();
		   $('#password_1').show();
		   $('#password_1').focus();
		});
		$('#password_1').blur(function(){
			if($(this).val()==""){
				$(this).hide();
		   		$('#password_temp_1').show();
			}
		});
		
		$('#password_temp_2').focus(function(){
			$(this).hide();
		   $('#confirm_password').show();
		   $('#confirm_password').focus();
		});
		$('#confirm_password').blur(function(){
			if($(this).val()==""){
				$(this).hide();
		   		$('#password_temp_2').show();
			}
		});
		
		$('#company').focus(function(){
			if($(this).val()=="Company"){
				$(this).val("");
			}
		});
		$('#company').blur(function(){
			if($(this).val()==""){
				$(this).val("Company");
			}
		});

		
	});

function isEmail (s)
	{
		if (s.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1){
			return true;
		}
		else{
			return false;
		}
	}
