//Front end Java Script File
//Front end Java Script File
// JavaScript Document
	
var LastOpenedTitleId = "";
function displayimg(id)
	{
	document.getElementById(id).style.display="block";
	}

function displayTitle(titleId,id)
{
	if(LastOpenedTitleId != '')
		document.getElementById(LastOpenedTitleId).style.display="none";
	document.getElementById(titleId).style.display="none";
	document.getElementById(id).style.display="block";
			LastOpenedTitleId = id;

}

function hideimg(id)
{
	document.getElementById(id).style.display="none";
}

function showText(id)
{
	document.getElementById(id).style.display="block";
}

var slide = 0;
var timedOut = 0;
var slideArray = new Array();

function getSlideIds(slideId)
	{
		var parent1 = document.getElementById(slideId);
		var thisChild = parent1.firstChild;
		var i=0;
		while ( thisChild != parent1.lastChild )
			{
			if ( thisChild.nodeType == 1 )
				{
				slideArray[i]=thisChild.id;
				i++;
				}
			thisChild = thisChild.nextSibling;
			}
			playSlides();
	}
	
	function playSlides()
	{
		new Fx.Style(slideArray[slide], 'opacity', {duration: 2000}).start(1,0);
	   document.getElementById(slideArray[slide]).style.display = "none";
	slide++;
	
	if(slide==slideArray.length) 
	slide = 0;
	document.getElementById(slideArray[slide]).style.display = "block";
	new Fx.Style(slideArray[slide], 'opacity', {duration: 1000}).start(0,1);
	timedOut = setTimeout("playSlides()",4000); 
	}


function toggleFotoActions(action)
{
	if (action =='over')
		document.getElementById('fotoControls').style.display = "block";
	else
		document.getElementById('fotoControls').style.display = "none";
}

	
	
/* 	----------------------------------------------------------------------------------------------------
	function toggles between 2 divs: movie & slideshow and dynamically inserts flash object in movie div
	----------------------------------------------------------------------------------------------------
	the js below has to be included in the html head or body
	<script type="text/javascript" src="swfobject.js"></script>
	------------------------------------------------------------------------------------------------- */
	
function toggleMediaDisplay(which, msrc)
	{
	if(which=='movie')
		{
			document.getElementById('movie').style.display = "block";
			document.getElementById('scroll_container').style.display = "none";
			var so = new SWFObject("../3dPlayer.swf", "3dPlayer", "448", "348", "8", "#B7B9B8");
			so.addVariable("msrc", "_images/_projects/_files/"+msrc);
			so.addParam("wmode", "transparent");
			so.write("movie");
		}
	if(which=='slideshow')
		{
			document.getElementById('movie').style.display = "none";
			document.getElementById('vedio_clip').style.display = "block";
		}
	}
	
// siteSearch ajax request
function siteSearch(formId,pathPrefix)
{
	$('loader_main').style.display = 'block';
	var url = pathPrefix+"search.php";
	new Ajax.Request(url, 
					  {
					  method:'post',
					  parameters:$(formId).serialize(),
					  	onSuccess: function(transport)
						{
							$('content_container_main_block').style.display = 'none';
							$('content_container_search_block').style.display = 'block';
							var response = transport.responseText;
							$('loader_main').style.display = 'none';
							$('content_container_search_block').innerHTML = response;
							searchScrollHeight = document.getElementById('content_container_search_block').scrollHeight;
							searchOffsetHeight = document.getElementById('content_container_search_block').offsetHeight;
							var searchScrollHeight;
							var searchOffsetHeight;
							if(searchScrollHeight <= searchOffsetHeight)
								{
								$('right_scroll1').style.visibility = 'hidden';
								}
							else
								{
								$('right_scroll1').style.visibility = 'visible';	
								}
							
						},
						onFailure: function(){ alert('Something went wrong...') }
					  });	
}
	
	
// ==================================  Google search functions...
function check_data(pageno,page_count)
{
	// get the search string from the search box
	var search_string = document.getElementById("searchTextField").value;
	// replace the spaces into '+' as google replaces spaces into '+'
	search_string = search_string.replace(' ','+');

	// send the request to del_after_use1.php to get the Latest data from google, through ajax
	url = pathPrefix+"search.php";
	
	
	new Ajax.Request(url,
	  {
			method:'get',
			parameters:{search_string:search_string,pageno:pageno},
				onSuccess: function(transport){
				  var response = transport.responseText;
			  // placing the result set into the hidden div
			  document.getElementById("show_result").style.display = 'block';
			  document.getElementById("show_result").innerHTML = response;
			 
			  // get the required result from the google page by seaching through the class name 'g'
			var obj = $$("#show_result .g");
			  var return_text = "";
			  for(i=0;i<obj.length;i++)
			  {
				return_text += obj[i].innerHTML+ "<br />"; 
				
				//removing the cached from the result 
				return_text = return_text.replace("Cached","");
				
				// removing the Similar pages from the result 
				return_text  = return_text .replace("Similar pages","");
			  }
			  if(return_text=="")
			  {
				return_text = "<div class='no-results'>No search results for given string.</div>";
			  }
			// showing the result set into the final_show div to display
			document.getElementById("search_result_wrapper").innerHTML = '<div id="banner_search">'+
											'<p>Zoekresultaat</p>'+
										'</div>'+return_text;
			document.getElementById("loader").style.display = "none";
			document.getElementById("main_content_box").style.display = "none";
			document.getElementById("search_result_wrapper").style.display = "block";
	
			// below code ment to get the navigation
			var navigation_string = ""; 
			
			// google giving the navigation in the div navbar, so, get the corresponding div.
			var Obj_test = document.getElementById('navbar');
			if(Obj_test!= null)
			{
				// to get the page numbers get the info by tag name td,
				var children = Obj_test.getElementsByTagName('td');
				var p_count = children.length;
				var page_start = 0;
	
					var page_indata ="";
					var string_curr_page = "";
					for(d=0;d<children.length;d++)
					{
						var obj_a_count = children[d].getElementsByTagName('a');
						var xx_return = "";
						var return_num ="";
						
						
						// below code for identify the current selected page				
						var num_curr_page = 0;
						var obj_curr_page = children[d].getElementsByTagName('span');
						
						if(children[d].innerHTML.indexOf("<span class=\"i\">")!=-1)
						{
							num_curr_page = children[d].innerHTML;
							string_curr_page = num_curr_page.substring(children[d].innerHTML.indexOf("<span class=\"i\">"),num_curr_page.length);
							string_curr_page = string_curr_page.replace("<span class=\"i\">","");
							string_curr_page = string_curr_page.replace("</span>","");
						}
	
						//below code for get the page numbers come from google 
						if(obj_a_count.length>0)
						{
							xx_return =obj_a_count[0].innerHTML;	
							var x_arr = xx_return.lastIndexOf('>')+1;
							var x_len =xx_return.length;
							return_num += xx_return.substring(x_arr,xx_return.length);
							if(return_num>0)
							{
							 page_indata += return_num + ",";
							}
						}
					  }
					  
					 // concatinating the present page with rest pages to get the sequenced order	
					  page_indata = string_curr_page+","+page_indata;
					  var arr_page = page_indata.split(",");
					  var sorted_array = arr_page.sort(sortNumber);
					  
					  if(parseInt(string_curr_page)<arr_page[0])
					  {
						navigation_string += string_curr_page + "&nbsp;&nbsp;&nbsp;"; 
					  }
					
						for(e=0;e<arr_page.length-1;e++)
						  {
							if(arr_page[e]==string_curr_page-1)
							{
							navigation_string += '<a class="selected_link" onclick="javascript:page_navigation('+arr_page[e]+ ',' + p_count +')">'+(arr_page[e])+'</a>' + "&nbsp;&nbsp;&nbsp;"; 					
							}
							else
							 navigation_string += '<a onclick="javascript:page_navigation('+arr_page[e]+ ',' + p_count +')">'+(arr_page[e])+'</a>' + "&nbsp;&nbsp;&nbsp;"; 										{
							}
						  }
					  
					document.getElementById("navigation").innerHTML = navigation_string;
			}
			else
			{
				document.getElementById("navigation").innerHTML = navigation_string;
			}
			
			},
			onFailure: function(){ alert('Something went wrong...') }
		  }); //.request()
		return false;
}	
 
 
 function setFieldValue(el,path)

{

	pathPrefix = path;

	value = el.value;

	if(value==' zoek...')

	{

		el.value = "";

	}

}


//--------- scroller js ----------//

var mainHeight;
var mainInnerHeight;
var difHeight;
var getScroll
var loop;
var marginTop;
var mouseUpCount;
var mouseDownCount;
var topClear;
var bottomClear;

	
function mouseDownTop()
	{
	mainHeight = document.getElementById('content_inner_main').clientHeight;
	mainInnerHeight = document.getElementById('content').clientHeight;
	difHeight = mainInnerHeight - mainHeight;
	marginTop = document.getElementById('content').style.marginTop;
	marginTop = marginTop.replace( "px", "" );
		for(mouseUpCount = 0; mouseUpCount <= difHeight; mouseUpCount++)
			{
				if(marginTop.replace("-", "") <= difHeight)
				{
					marginTop = marginTop.replace("-", "");
					getScroll = document.getElementById('content').style.marginTop = -(parseInt(marginTop) + 5)+"px";
					document.getElementById('bottom').style.cursor = "pointer";
					topClear = setTimeout("mouseDownTop()",30);
					return marginTop;
				}
				if(marginTop >= "-"+(difHeight))
				{
				document.getElementById('bottom').style.cursor = "auto";
				}
				else
				{
				document.getElementById('top').style.cursor = "auto";
				}
			}
	}

function mouseUpTop()
	{
	clearTimeout(topClear);
	}

function mouseDownBottom()
	{
	mainHeight = document.getElementById('content_inner_main').clientHeight;
	mainInnerHeight = document.getElementById('content').clientHeight;
	difHeight = mainInnerHeight - mainHeight;
	marginTop = document.getElementById('content').style.marginTop;
	marginTop = marginTop.replace( "px", "" );
		for(mouseDownCount = 0; mouseDownCount <= 0; mouseDownCount++)
			{
				if(marginTop <= 0)
				{
					getScroll = document.getElementById('content').style.marginTop = (parseInt(marginTop) + 5)+"px";
					document.getElementById('top').style.cursor = "pointer";
					bottomClear = setTimeout("mouseDownBottom()",30);
					return marginTop;
				}
					if(marginTop >= 5)
					{
					document.getElementById('top').style.cursor = "auto";
					}
			}
	}

function mouseUpBottom()
	{
	clearTimeout(bottomClear);
	}
	
//End of Scroll Js
