/**
 * @author jfdesgagne
 */
var JeldWen = new Class({
    subMenu:null,
	imagesGallery:null,
	caracteristics:null,
	tips:null,

    initialize: function(options){
		this.verifyPages();
		this.changeTargetLinks();
		this.fixCss();
    },

	fixCss: function() {
		/*
		if(Browser.Engine.webkit419 || Browser.Engine.webkit420) {
			$('top').setStyle('margin-top', '0.5em');
		*/
	},

	changeTargetLinks:function() {
		$$('a').each(function(el) {
			if (el.hasClass("_blank")) el.target = "_blank";
		})
	},

	verifyPages:function() {
		switch(page_id) {
			case "home":
				new Swiff('../assets/file_library/slideshow/slideshow_'+lang+'.swf', {
				    container: $('slideshow'),
					id:'product3D_swiff',
				    width:889,
				    height:352,
				    params:{
				       // wmode:'transparent',
				        allowscriptaccess:'sameDomain'
					},
					vars: {
						path:'../assets/file_library/slideshow/',
						models:'image1.jpg,image2.jpg,image3.jpg,image4.jpg'
						//viewText:'See the 3D view'
				    }
				});
			break;
			case "page_imagesGallery":
				this.imagesGallery = new ImagesGallery($('imagesGallery_slider'), $$('#imagesGallery_photoFilm ul li'), {menu:true});
			break;
			case "page_products":
				var undefined;
				if($('imagesGallery_slider')) this.imagesGallery = new ImagesGallery($('imagesGallery_slider'), $$('#imagesGallery_photoFilm ul li'));
				if (!$('image3D') && products3D!='') {

					if (lang == 'en') {
						viewText = 'Slide to rotate product';
						auralastText = 'More information on Auralast';
					} else {
						viewText = 'Déplacer pour tourner';
						auralastText = 'Plus d’information sur AuraLast';
					}

					var swiff = new Swiff('../assets/file_library/products3D/products3D.swf', {
						container: $('product3D'),
						id: 'product3D_swiff',
						width: 391,
						height: 508,
						params: {
							//  wmode:'transparent',
							allowscriptaccess: 'sameDomain'
						},
						vars: {
							path: '../assets/file_library/products3D/',
							//path: 'http://www.donatflamand.com/dap/assets/file_library/products3D/',
							models: products3D,
							modelType: modelType,
							auralastLink:"modules/auralast.php",
							viewText:viewText,
							auralastText:auralastText
						}

					});

					if ($('changeModel_wood')) {
						$('changeModel_wood').addEvent('click', function(event){
							Swiff.remote(swiff, 'changeModel', "wood");
						}.bind(this));
					}
					if($('changeModel_aluminium')) {
						$('changeModel_aluminium').addEvent('click', function(event){
							Swiff.remote(swiff, 'changeModel', "aluminium");
						}.bind(this));
					}
				}



				/*
				$$('.tooltip_product').each(function(el) {
					el.href = root+"assets/file_library/tooltips/"+el.href.substring(el.href.lastIndexOf(lang+'/')+3);
					el.store('tip:title', '');
 					el.title = '::<img src="'+el.href+'" alt="'+el.title+'" />';
				});
				*/

				this.caracteristics = new Caracteristics();

			break;

			case "splash":

			break;

			case "page_infolettres":
				new InfoLettres();
			break;

			case "page_friend":
				new Friend();
			break;

			case "page_auralast":
				var swiff = new Swiff(root+'assets/file_library/videos/PlayerVideo.swf', {
					container: $('playerVideo'),
					id: 'playerVideo_swiff',
					width: 645,
					height: 375,
					params: {
						wmode:'transparent',
						allowscriptaccess: 'sameDomain'
					},
					vars: {
						videoQueue: lang+'/034.flv|*|'+lang+'/035.flv|*|'+lang+'/036.flv'
					}
				});
			break;
		}

		if (page_id != "splash") {
			this.subMenu = new SubMenu();
			var restrict = "donatflamand.com/"+lang;
				
			if (page_id != "home" && $('pageSearch')) {
				var label = "Donat Flamand";
				var size = GSearch.SMALL_RESULTSET;
				var webSearch = new Search({
					'restrict': restrict,
					'label': label,
					'size': size,
					'idButton': 'pageBtnSearch',
					'idInput': 'pageSearch',
					'top': 22,
					'right': 36
				});
			}

			var webSearch2 = new Search({
				'restrict': restrict,
				'label': label,
				'size': size,
				'idButton': 'btnSearch',
				'idInput': 'search',
				'bottom': 40,
				'right': 19
			});

			/*
			if ($('pagePrint')) {
				$('pagePrint').addEvent('click', function(event){
					window.print();
				});
			}
			*/
		}

	}
});


function trace(value) {
	alert('alert:'+value);
}

window.addEvent('domready', function() {
	var jeldWen = new JeldWen();
});
