var app_ww, app_wh, // Window width/height
    app_agent = navigator.userAgent.toLowerCase(), // Browser type
    app_version = parseInt(navigator.appVersion),
    app_is_ie = app_agent.indexOf('msie') >= 0 && app_agent.indexOf('opera') < 0,
	app_is_ie6 = $.browser.msie && /MSIE (6\.)/.test(navigator.userAgent),
    app_is_opera = app_agent.indexOf('opera') >= 0,
    app_is_safari = app_agent.indexOf('safari') >= 0;


$(document).ready(function(){

	app_getwinsize();
	//centerMainWrapper();
	manageFotoliaUI();
/*
	$('#info-noel-header').mouseover(function () {
		$('#info-noel-text').show();
	}).mouseout(function () {
		$('#info-noel-text').hide();		
	});
*/
});


function app_getwinsize() {
  if (typeof(window.innerWidth) == 'number') {
    app_ww = window.innerWidth; app_wh = window.innerHeight;
  } else if (document.documentElement.clientHeight) {
    app_ww = document.documentElement.clientWidth; app_wh = document.documentElement.clientHeight;
  } else {
    app_ww = document.body.clientWidth; app_wh = document.body.clientHeight;
  }
}


function centerMainWrapper() {
	var mainWrapperWidth = $('#mainWrapper').width();
	//var actualMarginLeft = $('#mainWrapper').css('margin-left');
	var marginLeft = (app_ww - mainWrapperWidth)/2;
	//if (Math.abs(marginLeft - actualMarginLeft)>10) {
	$('#mainWrapper').css('margin-left', marginLeft+ 'px');
	//alert(app_ww);
	//} 
}

function loadSwfUpload(){
	/* SWFUpload */
	swfu = new SWFUpload({
		// Backend settings
		upload_url: "upload.php", // Relative to the SWF file, you can use an absolute URL as well.
		file_post_name: "swf_filename",
		
		// Flash file settings
		file_size_limit: "32000", // 32 MB
		file_types: "*.jpg", // or you could use something like: "*.doc;*.wpd;*.pdf",
		file_types_description: "Images au format JPG",
		file_upload_limit: "0", // Even though I only want one file I want the user to be able to try again if an upload fails
		file_queue_limit: "0", // this isn't needed because the upload_limit will automatically place a queue limit
		flash_color: "#000000",
		// Event handler settings
		swfupload_loaded_handler: swfUploadLoaded,
		
		//file_dialog_start_handler : fileDialogStart,		// I don't need to override this handler
		file_queued_handler: fileQueued,
		file_queue_error_handler: fileQueueError,
		file_dialog_complete_handler: fileDialogComplete,
		
		//upload_start_handler : uploadStart,	// I could do some client/JavaScript validation here, but I don't need to.
		upload_progress_handler: uploadProgress,
		upload_error_handler: uploadError,
		upload_success_handler: uploadSuccess,
		upload_complete_handler: uploadComplete,
		
		// Flash Settings
		flash_url: "swfupload_f9.swf", // Relative to this file
		// UI settings
		swfupload_element_id: "flashUI", // setting for the graceful degradation plugin
		degraded_element_id: "degradedUI",
		
		custom_settings: {
			progress_target: "fsUploadProgress",
			upload_successful: false
		},
		
		// Debug settings
		debug: false
	});
}

function manageFotoliaUI(){
	$("#search_img").click(function(){
     	$("#fotoliaUI").show(1000);
    });	
}

