(function($) { var flags = new Array(); var mask = null; var overlay = null; function startChooser() { mask = $('
').appendTo('body').css({ zIndex:100, background:'#000', height:$(document).height(), width:'100%', position:'absolute', top:0, left:0, opacity:0 }).animate({ opacity:.7 }, 'slow'); var html = '

Please Choose a Language

'; html += '

'; flags.push({file:'english.gif',name:'English', menu_domain:'www'});flags.push({file:'espanol.gif',name:'Español', menu_domain:'es'});flags.push({file:'espanol-de-mexico.gif',name:'Español de México', menu_domain:'mx'}); var url = String(window.location); $(flags).each(function(i,f) { var h = 'elkhartbrass.'+url.substr(url.indexOf('.')+1); h = h.replace('elkhartbrass.elkhartbrass', 'elkhartbrass'); html += ''+f.name+' '+f.name+'
'; }); html += '

'; overlay = $('
'+html+'
').appendTo('body').css({ opacity:0 }); $(overlay).find('a').click(languageClicked).end().animate({ opacity:1 }, 400); } function languageClicked() { $.cookie('subdomain', this.title, { expires:365, path:'/', domain:'elkhartbrass.com' }); var loc = String(window.location); var sub = loc.substr(7,loc.indexOf('.')-7); if(sub != this.title) window.location = this.href; else closeChooser(); return false; } function closeChooser() { $(overlay).remove(); $(mask).animate({ opacity:0 }, 'fast', function() { $(this).remove(); }); } $(document).ready(function() { if(!$.cookie('subdomain')) setTimeout(startChooser, 10); /*if(!$.cookie('subdomain')) { setTimeout(startChooser, 10); } else { var loc = String(window.location); var sub = loc.substr(7,loc.indexOf('.')-7); if(!loc) loc = 'www'; if($.cookie('subdomain') != loc) { window.location = 'http://'+$.cookie('subdomain')+'.elkhartbrass.com'; } }*/ }); })(jQuery);