// JavaScript Document

// HTML Example: Media Kit
// This function set represents commands for the Media Kit Project
// July 2008 Jaleel Beck

//initialize global variables
var d = 0, e = 0, f = 0, click_count = 0;
var click_timer = null, timer = null, dimtimer = null;
var over = false, over_top = false;
var url_query = "", nav_select = "", highlight_nav = "", spos = "", spos_selected = "";
var secondDocument = null;
var basemkit = "http://www.tmccreatives.com/mediakit/";

var preload = '<embed src="assets/flash/preloader.swf" quality"="high" wmode="transparent" bgcolor=#2b2b2b width="190" height="42" name="myMovieName" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';

var errormsg = '<a href="' + basemkit + 'index-intro.html"><img src="assets/images/error_message.png" width="195" height="124" border="0"></a>';

// Activate specific events on document ready
$(document).ready(function() {
	
	
	
	$("[id^='intro']").click(function() {
		var dbl_click = clickChecker();
		if (dbl_click) {
			var nav_select = $(this).attr("title");
			introAnimEnd(nav_select);
			$("#valuepass").text(nav_select);
		}
	});
	
	$("#win_close").click(function() {
		var dbl_click = clickChecker();
		if (dbl_click) {
			
			$("#efx_window_content").fadeOut({duration:300, queue:"global"});					
			
			$("#efx_win_container").animate({top:"-1000px"}, {duration:500, queue:"global", scope:"winUp"});
			
			// Fade in flash topic, photo
			$("#title_topic").fadeIn({queue:"global", scope:"flashIn"});
			$("#photo_topic").fadeIn({queue:"global", scope:"flashIn"});
			
			$("#efx_win_container").hide({queue:"global"});
			
		}
	});
	
	$(window).resize(function() {
		resizeScreen();				 
	});
	
});


// Present Intro section before opening application window 
$(document).ready(function() {
		$("#efx_win_container").show();
		$("#efx_window").animate({top:"700px", queue: "global"}, 1, function() {
			// Fade out div to reveal background
			$("#title_mkit_intro").animate({top: "200px"}, {duration:1, queue: "global"});
			$("#efx_window").fadeOut({duration: 1000, queue: "global"});
			$("#efx_win_container").hide({queue:"global"});
			
			$("#title_mkit_enter").animate({top: "195px"}, {duration:300, queue: "global", scope: "enter"});
			
			$("#title_mkit_enter").click(function() {
				openWindow();									  
			});
			
			// Fade in Footer
			$("#container_footer_intro").animate({opacity: "1"}, {duration: 500, queue: "global", scope: "begin"});
		});
});



// Open new window at default 980x768 dimensions, removes most browser GUI elements from IE, Firefox and Safari
function openWindow() {
	window.open("index-intro.html","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width=980, height=768");
}

// Resize window to proper width when resized              
function resizeScreen() {
	//win_height = document.documentElement && document.documentElement.clientHeight;
	//if (win_height < 768) {win_height = 768};
	window.resizeTo(980,768);
}

// Testing: Display SWF content in topic, photo divs
function loadTopicAndPhoto(topic,photo) {
	
	var topic_flash = "assets/flash/" + topic + ".swf";
	var photo_flash = "assets/flash/" + photo + ".swf";
	
	var params = {
 	 menu: "false",
	 wmode: "transparent"
	};
		
	swfobject.embedSWF(topic_flash, "title_topic_flash", "400", "90", "8.0.0", "#222021", "/assets/flash/expressInstall.swf", params);
	swfobject.embedSWF(photo_flash, "photo_topic_flash", "580", "90", "8.0.0", "#222021", "/assets/flash/expressInstall.swf", params);
}

// ANIMATION FUNCTIONS ********************************************************************** //

function introAnimBegin() {
			$(document).ready(function() {

				// Preload all navigation images in a hidden div
				function preloadNav() {
				var nav_array = new Array('demographic', 'samples', 'solutions', 'standards', 'testimonials');
				var nav_max = nav_array.length;
				var all_nav_image = "";
				var base_images = basemkit + "assets/images/"
				nv = 0;
					do {
						all_nav_image += '<img src="'+ base_images +'nav_mkit_intro_' + nav_array[nv] + '.png"><img src="'+ base_images +'nav_mkit_intro_' + nav_array[nv] + '_on.png"><img src="'+ base_images +'nav_mkit_intro_' + nav_array[nv] + '-trans.png"><img src="'+ base_images +'nav_mkit_intro_' + nav_array[nv] + '_on-trans.png">';
						nv++;
					} while (nv < nav_max);
					$("#test").html(all_nav_image);
				}
				
				preloadNav();
				
				// Position main container
				$("#container_main").animate({top:"100px"}, {duration: 1, queue: "global"});
				
				// Mkit logo down
				$("#title_mkit_intro").animate({opacity: "1"}, {duration: 500, queue: "global", scope: "mkit_title"});
				$("#title_mkit_intro").animate({top: "-110px"}, {duration: 500, queue: "global",  scope: "mkit_title"});
				
				// Fade in Footer
				$("#container_footer_intro").animate({opacity: "1"}, {duration: 500, queue: "global", scope: "mkit_title"});
				
				// Dividers move from center to top, bottom
				$("#divider_bartop_intro").fadeIn({duration: 500, queue: "global", scope: "divbar"});
				$("#divider_bartop_intro").animate({top: "-41px"}, {duration:500, easing:"swing", queue: "global",  scope: "divbar"});
				
				$("#divider_barbottom_intro").fadeIn({duration: 500, queue: "global", scope: "divbar"});
				$("#divider_barbottom_intro").animate({top: "246px"}, {duration:500, queue: "global",  scope: "divbar"});
				
				
				// Create Intro player + tiny flash player divs
				var cif = document.createElement("div");
				cif.setAttribute("id", "content_intro_flash");
				document.getElementById("content_intro").appendChild(cif);
				// Try embedding SWF into media though javascript
				// create SWF for intro
				var att_cif = { data:"assets/flash/mkit_video_intro.swf", width:"980", height:"300" };
				var par_cif = { menu:"false" };
				var par_cif = { wmode:"transparent" };
				var id_cif = "content_intro_flash";
				swfobject.createSWF(att_cif, par_cif, id_cif);
				
				var tpf = document.createElement("div");
				tpf.setAttribute("id", "tiny_player_flash");
				document.getElementById("tinyplayer").appendChild(tpf);
								
				var att_tpf = { data:"assets/sounds/mediakit_intromusic.swf", width:"0", height:"0" };
				var par_tpf = { menu:"false" };
				var par_tpf = { wmode:"transparent" };
				var id_tpf = "tiny_player_flash";
				swfobject.createSWF(att_tpf, par_tpf, id_tpf);
								
				$("#content_intro").fadeIn({duration:500, queue: "global"});
				
				$("#container_nav_intro").fadeIn({duration:500, queue: "global", scope: "nav_intro"});
				$("#container_nav_intro").animate({top: "-55px"}, {duration:500, queue: "global", scope: "nav_intro"});
			});
}

// Close existing elements, load new page and display selected content in new content div
function introAnimEnd(nav_select) {
				
				//Control intro music fadeout
				//------------Get a reference to the SWF--------------------------
				//This function works for both IE and Mozilla Firefox
				
				function getFlashMovieObject(movieName)
				{
				//alert(movieName);

				  if (window.document[movieName]) 
				  {
					  return window.document[movieName];
				  }
				  if (navigator.appName.indexOf("Microsoft Internet")==-1)
				  {
					if (document.embeds && document.embeds[movieName])
					  return document.embeds[movieName]; 
				  }
				  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
				  {
					return document.getElementById(movieName);
				  }
				}
				
				var movie = getFlashMovieObject("tiny_player_flash");			
								
				// Checks if movie is completely loaded.
				// Returns true if yes, false if no.
				function movieIsLoaded (movie) {
					// First make sure the movie's defined.
					if (typeof(movie) != "undefined") {
					// If it is, check how much of it is loaded.
					return movie.PercentLoaded() == 100;
				  } else {
					// If the movie isn't defined, it's not loaded.
					return false;
				  }
				}
				
				if(movieIsLoaded(movie)) {
					movie.Play();
				}
				
				
				// Nav closes into content
				$("#container_nav_intro").animate({opacity: "0"}, {duration:500, queue: "global", scope: "nav_outro"});
				$("#container_nav_intro").animate({top: "-85px"}, {duration:500, queue: "global", scope: "nav_outro"});
				
				// Content fades to black, then content container fades out
				$("#content_intro").fadeOut({duration:500, queue: "global"});
				
				// Dividers fade while moving up
				$("#divider_bartop_intro").animate({opacity: "0"}, {duration: 500, queue: "global", scope: "all_outro"});
				$("#divider_bartop_intro").animate({top: "-60px"}, {duration:500, queue: "global",  scope: "all_outro"});
				
				$("#divider_barbottom_intro").animate({opacity: "0"}, {duration: 500, queue: "global", scope: "all_outro"});
				$("#divider_barbottom_intro").animate({top: "-60px"}, {duration:500, queue: "global",  scope: "all_outro"});
				
				// Mkit logo up
				$("#title_mkit_intro").animate({opacity: "0"}, {duration: 500, queue: "global", scope: "all_outro"});
				$("#title_mkit_intro").animate({top: "-140px"}, {duration: 500, queue: "global",  scope: "all_outro"});
				
				// Fade Out Footer
				$("#container_footer_intro").animate({opacity: "0"}, {duration: 500, queue: "global", scope: "all_outro"});
				
				$("#container_main").animate({top:"0px"}, {duration: 1, queue: "global"}); 	
				$("#container_footer_intro").hide({duration:2, queue: "global"});
								
				// Animate section GUI
				$("#test").animate({top:"0px"}, 2000, function() {				
					sectionIntroAnimBegin(nav_select)
					}
				);

	return false;

}

// Load section index, animate initial elements in place, then load section content via ajax.  Needs to resize content div for content, or scroll
function sectionIntroAnimBegin(nav_select) {
		$("#container_main").load("index-section.html", function() {
		navControl();
		$("#container_footer").animate({opacity: "1"}, {duration: 500, queue: "global", scope: "mkit_title"});
		
		// Header drops into place
		$("#container_header").fadeIn({duration: 500, queue: "global", scope: "sect_nav_intro"});
		$("#container_header").animate({top: "20px"}, {duration: 500, queue: "global", scope: "sect_nav_intro"});
		
		// Display 1st div bar, then content container
		$("#divider_bartop").fadeIn({duration: 300, queue: "global", scope: "topdivbar"});
		$("#divider_bartop").animate({top: "0px"}, {duration: 500, queue: "global", scope: "topdivbar"});
		
		$("#test").animate({top:"-400px", queue: "global"}, 10, function() {				
			loadTopicAndPhoto('flash_topic_' + nav_select,'flash_photo_' + nav_select)
		});
			
		$("#title_topic").fadeIn({duration: 1000, queue: "global", scope: "btmdivbar"});
		$("#photo_topic").fadeIn({duration: 1000, queue: "global", scope: "btmdivbar"});
				
		// Display and lower second div bar, then display footer
		$("#divider_barbottom").fadeIn({duration: 300, queue: "global", scope: "btmdivbar"});
		$("#divider_barbottom").animate({top: "410px"}, {duration: 500, queue: "global", scope: "btmdivbar"});
		
		$("#content_section_background").fadeIn({queue:"global", duration:500});
		$("#content_section_background").queue(function() {
												
				var section_url = "pages/" + nav_select + "/index.html";
				loadTopic(section_url);
				$(this).dequeue();
		});
		
		// Create, drop and fade in music player
		// Create Intro player + tiny flash player divs
		var mpf = document.createElement("div");
		mpf.setAttribute("id", "media_player_flash");
		document.getElementById("mediaplayer").appendChild(mpf);
		// Try embedding SWF into media though javascript
		// create SWF for intro
		var att_mpf = { data:"http://www.tmccreatives.com/mediakit/assets/sounds/mcplayer_mediakit.swf", width:"215", height:"45" };
		var par_mpf = { menu:"false" };
		var par_mpf = { wmode:"transparent" };
		var id_mpf = "media_player_flash";
		swfobject.createSWF(att_mpf, par_mpf, id_mpf);
		
		$("#mediaplayer").show({queue: "global", scope: "mediaplayer"});
		$("#mediaplayer").animate({top: "605px", left:"740px"}, {duration: 500, queue: "global", scope: "mediaplayer"});

		swfobject.removeSWF("tiny_player_flash");
	});	
}

function transitionToSection(nav_select) {
		var flashvalue = "";
		
		// Add background to container topic (IE workaround)
		$("#container_topic").queue(function() {
				$(this).css({"background-color":"#222021"});
				$(this).dequeue();
		});
		
			 // Check if URL has subdirectory pages or just section path
				 var split_url = nav_select.split("/");
				 if (split_url[0] != "pages" ) {
					 ts_url = "pages/" + nav_select + "/index.html"
					 flashvalue = split_url[0];
				 } else {
					 ts_url = nav_select;
					 flashvalue = split_url[1];
				 }
				 
				 $("#valuepass").text(flashvalue);
			
			// Move cover divs to center while increasing opacity to 90%. Fade out content section
			$("#cover_left").fadeIn(300).animate({left:"0px"}, {duration:300, queue:"global", scope:"closecover"});
			$("#cover_right").fadeIn(300).animate({left:"490px"}, {duration:300, queue:"global", scope:"closecover"});

			$("#preloader").fadeIn({duration:500, queue: "global"}).html(preload);

			$("#content_section_background").fadeOut({duration: 500, queue: "global", scope:"contentfadeout"});
			$(".content_section").fadeOut({duration: 500, queue: "global", scope:"contentfadeout"});
			
			// Fade topic and photo, then load new topic and photo
			$("#title_topic").animate({opacity: "0"}, {duration: 500, queue: "global", scope:"topicfadeout"});
			$("#photo_topic").animate({opacity:"0"}, {duration: 500, queue: "global", scope:"topicfadeout"});
			
			$("#test").animate({top:"-200px", queue: "global"}, 2000, function() {				
				loadTopicAndPhoto('flash_topic_' + flashvalue,'flash_photo_' + flashvalue);
			});
			
			// Display Loading flash and Ajax to load page.  If successful, fade out flash, then lift cover divs and fade in content
			$("#test").animate({top:"-400px", queue: "global"}, 100, function() {
	
				 $.ajax({
					  url: ts_url,
					  cache: false,
					  error: function() {
							errorAjax();
					  },
					  success: function(html) {
						 $("#title_topic").animate({opacity: "1"}, {duration: 500, queue: "global", scope:"topicfadein"});
						 $("#photo_topic").animate({opacity: "1"}, {duration: 500, queue: "global", scope:"topicfadein"});
						 $(".content_section").html(html);
						 $("#preloader").fadeOut({duration:300, queue:"global", scope:"opencover"});
						 $("#cover_left").animate({left:"-490px"}, {duration:300, queue:"global", scope:"opencover"});
						 $("#cover_right").animate({left:"980px"}, {duration:300, queue:"global", scope:"opencover"});
						 $(".content_section").fadeIn({duration:1000, queue:"global", scope:"contentload"});
						 $("#content_section_background").fadeIn({duration: 500, queue:"global", scope:"contentload"});
					  }
			  	}); 
			});
}


// CONTENT LOADING FUNCTIONS ********************************************************************** //


// Ajax to load content in specific div, window or page.  Show loader until all content is received
function startLoading(type, div_id, page_direction, url_query, position) {
	var dbl_click = clickChecker();
	if (dbl_click) {
		switch (type) {
			// Drop window and load content into div_id by calling function
			case "win":
				$("#efx_win_container").show();
				$("#efx_window_section").show();
				$("#efx_win_container").animate({top:"0px"}, {duration:500, queue:"global", scope: "windrop"});
				$("#efx_window_section").animate({opacity:".9"}, {duration:500, queue:"global", scope: "windrop"});
				$("#test").animate({opacity: "0", queue:"global"}, 1000, function() {				
						$("#test").html("");
						displayWinContent(url_query, position);
				}
				);	
			break
			
			case "div":
				
			break
			
			case "page":
				
				if (page_direction == "left") {
					$(".content_section").fadeOut({duration:300, queue: "global", scope: "pageTurn"})
					$(".content_section").animate({left:"-300px"}, {duration:500, queue:"global", scope: "pageTurn"});
					turnPage(url_query, "left");
				} else {
					$(".content_section").fadeOut({duration:300, queue: "global", scope: "pageTurn"})
					$(".content_section").animate({left:"300px"}, {duration:500, queue:"global", scope: "pageTurn"});
					turnPage(url_query, "right");
				}
					
			break		
		}
	}
}

function turnPage(url_query, page_direction) {
// Load, then fadein content section div while moving in specified direction
	$("#preloader").fadeIn({duration:300, queue: "global"}).html(preload);
	$("#preloader").fadeIn(1000, function() {
		 $.ajax({
			  url: url_query,
			  cache: false,
			  error: function() {
					errorAjax();
			  },
			  success: function(html) {
				 $("#preloader").fadeOut({duration:300, queue: "global"}).hide({duration:2, queue: "global"});
				 $(".content_section").html(html);
				 if (page_direction == "left") {
						$(".content_section").animate({left:"300px"}, {duration:1, queue:"global"})
						$(".content_section").fadeIn({duration:300, queue: "global", scope: "pageTurn"})
						$(".content_section").animate({left:"0px"}, {duration:500, queue:"global", scope: "pageTurn"});
				 } else {
						$(".content_section").animate({left:"-300px"}, {duration:1, queue:"global"})
						$(".content_section").fadeIn({duration:300, queue: "global", scope: "pageTurn"})
						$(".content_section").animate({left:"0px"}, {duration:500, queue:"global", scope: "pageTurn"});
				 }
			  }
		  }); 
	});
}

function displayWinContent(url_query, position) {
	// Load query string into hidden div
	$("#test").html(position);
	
	// Ajax to load content in center topic div.  Show loader until all content is received
		$("#win_preloader").fadeIn({duration:300, queue: "global"}).html(preload);
		$("#win_preloader").fadeIn(1000, function() {
			 $.ajax({
				  url: url_query,
				  cache: false,
				  error: function() {
						errorAjax();
			 	  },
				  success: function(html) {
					 $("#win_preloader").fadeOut({duration:300, queue:"global"}).hide({duration:2, queue: "global"});
					 $("#efx_window_content").html(html);
					 $("#efx_window_content").fadeIn(1000, function() {
					});
				  }
			  }); 
		});
}

function loadTopic(this_url) {
	// Ajax to load content in center topic div.  Show loader until all content is received
		$("#preloader").fadeIn({duration:300, queue: "global"}).html(preload);
		$("#preloader").fadeIn(500, function() {
			 $.ajax({
				  url: this_url,
				  cache: true,
				  error: function() {
						errorAjax();
			 	  },
				  success: function(html) {
					 $("#preloader").fadeOut({duration:300, queue:"global"}).hide({duration:2, queue: "global"});
					 $(".content_section").html(html);
					 $(".content_section").fadeIn({duration:500, queue:"global"});
					 $("#content_section_background").fadeIn({duration: 500, queue:"global", scope:"contentfadein"});

				  }
			  }); 
		});
}


// SUBDIRECTORY NAVIGATION FUNCTIONS ********************************************************************** //




// Display subnav elements by raising the main nav
function selectSubhead(sub_call) {	
	sd = 0;
	var sub_list = new Array();
	var sub_url = new Array();
	var sub_full = "";
	
		subdir_url = basemkit + 'getsubdir.php?directory=' + sub_call;
	$.ajax({
				  url: subdir_url,
				  cache: true,
				  error: function() {
						errorAjax();
			 	  },
				  success: function(data) {
					 // Split URL and Title int arrays, then build list of subdirectories.  When complete, display the list and if the main nav is lowered, lift it.
					 var sub_dirs = data.split("|");
					 var sub_dirs_max = sub_dirs.length;
						while (sd < sub_dirs_max) {
							if (sd < sub_dirs_max - 1) {
								sub_url[sd] = "pages/" + sub_call + "/" + sub_dirs[sd];
								sub_list[sd] = sub_dirs[(sd + 1)];
								sub_full += '<li><a href="javascript:transitionCheck(\''+sub_url[sd]+'\')">' + sub_list[sd] + '</a></li>';
							} 
							sd += 2;
						}
						$("#subnav").html(sub_full);
						$("#container_nav").animate({top:"-30px"}, {duration:100, queue:"global"});
				  }
	}); 
	
}

function clearSubHead() {
	sub_full = "";
	$("#subnav").html(sub_full);
}

function lowerNav() {
	if(!over && !over_top) {
		$("#container_nav").animate({top:"0px"}, {duration:100, queue:"global"});
	}
	clearTimeout(timer);
}

function lightNav(spos) {
	var light_nav = '$("#' + spos + '").addClass(\'select\');';
	eval(light_nav);
}

function dimNav(spos) {
	var dim_nav = '$("#' + spos + '").removeClass();';
	eval(dim_nav);
}

function dimPrevSelectedNav() {
	var dim_selected_nav = 	'$("#' + spos_selected + '").removeClass();';
}
function navControl() {
	$("[id^='section']").click(function() {
		var dbl_click = clickChecker();
		nav_select = $("#valuepass").html();
		if (dbl_click && (nav_select != $(this).attr("title"))) {
			nav_select = $(this).attr("title");
			$("#valuepass").text(nav_select);
			transitionToSection(nav_select);
		}
	});	
			
	$("[id^='section']").hover(function()
		{
			spos = $(this).attr("id");
			lightNav(spos);
			
			var sub_select = null;
			sub_select = $(this).attr("name");
			if (sub_select == "submenu") {
				sub_call = $(this).attr("title");
				selectSubhead(sub_call);
			} else {
				clearSubHead();
			}
			
			over = false;
			over_top = true;
			
		}, function() 
		{
			dimNav(spos);  
			over_top = false;
			clearTimeout(timer);
			var timer = setTimeout("lowerNav()", 2000);
		});
		
		$("#container_subnav").hover(function() {
			dimPrevSelectedNav();
			var light_nav = '$("#' + spos + '").addClass(\'select\');';
			eval(light_nav);
			spos_selected = spos;
			over = false;
			over_top = true;
		}, function()
		{
			dimNav(spos);
			dimPrevSelectedNav();
			over_top = false;
			clearTimeout(timer);
			var timer = setTimeout("lowerNav()", 2000);
		});	

}


function transitionCheck(url) {
	var dbl_click = clickChecker();
	if (dbl_click) {
		// Checks if selected subnav link exists on another section.  If so, load transitionToSection and pass url to it.  tSS will split URL and find section + desired page.
		url_arr = url.split("/");
		sec_arr = url_arr[1];
		fkin = $("#valuepass").text();
		if (sec_arr == fkin) {
			// Create starting transition load and pass full url to loadTopic
			$(".content_section").fadeOut({duration:500, queue:"global", scope:"contentfadeout"});
			loadTopic(url);
		} else {
			transitionToSection(url);
		}
	}
}


/*
// PAGE NAVIGAION FUNCTIONS
function loadPageNavigation(page_left_url, page_left_title, page_right_url, page_right_title) {
	
	// Temporary page navigation function
	$("#page_left").hide();
	$("#page_right").hide();
	
	$("#page_left").unbind('click');
	$("#page_right").unbind('click');  
	
	if (page_left_url && page_left_title != "") {
			page_section = $("#valuepass").text();
			$("#page_left").html('PREV:' + page_left_title);
			$("#page_left").fadeIn(500);
			$("#page_left").click(function() {	
				 startLoading('page','', 'left', '/mediakit/pages/test/index.html')
			});
	}
	
	if (page_right_url && page_right_title != "") {
			page_section = $("#valuepass").text();
			$("#page_right").html('NEXT:' + page_right_title);
			$("#page_right").fadeIn(500);
			$("#page_right").click(function() {	
				 startLoading('page','', 'right', '/mediakit/pages/test/index2.html')
			});
	}
}

*/

// UTILITY FUNCTIONS ********************************************************************** //

function clickChecker() {
	// Check how many times a link or div was clicked returning true only once.  Resets after 1 second.
	click_count++;
	if (click_count > 1) {
		//alert("clicked:" +  click_count);
		clearTimeout(click_timer);
		var click_timer = setTimeout('resetCounter()', 500);
		return false;
	}
	clearTimeout(click_timer);
	var click_timer = setTimeout('resetCounter()', 500);
	return true;
}

function resetCounter() {
	clearTimeout(click_timer);
	click_count = 0;
}

function errorAjax() {
	//display error message if file is missing.
	$("#preloader").hide();
	$("#preloader").html(errormsg);
	$("#preloader").fadeIn({duration:500, queue: "global"});
}