  //////////////////////////////////////////
 // MyBizznet team work copyright © 2008 //
//////////////////////////////////////////

// Application name: ETEP Website
// Version: 1
// Last update : 11/04/2008
// Author:  Mathieu Caille
// Team: MyBizznet core team [All rights reserved]
// Email:   mathieu.caille@mybizznet.com
// MyBizznet All the tools for my business
// website http://www.mybizznet.com
/////////////////////////////////////////////////////////////////////////////////////

////// This JavaScript Document must work with Prototype FrameWork
////// Greate thank to the Prototype Core Team 
////// Website http://www.prototypejs.org
////// Don't Forget to Donate money if you use this framework
////// Copyright (c) 2005-2008 Sam Stephenson (http://www.prototypejs.org) 

////// This JavaScript Document must work with Script.aculo.us
////// Greate thank to the Script.aculo.us Core Team 
////// Website http://script.aculo.us
////// Don't Forget to Donate money if you use this framework
////// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)

/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
////// Menu on IE

function suckerfish(type, tag, parentId) {
	if (window.attachEvent) {
		window.attachEvent("onload", function() {
			var sfEls = (parentId==null)?document.getElementsByTagName(tag):document.getElementById(parentId).getElementsByTagName(tag);
			type(sfEls);
		});
	}
}

sfHover = function(sfEls) {
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

suckerfish(sfHover, "LI", "menu");


////// Company menu action

function CompanyContents() {
	Event.observe("select_company","click",detectID);
	function detectID(e)
	{
	new Effect.Parallel([
		new Effect.Fade('mainpage_contents'),
		new Effect.Fade('left_panel'),
		new Effect.SlideDown('panel_ban'),
		new Effect.Appear('contents')
		]);
	elementid = Event.element(e);
	new Ajax.Updater('contents', 'REQUESTS/COMPANY/content.php', 
					 {
						 parameters: {ID: elementid.id}
						 
					 });
	new Ajax.Updater('panel_ban', 'REQUESTS/COMPANY/img.php', 
					 {
						 parameters: {ID: elementid.id}
						 
					 });
	
	}};
Event.observe(window, "load", CompanyContents, false);


////// Product recorder menu action

function ProductRecorder() {
	Event.observe("select_recorder","click",detectID);
	function detectID(e)
	{
	new Effect.Parallel([
		new Effect.Fade('mainpage_contents'),
		new Effect.SlideDown('panel_ban'),
		new Effect.Appear('contents'),
		new Effect.Appear('left_panel')
		]);
	elementid = Event.element(e);
	new Ajax.Updater('left_panel', 'REQUESTS/PRODUCT/menu_onglet.php', 
					 {
						 parameters: {ID: elementid.id}
						 
					 });
	new Ajax.Updater('contents', 'REQUESTS/PRODUCT/onglet.php', 
					 {
						 parameters: {ID: elementid.id}
						 
					 });
	new Ajax.Updater('panel_ban', 'REQUESTS/PRODUCT/img.php', 
					 {
						 parameters: {ID: elementid.id}
						 
					 });
	
	}};
Event.observe(window, "load", ProductRecorder, false);


////// Function view edit panel for company

function ViewCompanyEditPanel() {
	new Ajax.Updater('contents' , 'REQUESTS/COMPANY/edit.php',  {
						 evalScripts:true,
						 parameters: {ID: $F('ID')}
					 });
	new Effect.Parallel([new Effect.Fade ('mainpage_contents'),
						 new Effect.Appear ('contents')]);
	
	}
	
////// Function company save update

function UpdateCompany() {
	new Ajax.Request('REQUESTS/COMPANY/edit_save.php',
	{
	parameters: $('edit_company').serialize(),
	onSuccess: function(transport) {
	new Ajax.Updater('contents' , 'REQUESTS/COMPANY/content.php' , { parameters: { ID: $F('company_id')}});	
	}
						});}
	

/////////////////////////////////////////////////////////////////////////////////////
// Function View Create account panel

function ViewCreateAccountPanel() {
	new Ajax.Updater('contents' , 'REQUESTS/CREATE_ACCOUNT.php' , { evalScripts:true } );
	new Ajax.Updater('left_panel' , 'REQUESTS/ACCOUNT/about.php');
	new Effect.Parallel([new Effect.Fade ('mainpage_contents'),
						 new Effect.Appear ('contents')]);
	
	}
	
// Function View create customer account panel
	
function ViewCreateCustomerPanel() {
	new Effect.Parallel([
		new Effect.Fade ('about_account'),
		new Effect.Fade ('about_visitor_account'),
		new Effect.SlideDown ('about_customer_account'),
		new Effect.Appear ('create_customeraccocunt'),
		new Effect.Appear ('form_register')
	]);
	}

function SwitchOffCreateCustomerPanel() {
	new Effect.Parallel([
		new Effect.Fade ('about_account'),
		new Effect.Fade ('about_customer_account'),
		new Effect.Fade ('create_customeraccocunt'),
		new Effect.SlideDown ('about_visitor_account'),
		new Effect.Appear ('form_register')
	]);
	}
	
	
function ViewInfo() {
	new Effect.toggle ('info_serial','blind');
	}
	
function RegisterConfirmation() {
	new Ajax.Updater('contents' , 'REQUESTS/ACCOUNT/confirmation.php');
	}



/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
// Header panel


function ViewAbout() {
	new Ajax.Updater('contents' , 'REQUESTS/COMPANY/content.php', { parameters: { ID: '1'}});
	new Ajax.Updater('panel_ban' , 'REQUESTS/COMPANY/img.php', { parameters: { ID: '1'}});
	new Effect.Parallel([new Effect.Fade ('mainpage_contents'),
						 new Effect.Appear ('contents'),
						 new Effect.SlideDown ('panel_ban')
						 ]);
}


function ViewCareer() {
	new Ajax.Updater('contents' , 'REQUESTS/COMPANY/content.php', { parameters: { ID: '5'}});
	new Ajax.Updater('panel_ban' , 'REQUESTS/COMPANY/img.php', { parameters: { ID: '5'}});
	new Effect.Parallel([new Effect.Fade ('mainpage_contents'),
						 new Effect.Appear ('contents'),
						 new Effect.SlideDown ('panel_ban')
						 ]);
}

function ViewContact() {
	new Ajax.Updater('contents' , 'REQUESTS/COMPANY/content.php', { parameters: { ID: '7'}});
	new Ajax.Updater('panel_ban' , 'REQUESTS/COMPANY/img.php', { parameters: { ID: '7'}});
	new Effect.Parallel([new Effect.Fade ('mainpage_contents'),
						 new Effect.Appear ('contents'),
						 new Effect.SlideDown ('panel_ban')
						 ]);
}

function ViewTechnology() {
	new Ajax.Updater('contents' , 'REQUESTS/COMPANY/content.php', { parameters: { ID: '6'}});
	new Ajax.Updater('panel_ban' , 'REQUESTS/COMPANY/img.php', { parameters: { ID: '6'}});
	new Effect.Parallel([new Effect.Fade ('mainpage_contents'),
						 new Effect.Appear ('contents'),
						 new Effect.SlideDown ('panel_ban')
						 ]);
}

/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
// Footer panel 

function ViewCopyright() {
	new Ajax.Updater('contents' , 'REQUESTS/FOOTER/copyright.php');
	new Effect.Parallel([new Effect.Fade ('mainpage_contents'),
						 new Effect.Appear ('contents')]);
}

function ViewPrivacy() {
	new Ajax.Updater('contents' , 'REQUESTS/FOOTER/privacy.php');
	new Effect.Parallel([new Effect.Fade ('mainpage_contents'),
						 new Effect.Appear ('contents')]);
}

function ViewWebtechnology() {
	new Ajax.Updater('contents' , 'REQUESTS/FOOTER/webtech.php');
	new Effect.Parallel([new Effect.Fade ('mainpage_contents'),
						 new Effect.Appear ('contents')]);
}


/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
// News & publications

function ViewEvents() {
	new Ajax.Updater('contents' , 'REQUESTS/COMPANY/events.php');
	new Effect.Parallel([new Effect.Fade ('mainpage_contents'),
						 new Effect.Appear ('contents')]);
}

// View an event 

function ViewEvent() {
	Event.observe("news_container","click",detectID);
	function detectID(e)
	{
elementid = Event.element(e);
	new Ajax.Updater('contents' , 'REQUESTS/PRODUCT/global.php' ,  { evalScripts:true , parameters: { ID: elementid.id }} , { onComplete: Lightview.updateViews() } );
	new Ajax.Updater('panel_ban' , 'REQUESTS/PRODUCT/ban.php' , { parameters: {  ID: elementid.id }
					 });
	new Ajax.Updater('left_panel' , 'REQUESTS/PRODUCT/left_panel.php' , { parameters: {ID: elementid.id }
					 });
	new Effect.Parallel([new Effect.Fade ('mainpage_contents'),
						 new Effect.Appear ('left_panel'),
						 new Effect.Appear ('contents')]);
	}};
	Event.observe(window, "load", ViewEvent, false);

/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
// Main page panel view product

function ViewProduct() {
	Event.observe("flightdatarecorder_panel","click",detectID);
	Event.observe("flighttestrecorder_panel","click",detectID);
	Event.observe("groundstation_panel","click",detectID);
	Event.observe("transportation_panel","click",detectID);
	Event.observe("software_panel","click",detectID);
	Event.observe("panel_ban","click",detectID);
	function detectID(e)
	{
	elementid = Event.element(e);
	new Ajax.Updater('contents' , 'REQUESTS/PRODUCT/global.php' ,  { evalScripts:true , parameters: { ID: elementid.id }} , { onComplete: Lightview.updateViews() } );
	new Ajax.Updater('panel_ban' , 'REQUESTS/PRODUCT/ban.php' , { parameters: {  ID: elementid.id }
					 });
	new Ajax.Updater('left_panel' , 'REQUESTS/PRODUCT/left_panel.php' , { parameters: {ID: elementid.id }
					 });
	new Effect.Parallel([new Effect.Fade ('mainpage_contents'),
						 new Effect.Appear ('left_panel'),
						 new Effect.Appear ('contents')]);
	}};
	Event.observe(window, "load", ViewProduct, false);
	
// List product panel

function ViewProductFromList() {
	Event.observe("product_list","click",detectID);
	function detectID(e)
	{
	elementid = Event.element(e);
	new Ajax.Updater('contents' , 'REQUESTS/PRODUCT/global.php' , { evalScripts:true , parameters: { ID: elementid.id }
					 });
	new Ajax.Updater('panel_ban' , 'REQUESTS/PRODUCT/ban.php' , { parameters: { ID: elementid.id }
					 });
	new Ajax.Updater('left_panel' , 'REQUESTS/PRODUCT/left_panel.php' , { parameters: { ID: elementid.id }
					 });
	new Effect.Parallel([new Effect.Fade ('mainpage_contents'),
						 new Effect.Appear ('left_panel'),
						 new Effect.SlideDown ('panel_ban'),
						 new Effect.Appear ('contents')]);
	
	}};
	
// View module of product	

function ViewModule() {
	Event.observe("card_panel","click",detectID);
	function detectID(e)
	{
	elementid = Event.element(e);
	new Ajax.Updater('contents' , 'REQUESTS/MODULE/global.php' , { parameters: { ID: elementid.id }
					 });
	new Ajax.Updater('panel_ban' , 'REQUESTS/MODULE/img.php' , { parameters: { ID: elementid.id }
					 });
	new Effect.Parallel([new Effect.Fade ('mainpage_contents'),
						 new Effect.Appear ('left_panel'),
						 new Effect.Appear ('panel_ban'),
						 new Effect.Appear ('contents')]);
	
	}};

/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
// Products javascripts actions

// View Global specification
function ViewGlobalSpecifications() {
	new Ajax.Updater('contents' , 'REQUESTS/PRODUCT/product_spe_global.php', {
						 parameters: {PRODUCT_ID: $F('ID')}
						 
					 });
	new Effect.SlideDown('contents');
}


// View Technical specification
function ViewTecnicalSpecifications() {
	new Ajax.Updater('contents' , 'REQUESTS/PRODUCT/product_spe_tech.php', {
						 parameters: {PRODUCT_ID: $F('ID')}
						 
					 });
	new Effect.SlideDown('contents');
}

// View Environmental specification
function ViewEnvironmentalSpecifications() {
	
	new Ajax.Updater('contents' , 'REQUESTS/PRODUCT/product_spe_envi.php', {
						 parameters: {PRODUCT_ID: $F('ID')}
						 
					 });
	new Effect.SlideDown('contents');
}


/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
// Contact form overlay windows


function OverlayContact() {
	Event.observe("contact_us", "click", function(event)	 {
    event.stop();
	Lightview.show({
	evalScripts:true,
	  href: 'send_mail.php',
	  rel: 'ajax',
	  title: 'etep.com > Contact us',
	  options: {
		evalScripts:true,
	    autosize: true,
		ajax: {
		  onComplete: function(){
		    // once the request is complete we observe the submit button
			$('contact_form').observe('submit', submitAjaxForm);
		  } 
	    }
	  }
	});
  });
};
Event.observe(window, "load", OverlayContact, false);


function OverlayContactBis() {
	Event.observe("contact_us_bis", "click", function(event)	 {
    event.stop();
	Lightview.show({
	evalScripts:true,
	  href: 'send_mail.php',
	  rel: 'ajax',
	  title: 'etep.com > Contact us',
	  options: {
		evalScripts:true,
	    autosize: true,
		ajax: {
		  onComplete: function(){
		    // once the request is complete we observe the submit button
			$('contact_form').observe('submit', submitAjaxForm);
		  } 
	    }
	  }
	});
  });
};
Event.observe(window, "load", OverlayContactBis, false);


// Submit contact form

function submitAjaxForm(event) {
  // block default form submit
  event.stop();
  new Ajax.Request('REQUESTS/MAIL/newaccount.php',
				{
				parameters: $('contact_form').serialize()});
  Lightview.show({
    href: 'confirm_mail.php',
    rel: 'ajax',
    options: {
      title: 'Thank you',
	  menubar: false,
	  topclose: true,
	  autosize: true,
      ajax: {
        parameters: Form.serialize('contact_form') // the parameters from the form
      }
    }
  });
}

/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
// Autocomplete of search input

function AutocompSearch() {
	new Ajax.Autocompleter('productsearch' , 'suggest' , 'REQUESTS/SEARCH/search.php' ,
						      { 
							  method: 'post',
							  paramName: 'search'});
							}
Event.observe(window, 'load', AutocompSearch);

// Clear defaut value of search input

function ClearSearchField(thefield){

if (thefield.defaultValue==thefield.value)

thefield.value = ""

}

// Search results

function ViewSearchResult() {
	new Ajax.Updater('contents' , 'REQUESTS/SEARCH/results.php' , { parameters: { VALUE: $F('productsearch')}});
	new Effect.Parallel([new Effect.Fade ('mainpage_contents'),
						 new Effect.Appear ('contents')]);
	}