jQuery(document).ready(function(){
	createCookie();
        jQuery('.rotator').cycle({ prev: '#prev',  next: '#next', timeout: 10000, speed: 500 });
});

function createCookie(){
	var modal = jQuery.cookie('mw');
	console.log(modal);
	if (modal != 'visited') {
		jQuery(document).ready(function(){locationCheck();});
	   jQuery.cookie('mw', 'visited', { expires: 365, path: '/', domain: '.wherewewatch.com' });
	}
}

function locationCheck() {
if (google.loader.ClientLocation) {				
	var region = google.loader.ClientLocation.address.region.toUpperCase();
	if (region == "NY") { jQuery.colorbox({href:"/modal/splash-ny", opacity:.65, scrolling:"false", onComplete: colorboxDone}); } 
			else { jQuery.colorbox({href:"/modal/splash-global", opacity:.65, scrolling:"false", onComplete: colorboxDone}); }
} 
	else { jQuery.colorbox({href:"/modal/splash-global", opacity:.65, scrolling:"false", onComplete: colorboxDone}); }
}

function colorboxDone() {
	Cufon.replace('h1', { color: '-linear-gradient(#cd0000, #ff1a00)', fontFamily: 'Default' });
	Cufon.replace('h2', { color: '-linear-gradient(#f9c839, #e4ad0a)', fontFamily: 'Default' });
	Cufon.replace('a#closeBtn', { fontFamily: 'TW Cent', hover: true });
	form_labelize();
	form_validate();
	jQuery(".closeBox").live('click',function(event) {
		jQuery.fn.colorbox.remove();
		event.preventDefault(); 
	});
}
