// JavaScript Document
/*
window.onload = function()
{
	for(var i=1; i<=7; i++)
	{
		document.getElementById("subMenuLeft"+i).style.display = 'none';
	}
}
function toggleMenu(menuID, referer)
{
	for(var i=1; i<=7; i++)
	{
		document.getElementById("subMenuLeft"+i).style.display = 'none';
	}
	var menuObjet = document.getElementById(menuID).style.display;
	document.getElementById(menuID).style.display = (menuObjet == 'none') ? '' : 'none';
	referer.className = 'menuItemSelected';
}*/
nlSubscribe = function()
{
	if(document.getElementById("email_nl").value=="" || document.getElementById("name_nl").value=="")
	{
		alert("Please fill in the fields correctly.")
		return;
	}
	  var parameters = "email=" + escape( encodeURI( document.getElementById("email_nl").value ) );
	  parameters += "&name=" + escape( encodeURI( document.getElementById("name_nl").value ) );
	  parameters += "&occupation=" + escape( encodeURI( document.getElementById("occupation_nl").value ) );
	  parameters += "&pobox=" + escape( encodeURI( document.getElementById("pobox_nl").value ) );
	  parameters += "&action=" + escape( encodeURI( "1" ) );
	  
	  if(true)
	  {
		 document.getElementById('nl_form_wait').style.display = '';
		 document.getElementById('nl_form').style.display = 'none'; // hide the object so it's not clickable anymore to avoid double requests
		 
		  var xmlHttp;
		  try { xmlHttp=new XMLHttpRequest(); } // Firefox, Opera 8.0+, Safari
		  catch (e) // Internet Explorer
			{
			try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
			catch (e)
			  {
			  try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			  catch (e)
				{
				alert("Your request could not be accomplished.")
				return false;
				}
			  }
			}
			xmlHttp.onreadystatechange=function()
			  {
			  if(xmlHttp.readyState==4)
				{
					alert(xmlHttp.responseText);
					document.getElementById('nl_form').style.display = '';
					document.getElementById('nl_form_wait').style.display = 'none';
				}
			  }
			xmlHttp.open('POST', "ajax_nl_subscribe.php", true);
			xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			xmlHttp.setRequestHeader("Content-length", parameters.length);
			xmlHttp.setRequestHeader("Connection", "close");
			xmlHttp.send(parameters);
	  }
}

function displayImage(imageDir, imageObjectID, imageTitle) 
{
	document.getElementById(imageObjectID+'Preloader').style.display = '';
	document.getElementById(imageObjectID).style.display = 'none';
	var img_preload = new Image();
	img_preload.onload = function()
	{
			document.getElementById('mainImagePreloader').style.display = 'none';
			document.getElementById(imageObjectID).style.display = '';
			document.getElementById(imageObjectID).src = imageDir;
			//document.getElementById('imageTitle').innerHTML = imageTitle;
	}
	img_preload.src = imageDir;
}

function getNextImages(industryTextID, parentID, page, tableObject, imageObjectID)
{
	var xhr;

	try 
	{
		xhr = new XMLHttpRequest();
	} 
	catch (e) 
	{
		var a = ['MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'MICROSOFT.XMLHTTP.1.0 ', 'MICROSOFT.XMLHTTP.1', 'MICROSOFT.XMLHTTP'];
		for (var i = 0; i < a.length; i++) 
		{
			try 
			{
				xhr = new ActiveXObject(a[i]);
				break;
			} 
			catch (e) {}
		}
	}

	xhr.onreadystatechange = function()
	{
		if(xhr.readyState==4)
		{
			document.getElementById(tableObject).innerHTML = xhr.responseText;
		}
	}
	xhr.open("GET", "list_galery_images.php?parentID="+parentID+"&page="+page, true);
	xhr.send(null);
	getFirstGalleryImage(industryTextID, parentID, page, imageObjectID, 1);
}

function getFirstGalleryImage(industryTextID, parentID, page, imageObjectID, returnString)
{
	var xhr;

	try 
	{
		xhr = new XMLHttpRequest();
	} 
	catch (e) 
	{
		var a = ['MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'MICROSOFT.XMLHTTP.1.0 ', 'MICROSOFT.XMLHTTP.1', 'MICROSOFT.XMLHTTP'];
		for (var i = 0; i < a.length; i++) 
		{
			try 
			{
				xhr = new ActiveXObject(a[i]);
				break;
			} 
			catch (e) {}
		}
	}

	xhr.onreadystatechange = function()
	{
		if(xhr.readyState==4)
		{
			var responseData = xhr.responseText;
			responseData = responseData.split(";")
			displayImage(responseData[0], imageObjectID, responseData[1]) 
		}
	}
	xhr.open("GET", "get_first_galery_image.php?parentID="+parentID+"&page="+page+"&returnString="+returnString, true);
	xhr.send(null);
}
function getNextImages2(industryTextID, parentID, page, tableObject, imageObjectID)
{
	var xhr;

	try 
	{
		xhr = new XMLHttpRequest();
	} 
	catch (e) 
	{
		var a = ['MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'MICROSOFT.XMLHTTP.1.0 ', 'MICROSOFT.XMLHTTP.1', 'MICROSOFT.XMLHTTP'];
		for (var i = 0; i < a.length; i++) 
		{
			try 
			{
				xhr = new ActiveXObject(a[i]);
				break;
			} 
			catch (e) {}
		}
	}

	xhr.onreadystatechange = function()
	{
		if(xhr.readyState==4)
		{
			document.getElementById(tableObject).innerHTML = xhr.responseText;
		}
	}
	xhr.open("GET", "list_galery_images2.php?parentID="+parentID+"&page="+page, true);
	xhr.send(null);
	getFirstGalleryImage2(industryTextID, parentID, page, imageObjectID, 1);
}

function getFirstGalleryImage2(industryTextID, parentID, page, imageObjectID, returnString)
{
	var xhr;

	try 
	{
		xhr = new XMLHttpRequest();
	} 
	catch (e) 
	{
		var a = ['MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'MICROSOFT.XMLHTTP.1.0 ', 'MICROSOFT.XMLHTTP.1', 'MICROSOFT.XMLHTTP'];
		for (var i = 0; i < a.length; i++) 
		{
			try 
			{
				xhr = new ActiveXObject(a[i]);
				break;
			} 
			catch (e) {}
		}
	}

	xhr.onreadystatechange = function()
	{
		if(xhr.readyState==4)
		{
			var responseData = xhr.responseText;
			responseData = responseData.split(";")
			displayImage(responseData[0], imageObjectID, responseData[1]) 
		}
	}
	xhr.open("GET", "get_first_galery_image2.php?parentID="+parentID+"&page="+page+"&returnString="+returnString, true);
	xhr.send(null);
}

function submitContactForm(ContactForm)
{
	if(ContactForm.fname.value.length == 0)
	{
		alert("Please fill in all mandatory fields.")
		ContactForm.fname.focus();
		return false;
	}
	else if(ContactForm.lname.value.length == 0)
	{
		alert("Please fill in all mandatory fields.")
		ContactForm.lname.focus();
		return false;
	}
	else if(ContactForm.email.value.length == 0)
	{
		alert("Please fill in all mandatory fields.")
		ContactForm.email.focus();
		return false;
	}
	else if ((ContactForm.email.value.indexOf('@', 0) == -1) || (ContactForm.email.value.indexOf('.') == -1)){ 
		alert ("Please enter a correct email address." );    
		ContactForm.email.focus();
		return false;
	}
	else if(ContactForm.comments.value.length == 0)
	{
		alert("Please fill in all mandatory fields.")
		ContactForm.comments.focus();
		return false;
	}
	
	return true;
}

function submitTitleForm(titleForm)
{
	if(titleForm.title.value.length == 0)
	{
		alert("Please fill in all mandatory fields.")
		titleForm.title.focus();
		return false;
	}
	else if(titleForm.author.value.length == 0)
	{
		alert("Please fill in all mandatory fields.")
		titleForm.author.focus();
		return false;
	}
	else if(titleForm.lang.value.length == 0)
	{
		alert("Please fill in all mandatory fields.")
		titleForm.lang.focus();
		return false;
	}
	else if(titleForm.fname.value.length == 0)
	{
		alert("Please fill in all mandatory fields.")
		titleForm.fname.focus();
		return false;
	}
	else if(titleForm.lname.value.length == 0)
	{
		alert("Please fill in all mandatory fields.")
		titleForm.lname.focus();
		return false;
	}
	else if(titleForm.email.value.length == 0)
	{
		alert("Please fill in all mandatory fields.")
		titleForm.email.focus();
		return false;
	}
	else if ((titleForm.email.value.indexOf('@', 0) == -1) || (ContactForm.email.value.indexOf('.') == -1)){ 
		alert ("Please enter a correct email address." );    
		titleForm.email.focus();
		return false;
	}
	
	return true;
}


function submitContactForm2(ContactForm)
{
	if(ContactForm.fname.value.length == 0)
	{
		alert("Please fill in all mandatory fields.")
		ContactForm.fname.focus();
		return false;
	}
	else if(ContactForm.email.value.length == 0)
	{
		alert("Please fill in all mandatory fields.")
		ContactForm.email.focus();
		return false;
	}
	else if ((ContactForm.email.value.indexOf('@', 0) == -1) || (ContactForm.email.value.indexOf('.') == -1)){ 
		alert ("Please enter a correct email address." );    
		ContactForm.email.focus();
		return false;
	}
	
	return true;
}

// Virtual tour
function changesubcolvt(idvideo)
  {
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        document.getElementById("subcol").innerHTML=xmlHttp.responseText;
        }
      }
	url="gallery_video_ajax.php?idvideo="+idvideo;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
  }
