// JavaScript Document
var xmlHttp;
var xmlHttp1;
function getXmlHttpObject(){
	var objXMLHttp=null;
	if(window.XMLHttpRequest){
 		objXMLHttp=new XMLHttpRequest();
 	}else if(window.ActiveXObject){
 		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
 	}
 	return objXMLHttp;
}
//-----Start of Load Science Papers Name List ------------------------------------------
function wfLoadSpNameList(spKeyword){
	xmlHttp=getXmlHttpObject();
	if(xmlHttp==null){
		alert("Your browser has to be updated.");
		return;
	}else{
		var url="addons/resources_load_sp_name_list.php";
		url=url+"?spKeyword="+spKeyword;
		xmlHttp.onreadystatechange=wfShowSpNameList;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}		
}
function wfShowSpNameList(){
	if(xmlHttp.readyState!=4){
		document.getElementById('divSpNameList').innerHTML='Loading...';	
	}
	if(xmlHttp.readyState==4){
		MM_showHideLayers('divSpNameList','','show');
		document.getElementById('divSpNameList').innerHTML=xmlHttp.responseText;
	}
}
//-----End of Load Science Papers Name List-------------------------------------------
//-----Start of Load Science Papers Topic List ------------------------------------------
function wfLoadSpTopicList(){
	xmlHttp=getXmlHttpObject();
	if(xmlHttp==null){
		alert("Your browser has to be updated.");
		return;
	}else{
		var url="addons/resources_load_sp_titles.php";
		xmlHttp.onreadystatechange=wfShowSpTopicList;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}		
}
function wfShowSpTopicList(){
	if(xmlHttp.readyState!=4){
		document.getElementById('sp_title_area').innerHTML='Loading...';	
	}
	if(xmlHttp.readyState==4){
		document.getElementById('sp_title_area').innerHTML=xmlHttp.responseText;
	}
}
//-----End of Load Science Papers Topic List-------------------------------------------

//-----Start of Load Science Papers Sub Category List ------------------------------------------
function wfLoadSpSubCategoryList(topic){
	xmlHttp=getXmlHttpObject();
	if(xmlHttp==null){
		alert("Your browser has to be updated.");
		return;
	}else{
		var url="addons/resources_load_sp_sub_categories.php";
		url=url+"?topic="+topic;
		xmlHttp.onreadystatechange=wfShowSpSubCategoryList;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}		
}
function wfShowSpSubCategoryList(){
	if(xmlHttp.readyState!=4){
		document.getElementById('sp_sub_category_area').innerHTML='Loading...';	
	}
	if(xmlHttp.readyState==4){
		document.getElementById('sp_sub_category_area').innerHTML=xmlHttp.responseText;
	}
}
//-----End of Load Science Papers Sub Category List-------------------------------------------

//-----Start of Load Science Papers Authors List ------------------------------------------
function wfLoadSpAuthorsList(){
	xmlHttp=getXmlHttpObject();
	if(xmlHttp==null){
		alert("Your browser has to be updated.");
		return;
	}else{
		var url="addons/resources_load_sp_authors.php";
		xmlHttp.onreadystatechange=wfShowSpAuthorsList;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}		
}
function wfShowSpAuthorsList(){
	if(xmlHttp.readyState!=4){
		document.getElementById('sp_aurhor_area').innerHTML='Loading...';	
	}
	if(xmlHttp.readyState==4){
		document.getElementById('sp_aurhor_area').innerHTML=xmlHttp.responseText;
	}
}
//-----End of Load Science Papers Authors List-------------------------------------------

//-----Start of Load Keynote Speakers List ------------------------------------------
function wfLoadKsList(id){
	xmlHttp1=getXmlHttpObject();
	if(xmlHttp1==null){
		alert("Your browser has to be updated.");
		return;
	}else{
		var url="addons/resources_keynote_speakers_list.php";
		url=url+"?id="+id;
		xmlHttp1.onreadystatechange=wfShowKsList;
		xmlHttp1.open("GET",url,true);
		xmlHttp1.send(null);
	}		
}
function wfShowKsList(){
	if(xmlHttp1.readyState!=4){
		document.getElementById('keynote_speakers_list').innerHTML='Loading...';	
	}
	if(xmlHttp1.readyState==4){
		document.getElementById('keynote_speakers_list').innerHTML=xmlHttp1.responseText;
	}
}
//-----End of Load Keynote Speakers List-------------------------------------------


//-----Start of Load Selected Keynote Speaker details ------------------------------------------
function wfLoadSelectedKsDetails(id){
	xmlHttp=getXmlHttpObject();
	if(xmlHttp==null){
		alert("Your browser has to be updated.");
		return;
	}else{
		var url="addons/resources_keynote_speaker_info.php";
		url=url+"?id="+id;
		xmlHttp.onreadystatechange=wfShowSelectedKsDetails;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		document.getElementById('keynote_speakers_list').innerHTML='';
		wfLoadKsList(id);
	}		
}
function wfShowSelectedKsDetails(){
	if(xmlHttp.readyState!=4){
		document.getElementById('selected_ks_info').innerHTML='Loading...';	
	}
	if(xmlHttp.readyState==4){
		document.getElementById('selected_ks_info').innerHTML=xmlHttp.responseText;
	}
}
//-----End of Selected Keynote Speaker details-------------------------------------------

//-----Show Science Papers Name List--------------------------------------------------
function MM_showHideLayers() {
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function wfGetKeyword(){
	typed_value = document.form1.txtSpName.value;
	wfLoadSpNameList(typed_value);
}

function wfGetSelectedSpName(selectedVal){
	document.form1.txtSpName.value=selectedVal;
	var obj = document.getElementById("divSpNameList").style;	
			if(!obj.display){
				obj.display = 'none';
			}
   			else{
        		obj.display = '';
			}
}

function wfActivateTopic(){
	if(document.getElementById("cbTitle").checked){		
		document.form1.mnuTitle.disabled=false;
		wfLoadSpTopicList();
	}
	else{
		document.form1.mnuTitle.disabled=true;
	}
}

function wfActivateSubCategory(){
	if(document.getElementById("cbSubCategory").checked){
		document.form1.mnuSubCategory.disabled=false;
	}
	else{
		document.form1.mnuSubCategory.disabled=true;
	}
}
function wfLoadSubCategory(topic){
	if(document.getElementById("cbSubCategory").checked){
		document.form1.cbSubCategory.checked=false;
		wfLoadSpSubCategoryList(topic);
		document.form1.mnuSubCategory.disabled=true;
	}else{
		wfLoadSpSubCategoryList(topic);
		document.form1.cbSubCategory.disabled=false;
	}	
}

function wfActivateSpAuthors(){
	if(document.getElementById("cbAuthor").checked){
		document.form1.mnuAuthor.disabled=false;
		wfLoadSpAuthorsList();
	}
	else{
		document.form1.mnuAuthor.disabled=true;
	}	
}
function testShow(){
	if(document.form1.lstSpName.selectedIndex<0){
		if(document.form1.txtSpName.value.length==0){
			var obj = document.getElementById("divSpNameList").style;		
			if(!obj.display){
				obj.display = 'none';
			}
   			else{
        		obj.display = '';
			}
		}
		else{
			wfGetKeyword();
			var obj = document.getElementById("divSpNameList").style;		
			if(!obj.display){
				obj.display = 'none';
			}
   			else{
        		obj.display = '';
			}
		}
	}
	else{
		//wfGetSelectedSpName(this.options[this.selectedIndex].value);
	}
}
function validate_newsletter_signup(){
string = /^[\s]+$/
string2 = /^[a-zA-Z0-9-.''\s]+$/
string3 = /0-9/
string4= /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/
	if (document.forms[0].txtName.value=="")	
	{
		document.getElementById("err_msg_area").innerHTML='<div class="messages error">Your name field can not be left blank</div>';
		document.forms[0].txtName.focus();
		return false;
	}
	str=document.forms[0].txtMail.value
	if (str=="")
	{
		document.getElementById("err_msg_area").innerHTML='<div class="messages error">Your e-mail address field can not be left blank</div>';
		document.forms[0].txtMail.focus();
		return false;
	} 
	if (!str.match(string4)) 
	{
		document.getElementById("err_msg_area").innerHTML='<div class="messages error">Invalid e-mail address</div>';
		document.forms[0].txtMail.focus();
		return false;
	}
}