<!--
// This calls our function ClearInput, and the two variables we
// will need for it to function the original value and the id.
function ClearInput(value, id){ 
	var input = document.getElementById(id); // Gets the input field based on its id.

	if(value == input.value){ // If the default value is equal to the current value.
		input.value = ''; // Empty It.
	}
} 
function ResetInput(value, id){ 
	var input = document.getElementById(id); // Gets the input field based on its id.
	if (input.value== '') {
		input.value = value;
	}
} 

// AJAX function
function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}


function myFocus(id){
	var focusarea =	document.getElementById(id);
	focusarea.focus();
}

function formHandler ( formid, fieldvalue )
{
	
	if (fieldvalue!='')
	{
		document.getElementById(formid).deleteid.value = fieldvalue;
	}
	
	
	document.getElementById(formid).submit();
} 

function polaroid_focus(polaroid)
{
	polaroid.className = "polaroid_focus clickable";
}

function polaroid_blur(polaroid)
{
	polaroid.className = "polaroid_blur clickable";
}

// CODE FOR THE MAIN MENU

var hideTimerId = -1;

function showSubMenu(id)
{
	/***CODE FOR NEW MENU****/
	//RESET MENU'S

	if (hideTimerId >= 0) {
		clearTimeout (hideTimerId);
	}

	for (var x=1; x <= 7; x++)
	{
		$('SubMenu_'+x).style.display = 'none';
		$('MainMenu_' + x).setStyle({background:'none'});
	}

	//ACTIVATE SELECTED MENU
	$('MainMenu_' + id).setStyle({background:'url(images/menu_bg_stroke_selected.gif) repeat-x'});
	$('SubMenu_' + id).style.display = 'block';
} 



function hideSubMenus() {
	if (hideTimerId >= 0) {
		clearTimeout (hideTimerId);
	}
	hideTimerId = setTimeout("hideSubMenusNow();",400)
}

function hideSubMenusNow()
{
	/***CODE FOR NEW MENU****/
	//RESET MENU'S

	for (var x=1; x <= 7; x++)
	{
		$('SubMenu_'+x).style.display = 'none';
		$('MainMenu_' + x).setStyle({background:'none'});
	}

	for (var x=1; x <= 7; x++)
	{
		$('SubMenu_'+x).style.display = 'none';
		
	}
} 

//FRONTPAGE
page_nr = 0;
timer_id = null;

function tour_page(nr) {
	if (nextPageTimer != null) clearTimeout(nextPageTimer);
	nextPageTimer = setTimeout("nextPage();",7000);
	
	if (nr == page_nr) return;
		
	page_nr = nr;
	
	queue = Effect.Queues.get('tour');
	queue.each(function(effect) { effect.cancel(); });

	//Effect.Queue.each(function(effect) { effect.cancel(); });
	
	xvalue = (nr * -574);
	new Effect.Move('tour_back', { x: xvalue, y: 0, mode: 'absolute', duration: 1, queue: { scope: 'tour' }});//, transition: Effect.Transitions.spring, duration: 2.0
	if (timer_id != null) clearTimeout(timer_id);
	timer_id = setTimeout("showText();",950);
	$('tour_title').hide();
	$('tour_text').hide();
	
	for (i=0;i<3;i++)
	{
		$('tour_btn'+i).removeClassName('tour_btn_select');
	}
	$('tour_btn'+nr).addClassName('tour_btn_select');
	return false;
}

function nextMediaPage(nr) {
	nextvalue = (nr+1)%5;
	setTimeout("nextMediaPage(nextvalue);",4100);
	yvalue = (nr * -120);
	new Effect.Move('media_content', { x: 0, y: yvalue, mode: 'absolute', duration: 1.5, queue: { scope: 'media' }});//, transition: Effect.Transitions.spring, duration: 2.0
}

nextPageTimer = null;

function nextPage() {
	tour_page((page_nr+1)%3);
}



function showText() {
	
	fontpage_text_array = new Array(new Array(TEXT_FRONTPAGE_TOPBAR1, TEXT_FRONTPAGE_TOPBAR1_MORE), new Array(TEXT_FRONTPAGE_TOPBAR2, TEXT_FRONTPAGE_TOPBAR2_MORE),
		new Array(TEXT_FRONTPAGE_TOPBAR3, TEXT_FRONTPAGE_TOPBAR3_MORE));

	$('tour_title').innerHTML = fontpage_text_array[page_nr][0];
	$('tour_text').innerHTML = fontpage_text_array[page_nr][1];
	new Effect.Appear('tour_title', {duration: 0.25, queue: { scope: 'tour' }});
	new Effect.Appear('tour_text', {duration: 0.25, queue: { scope: 'tour' }});
}

var scores = new Array(75701120,137400,12521,14567 );
var upcview = new Array(42,1,0.25,0.2 );
var upcreal = new Array(172800,311,103,86);
var startd = new Date(2010, 0, 10);
var startdpage = new Date();
var score= new Array(0,0,0,0);

function init_scores() {
	time_def = ((startdpage.getTime() - startd.getTime()) / 86400000);
	for (i=0;i<4;i++)
	{
		score[i] = Math.round(( scores[i] + ( time_def * upcreal[i]) ));
	}
}

init_scores();

function update_scores() {
	var d=new Date();
	var time_def = ((d.getTime() - startdpage.getTime()) / 1000);	//sec
	
	randomnumber=Math.floor(Math.random()*4);
	
	score_temp = Math.round(( score[randomnumber] + ( time_def * upcview[randomnumber]) ));
	
	score_str = score_temp.toString();
	if (score_str.length>3) score_str = score_str.substr(0, score_str.length-3) + '.' + score_str.substr(score_str.length-3,3);
	if (score_str.length>7) score_str = score_str.substr(0, score_str.length-7) + '.' + score_str.substr(score_str.length-7,7);
	$('score_'+randomnumber).innerHTML = score_str;
	setTimeout("update_scores();", Math.round(Math.random() * 300));
}

function keep_scrolling(id, width, startnr, maxnr, duration, time) {
	new Effect.Move(id, { x: (-1*width*startnr), y: 0, mode: 'absolute', duration: duration}); 
	setTimeout("keep_scrolling('"+id+"',"+width+","+((startnr+1)%maxnr)+","+maxnr+","+duration+","+time+");", time);
	return false;
}


// CALL WAKEUP.PHP TO MAKE SURE THE USER DOESN'T GET LOGGED OUT WHILE WEBSITE IS STILL OPEN
function wakeup() {
                new Ajax.Updater('wakeup', 'wakeup.php');
                setTimeout("wakeup();",3300000); // an hour
}


//change language
function change_user_lang(user_lang)
{	
	  // change lang in user profile
	  new Ajax.Request('change_lang.php', {
      method: 'post',
      parameters:{ lang : user_lang},
      onSuccess: function () {window.location = window.location.href;},
      onFailure: function (err) {alert(err.responseText); }
  });
}

// google map api function for address.
  var obj_result;
  var geocoder;
  var blind_down;
  var stored_index;	
  var location_changed=false;
	

  function initialize_googlemap()
  { 
	location_changed=false;
	geocoder = new google.maps.Geocoder();
	obj_result = new Object();
	number_result = 0;
	stored_index = -1;
	blind_down=false;
	document.getElementById("selected_address").innerHTML='';
	document.getElementById("validate_selected_address").innerHTML='';
	document.getElementById("address_search_result").innerHTML ='';
	document.getElementById("city").value='';
	document.getElementById("latitude").value='';
	document.getElementById("longitude").value='';
	document.getElementById("formatted_address").value='';
	search_address();	
  }	

  function search_address() 
  {
			var address = document.getElementById("address").value + ','+ document.getElementById("country").value ;		
			if (geocoder) 
			{
			  geocoder.geocode( { 'address': address,'language' : CURRENT_LANG}, function(results, status) 
				{	
					if (status==google.maps.GeocoderStatus.OK) 
					{						
						blind_down=false;
						var country_array = new Array();
						obj_result = results;
						document.getElementById("address_search_result").innerHTML = MAP_MORE_RESULTS + '<br>';				
						last_index = results.length;
						var country_array_size=0;
						for(var i=0;i<last_index;i++)
						{
							for(var j=0;j<results[i].address_components.length;j++)
							{
								var component_type=results[i].address_components[j].types;
								if (component_type.indexOf('country')!=-1)
								{
									if(results[i].address_components[j].short_name==document.getElementById("country").value)
									{
									country_array[country_array_size]=i;
									country_array_size++;
									break;
									}
								}
							}
						}
						
						
						for(var k=0;k<country_array_size;k++)
						{				
							i=country_array[k];
							for(var j=0;j<results[i].address_components.length;j++)
							{	
								var component_type=results[i].address_components[j].types;
								if (component_type.indexOf('locality')!=-1)
								{
									number_result++;
									stored_index=i;									
									document.getElementById("address_search_result").innerHTML+='<br/><div class="address_search_result"  readonly="readonly" onclick="select_address('+i+');">'+results[i].formatted_address+'</div>';	
									break;
								}
							}
						}
							if(number_result==0)
							{
								document.getElementById("address_search_result").innerHTML='';
								document.getElementById("selected_address").innerHTML = MAP_NO_RESULTS;
								validatecity('validate_selected_address');
							}
							else if(number_result==1)
							{
								document.getElementById("address_search_result").innerHTML='';
								select_address(stored_index);
							}
							else
							{
								var result_height = (last_index*35+75);
								document.getElementById("address_search_result").style.height = result_height;
								new Effect.BlindDown("address_search_result");
								blind_down=true;
							}
					}
					else
					{	
						document.getElementById("address_search_result").innerHTML='';
						document.getElementById("selected_address").innerHTML = MAP_NO_RESULTS;
						validatecity('validate_selected_address');
					}			
				}
			  );
			}
			
	}
  
 function select_address(index)
 {
 	for(var j=0;j<obj_result[index].address_components.length;j++)
		{
			var component_type=obj_result[index].address_components[j].types;
			if (component_type.indexOf('locality')!=-1)
			{			
			document.getElementById("selected_address").innerHTML=obj_result[index].formatted_address;
			document.getElementById("formatted_address").value=obj_result[index].formatted_address;
			document.getElementById("city").value=obj_result[index].address_components[j].short_name;
			document.getElementById("latitude").value=obj_result[index].geometry.location.b;
			document.getElementById("longitude").value=obj_result[index].geometry.location.c;	
			validatecity('validate_selected_address');
			}
		}
	if(blind_down)
	new Effect.BlindUp("address_search_result");
 }
// google map api function.
 
 /**
* Window popup
*/
function popup(url, width, height, name)
{
	if (!name)
	{
		name = '_popup';
	}

	window.open(url.replace(/&amp;/g, '&'), name, 'height=' + height + ',resizable=yes,scrollbars=yes, width=' + width);
	return false;
}

 
 
 
 
 
 
 
 
 
//-->