// JavaScript Document
var PAGE_TYPE_STATE_SPECIFIC = 1;
var PAGE_TYPE_NON_STATE_SPECIFIC = 0;
var INTERNET_EXPLORER = "Microsoft Internet Explorer";
var VERSION_IE_5 = "MSIE 5";
var VERSION_IE_6 = "MSIE 6";

function isIE5 () {
	return (navigator.appName == INTERNET_EXPLORER) && (navigator.appVersion.indexOf(VERSION_IE_5) > 0);
}

function isIE5Or6 () {
	return (navigator.appName == INTERNET_EXPLORER) && ( (navigator.appVersion.indexOf(VERSION_IE_5) > 0) || (navigator.appVersion.indexOf(VERSION_IE_6) > 0) );
}

function isIE() {
	return (navigator.appName == INTERNET_EXPLORER);
}

// If the root URL is not specified in the calling page, find it...
if (!rootUrl){
	var rootUrl = getSiteUrl();
}
// If the server IP is not specified in the calling page, set it to blank...
if (!serverIP){
	var serverIP = '';
}

/* function to move images of top navigation menu buttons for mouseover */
	function movepic(img_name,img_src) {
		document[img_name].src=img_src;
	}

/* Preload images script for top navigation menu */
var myimages=new Array()
	function preloadimages(){
		for (i=0;i<preloadimages.arguments.length;i++){
			myimages[i]=new Image()
			myimages[i].src=preloadimages.arguments[i]
		}
	}

	arrStateName = new Array(
		"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", 
		"Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", 
		"Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", 
		"Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", 
		"North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", 
		"Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming", "Washington DC"
	);

	function build_state_dropdown(divId) {
		var selstatestd;
		var test_state;

		selstatestd = document.getElementById(divId);
		var newselect = document.createElement('select');
		newselect.name="state_id";
		newselect.className = "stateselect";
		//newselect.id="stateselect"
		newselect.options[0] = new Option('Choose Your State','0');

		for (j=0;j<arrStateName.length;j++) {
			newselect.options[j + 1] = new Option(arrStateName[j],j+1);
		}
		state = readCookie("lastsel_state");
		if(state == '' || state == 0)  {
			newselect.selectedIndex = '';
		} else {
			newselect.selectedIndex = state;
			newselect.options[0].text = "Choose Your State";
		}

		if (pgType == 1) {
			newselect.onchange=function() {
				sentToStatePage(destLink,newselect);
			}
		} else {
			newselect.onchange=function() {
				sendToNonStatePage(destLink,newselect)
		  }
		}
		if (selstatestd != null) {
			// remove any existing select boxes
			$("#" + divId + " > .stateselect").remove();
			selstatestd.appendChild(newselect);
		}
	}

	function build_qlinks_dropdown() {
		  if (arrQLinksId)
		  {
			  selstatestd = document.getElementById("selectquicklinkstd");

			  var newselect = document.createElement('select');
			  newselect.name="quick_links";
			  newselect.id="quick_links";

			  newselect.options[0] = new Option('Quick Links','');

			  for(j=0;j<arrQLinksId.length;j++)
			  {
				  newselect.options[j + 1] = new Option(arrQLinksName[j], rootUrl.replace(/\/$/,'')+arrQLinksId[j]);
			  }

			  newselect.onchange=function()
			  {
				sendToquicklink();
			  }
			  if (selstatestd != null) {
			    selstatestd.appendChild(newselect);
			  }
		  }
	}

	/**
	 * Sends the user to a state-specific page based on the value
	 * selected in the state drop-down.
	 *
	 */
	function sentToStatePage(filename,select){
		var stateid = select.value;

		// if the user specifically selected the "Nationwide DMV Guide" option, then clear the state cookie
		if((stateid == '') || (stateid == 0)) {
			if (filename == 'department-motor-vehicles.php') {
				var actionvalue = '';
			} else {
				createCookie('lastsel_state','0',getCookieDomain());
				var actionvalue = filename;
			}
		}

		//var rootUrl = getSiteUrl();
		if(!validInt(filename))   {
			var arr_states_codes = new Array (
				"al-alabama", "ak-alaska", "az-arizona", "ar-arkansas", "ca-california", "co-colorado", "ct-connecticut", "de-delaware", 
				"fl-florida", "ga-georgia", "hi-hawaii", "id-idaho", "il-illinois", "in-indiana", "ia-iowa", "ks-kansas", "ky-kentucky", 
				"la-louisiana", "me-maine", "md-maryland", "ma-massachusetts", "mi-michigan", "mn-minnesota", "ms-mississippi", "mo-missouri", 
				"mt-montana", "ne-nebraska", "nv-nevada", "nh-new-hampshire", "nj-new-jersey", "nm-new-mexico", "ny-new-york", 
				"nc-north-carolina", "nd-north-dakota", "oh-ohio", "ok-oklahoma", "or-oregon", "pa-pennsylvania", "ri-rhode-island", 
				"sc-south-carolina", "sd-south-dakota", "tn-tennessee", "tx-texas", "ut-utah", "vt-vermont", "va-virginia", "wa-washington", 
				"wv-west-virginia", "wi-wisconsin", "wy-wyoming", "washington-dc"
			);
  	    	if((stateid != '') && (stateid != 0)) {
		    	stateid--;
				if(filename == 'index.php') {
					var actionvalue = arr_states_codes[stateid]+'/department-motor-vehicles.php';
				} else {
					var actionvalue = arr_states_codes[stateid]+'/'+filename;
				}
			}
			location.href = rootUrl + actionvalue;
		} else {
			var browserName=navigator.appName;
			var xmlhttp;
			var url = rootUrl + "showstatefile.php?stateid="+stateid+"&navid="+filename;
			//alert(url);
			var retval;
			if (browserName=="Netscape" || browserName=="Opera")	{
		   		xmlhttp=new XMLHttpRequest();
			}
			else if (browserName=="Microsoft Internet Explorer")	{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.open("GET", url, false);
			xmlhttp.send(null);
			//	Call the function to set the fields based upon the response received
			retval = xmlhttp.responseText;
			location.href = rootUrl + retval.substr(1); //remove leading '/'
		}
		return true;
	}

	function sendToNonStatePage(filename, select){
		var arr_states_codes = new Array (
			"al-alabama", "ak-alaska", "az-arizona", "ar-arkansas", "ca-california", "co-colorado", "ct-connecticut", "de-delaware", 
			"fl-florida", "ga-georgia", "hi-hawaii", "id-idaho", "il-illinois", "in-indiana", "ia-iowa", "ks-kansas", "ky-kentucky", 
			"la-louisiana", "me-maine", "md-maryland", "ma-massachusetts", "mi-michigan", "mn-minnesota", "ms-mississippi", "mo-missouri", 
			"mt-montana", "ne-nebraska", "nv-nevada", "nh-new-hampshire", "nj-new-jersey", "nm-new-mexico", "ny-new-york", "nc-north-carolina", 
			"nd-north-dakota", "oh-ohio", "ok-oklahoma", "or-oregon", "pa-pennsylvania", "ri-rhode-island", "sc-south-carolina", 
			"sd-south-dakota", "tn-tennessee", "tx-texas", "ut-utah", "vt-vermont", "va-virginia", "wa-washington", "wv-west-virginia", 
			"wi-wisconsin", "wy-wyoming", "washington-dc"
		);
		var stateid = select.value;

		if((stateid != '') || (stateid != 0))   {
			createCookie ('lastsel_state', stateid, getCookieDomain());
		}
		if((filename == "search/") && (stateid > 0)){
			document.getElementById("tz").value = arr_states_codes[stateid-1].substring(0,2);
			doSearch();
			return true;
		}
		stateid = getCookie('lastsel_state');
		if((filename == 'index.php') && (stateid > 0))	{
			url = arr_states_codes[stateid-1]+'/department-motor-vehicles.php';;
		}
		else {
			url = filename;
		}
		location.href = rootUrl + url;
		return true;
	}

  function selectState(state)
  {
  	  if(state == '')  {
			document.getElementById('stateselect').selectedIndex = '';
			document.getElementById('stateselect').selectedIndex = "";
	  } else {
//		    state++;
			document.getElementById('stateselect').selectedIndex = state;
			document.getElementById('stateselect').options[0].text = "Choose Your State";
	  }
  }


  function sendToquicklink() {
		 var qlinkUrl = document.getElementById("quick_links").value;
		 if(qlinkUrl == '') {
			 return false;
		 }
		location.href = qlinkUrl;
	return true;
  }

  function dmvtellafriend() {
		window.open('http://pub20.bravenet.com/announce/show.php?usernum=1656273176&cpv=2','bnettaf','width=525,height=470,scrollbars=yes,top=10,left=150,toolbars=no,resizable=1');
  }

  function bookmarksite(siteurl) {

	var browserName=navigator.appName;

	 var arr_states_codes = new Array ("al-alabama", "ak-alaska", "az-arizona", "ar-arkansas", "ca-california", "co-colorado", "ct-connecticut", "de-delaware", "fl-florida", "ga-georgia", "hi-hawaii", "id-idaho", "il-illinois", "in-indiana", "ia-iowa", "ks-kansas", "ky-kentucky", "la-louisiana", "me-maine", "md-maryland", "ma-massachusetts", "mi-michigan", "mn-minnesota", "ms-mississippi", "mo-missouri", "mt-montana", "ne-nebraska", "nv-nevada", "nh-new-hampshire", "nj-new-jersey", "nm-new-mexico", "ny-new-york", "nc-north-carolina", "nd-north-dakota", "oh-ohio", "ok-oklahoma", "or-oregon", "pa-pennsylvania", "ri-rhode-island", "sc-south-carolina", "sd-south-dakota", "tn-tennessee", "tx-texas", "ut-utah", "vt-vermont", "va-virginia", "wa-washington", "wv-west-virginia", "wi-wisconsin", "wy-wyoming", "washington-dc");
	 var arr_states = new Array("Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming", "Washington DC");

	 if (!siteurl) siteurl = window.location.href;
	 var checkf=false;
	 var checkstateid;
	 for(var i=0;i<arr_states_codes.length;i++) {
	   if(siteurl.search(arr_states_codes[i]) != '-1') {
	 	   checkf = true;
		   checkstateid = i;
	   }
	 }

	 if(checkf == true) {
		 var title = arr_states[checkstateid]+' DMV.ORG -The Unofficial Guide to the DMV';
		 var url =  'http://www.dmv.org/'+arr_states_codes[checkstateid]+'/department-motor-vehicles.php';
	 } else {
		 var title ='DMV.ORG - The Unofficial Guide to the DMV';
		 var url =  'http://www.dmv.org/';
	 }

	if (browserName=="Netscape" || browserName=="Opera")
	  {

			 window.sidebar.addPanel(title, url,"t");
	  }
	else
	  {
		 window.external.addFavorite(url,title);
	}
  }

  function validInt(file)
  {
	result = true;
		var num = parseInt(file);
		if (isNaN(num))
		{
			result = false;
		}
	return result;
  }


function visitmenu(x){
	if (document.jump.menu.value != "null") {
		document.location.href = x
	}
}

function goWin() {
	var ww;
    ww = window.open("http://www.carfax.com/cfm/popVIN.cfm","VIN","width=500,height=350");
}

setTimeout ("changePage()", 100);

function changePage()
	{
	if (self.parent.frames.length != 0)
	self.parent.location=self.location;
	}

function helpfulpopUp(URL, height) {
day = new Date();
id = day.getTime();
height = (height)?height:320;
var width = 480;
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height+",left = "+((screen.width-width)/2)+",top = "+((screen.height-height)/2)+"');");
}

function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}

function getSiteUrl(){
	var loc = window.location.href;
	arrFolders = loc.split('/');
	if(loc.indexOf("~") >= 0){
		url = arrFolders[0] + "//" + arrFolders[2] + "/" + arrFolders[3] + "/";
	}else{
		url = arrFolders[0] + "//" + arrFolders[2] + "/";
	}
	return url;
}


function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function doLocalSearch (textId, hintText) {
	return (document.getElementById(textId).value.length > 0 && document.getElementById(textId).value != hintText);
}

function clearInitStr(id)
{
	if (id && !id.hasCleared){
		id.value="";
		id.hasCleared = true;
	}
}

function deleteEnterSearchterm(inputId)
{
	if(document.getElementById(inputId).value == 'search term required')
		document.getElementById(inputId).value = '';
}

function doSearch(id, url)
{
    var query_string = '';
	var format_keywords = '';
	var http_prefix = 'http://';
	var search_url = url? url:'search.dmv.org';

	if (id == "searchDmv_id") {
		id = "frmsearchPrimary";
	}
	
	if (id == 'frmSearchHelpCenter') {
	    var search_field = document.getElementById('navQuery');
	} else {
	    var search_field = document.getElementById(id).getElementsByTagName('input')[0];
	}

	if( !search_field.value.replace(/^\W+/,'').length || search_field.value == "Search term required" || search_field.value == "Search" )
	{
		search_field.value = "Search term required";
		return false;
	}

	var tz_field     = statecode;
	var state_field  = statename;
	var section_name = section;

	if (state_field == "" || (id == 'frmSearchHelpCenter')) {
        state_field = "NO-STATE";

	}

	if (section_name == "Home"){
		section_name = "HOMEPAGE";
	} else {
		section_name = section_name.toUpperCase();
	}
	section_name = section_name.replace(/ /gi,"+");
	section_name = escape(section_name);

    if (id == 'frmSearchHelpCenter') {
	    var search_form        = document.getElementById('frmSearchHelpCenter');
	    var tz_field_help      = document.getElementById('tz_id_help_center');
	    var state_field_help   = document.getElementById('state_id_help_center');
	    var section_field_help = document.getElementById('section_id_help_center');

	    var navQuery_elem      = document.getElementById('navQuery');
	    navQuery_elem.setAttribute('name', 'w');

	    tz_field_help.value = statecode;
	    state_field_help.value = state_field;
	    section_field_help.value = section_name;
	} else {
	   var search_form = document.getElementById(id);
	   if (state_field == 'NON-STATE') {
	       var search_state_field = document.getElementById('state_id');
	       search_state_field.value = state_field;
	   }
	   var search_section = document.getElementById('section_id');
	   search_section.value = section_name;
	}

	format_keywords = search_field.value.replace(/ /gi,"+");
	format_keywords = escape(format_keywords);

	// add search terms:
	query_string += '?w=' + format_keywords;
	// add tz:
	query_string += '&tz=' + tz_field;
	// add state:
	query_string += '&state=' + state_field;
	// add section name:
	query_string += '&section=' + section_name;
	// add server address:
	query_string += '&orig_serv=' + serverIP;

	if (id == 'frmSearchHelpCenter') {
	    query_string += '&ssv=HELP';
	}

    keyword = search_field.value
		.replace(/'/g, "")
		.replace(/[~`!@#$%^&*()_+=|}{\\\][";:\/?.>,<]/gi, " ")
		.replace(/^\s*(.*?)\s*$/, "$1")
		.replace(/ +/g,"-")
		.toLowerCase();
 
	var len,maxLen=0,tstate, stateName='';
    for (var i in arrStateName) 
		if (keyword.indexOf((tstate=arrStateName[i].toLowerCase().replace(" ","-")))==0 && (len=tstate.length)>maxLen && (maxLen=len)>0) 
			{ stateName = tstate; }
			
	if (stateName) { 
		keyword = keyword.replace(stateName,"").replace(/^-/,""); 
		stateName += "/"; 
	} else if (state_field && state_field != "NO-STATE") {
		stateName = state_field.toLowerCase().replace(" ","-") + "/";
	}
	
	url = stateName + keyword;
	search_form.action = http_prefix + search_url + '/search';
	window.location.href = http_prefix + search_url + '/dmv/' + url;
	return false;
}


/*
 * Function to open a link presented in a popup. This function first tries to open the link in the parent window
 * specified by the pWindow. If this doesn't work, then it will try to open a new window and point it to the url.
 *
 * The window that opens the popup needs to set the pWindow attribute in order for this to work:
 *		window.open(url,'_blank',...).pWindow = window;
 *
 *
 */
function gotoPopupLink(url){
	try{
		// If there is a parent window defined in pWindow then use it to load the new url
		pWindow.location.href=url;
	}catch(e){
		// This means there was no parent window defined. So open a new window...
		window.open(url, "_blank", "menubar=1,location=1,status=1,toolbar=1,resizable=1,width=800,height=600,scrollbars=1");
	}
	window.close();
}

function l_st(lnk) {
	// if the url starts with an fqd
	if (lnk.href.toLowerCase().indexOf("http://") == 0 || lnk.href.toLowerCase().indexOf("https://") == 0) {
		var dom = getCookieDomain();
		if (!dom) dom = getSiteUrl().replace(/http.?:\/\/(.*)\//,'$1');
				
		// if the domain is found in between "//" and the next "/"
		if ((i=lnk.href.toLowerCase().indexOf(dom))<0 || i > lnk.href.toLowerCase().indexOf ("/", 8)) {
			lnk.target = "_blank";
		}
	}
}

/**
 * OnMouseOver event handler for hover menus 
 * @param li	:		<li> object containing an <a> object and a <ul> sub menu
 * @return
 */
function menuOn(li){
	if (li.hClose) clearTimeout(li.hClose);
	
	var elem = li.getElementsByTagName('*');
	if (!elem || elem.length < 2) return;
	
	var a = elem[0];
	var ul = elem[1];
	
	ul.style.display = 'block';
	if (a.className.indexOf('active')<0){
		a.oldClassName = a.className;
		a.className += ' active';
	}
}

/**
 * OnMouseOut event handler for hover menus 
 * @param li	:		<li> object containing an <a> object and a <ul> sub menu
 * @return
 */
function menuOff(li){
	var elem = li.getElementsByTagName('*');
	if (!elem || elem.length < 2) return;
	
	var a = elem[0];
	var ul = elem[1];
	
	ul.style.display = 'none'; 
	// The display switching is to fix IE not changing class
	a.style.display='none';a.className = a.oldClassName;a.style.display='block';
}

/**
 * OnClick event handler for menus that open with a click and close with either a second click or mouse rolling out 
 * @param li	:		<li> object containing an <a> object and a <ul> sub menu
 * @return
 */
function menuClick(li, externalEvent){
	if (!li.on){
		if (externalEvent) externalEvent(true);
		menuOn(li);
		li.onmouseover = function(){menuOn(li)}
		li.onmouseout = function(){li.hClose = setTimeout(function(){
			menuOff(li);li.on=false;
			li.onmouseout=li.onmouseover=null
			if (externalEvent) externalEvent(false);}
		,500)} // To delay the closing of menu's, increase this number (in milli seconds) 
		li.on = true;
	}else{
		li.on = false;
		li.onmouseover=li.onmouseout=null;
		menuOff(li);
		if (externalEvent) externalEvent(false);
	}
}

/**
 * Function to execute a component via AJAX and return results
 * 
 * @param component					: 	component name
 * @param args						:	component extra arguments
 * @param callbackFunc (optional)	:	callbackFunc to receive the results in async mode
 * @param obj (optional)			:	DOM Object to change the cursor for and serialize calls
 * @return true|false if callbackFunc exists, the component result otherwise
 */
function call(component,args,callbackFunc,obj){
	if (obj&&obj.incall) return;
	
	var strArgs="";
	for (arg in args){
		strArgs += "&"+escape(arg)+"="+escape(args[arg]);
	}

	//var url = rootUrl + "ajaxComponent.php?c="+component+"&uq="+Math.random();
	var url = "/ajaxComponent.php?c="+component+"&uq="+Math.random();

	var post = "i=" + pageInfo + strArgs;

	/*
	*/
	if (callbackFunc) {
		$.ajax({
			type: "POST",
			url: url,
			data: post,
			dataType: "html",
			success: function (data, textStatus) {
				callbackFunc(data);
			},
			failure: function (data, textStatus, error) {
			}
		});
	}
	else {
		$.ajax({
			type: "POST",
			url: url,
			data: post,
			dataType: "html"
		});
	}
	/*
	var xhReq = function(){
		try { return new XMLHttpRequest(); } catch(e) {}
		try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
		try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
		return false;		
	}();

	if (xhReq){
		if (obj) {obj.incall=true;obj.style.cursor="wait";}
		console.debug(post);
		console.debug(post.length);
		xhReq.open("POST", url, callbackFunc? true:false);
		xhReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xhReq.setRequestHeader("Content-length", post.length);
		xhReq.setRequestHeader("Connection", "close");
		if (callbackFunc){
			xhReq.onreadystatechange = function() {
				if (xhReq.readyState != 4)  { return; }
				if (obj) {obj.incall=false;obj.style.cursor="pointer";}
				callbackFunc(xhReq.responseText);
			};
		}
		xhReq.send(post);
		if (!callbackFunc){ 
			if (obj) {obj.incall=false;obj.style.cursor="pointer";}				
			return xhReq.responseText;
		}
	}else{
		return false;
	}
	*/

	return true;
}

// set up the hover state for thumbshots on pageload...
function setupThumbshots(){
	$(document).ready(function(){
	  	var thumbshotClearInt;
	  	$(".thumbshots a img").mouseover(function(){
	  		clearTimeout(thumbshotClearInt);
		  	if ($('#thumbshotImg').get(0) && $('#thumbshotImg').get(0) == this.preview) return;
			this.preview = true;
			
		  	var h=252;
		  	var w=336;
		  	var imgSrc = this.src;
			imgSrc = imgSrc.match(/&h=/)? imgSrc.replace(/(&h=)(.*?)(&|$)/,'$1'+h+'$2') : imgSrc+="&h="+h;
			imgSrc = imgSrc.match(/&w=/)? imgSrc.replace(/(&w=)(.*?)(&|$)/,'$1'+w+'$2') : imgSrc+="&w="+w;
	
			$('#thumbshotImg').remove();
			$('body').prepend("<div id='thumbshotImg' style='position:absolute;z-index:10000;display:none'>hello</div>");
			this.preview = $('#thumbshotImg').get(0); 
			$('#thumbshotImg').css('left',$(this).offset().left+$(this).width()+1);
			$('#thumbshotImg').css('top',$(this).offset().top-20);
			$('#thumbshotImg').html('<img src="'+imgSrc+'" />');
			$('#thumbshotImg').mouseover(function(){this.isHover=true});
			$('#thumbshotImg').mouseout(function(){this.isHover=false});
	
			setTimeout(function(){$('#thumbshotImg').show('fast');}, 500);
	
	  	});
	  	$(".thumbshots a img").mouseout(function(){
		  	var closePreview = function(){
				if (!$('#thumbshotImg').attr('isHover')) 
					$('#thumbshotImg').remove();
				else
				  	thumbshotClearInt = setTimeout(closePreview,500);
		  	}
		  	thumbshotClearInt = setTimeout(closePreview,500);
	  	});
	});
}