// Allow W3C DOM Compliant browsers (and IE)
if( !document.getElementById ) window.location = '/requirements.html';

// Misc. shared functions ***

function go_url(id) {
	window.location = id;
}
function flatbuns_download() {
	window.open('/content_svn/downloads/flatbuns/index.html', 'Download', 'noscrollbars, width=520, height=320, left=200, top=300')
}
function urchin_tracker(path, go_url, _blank) {
  // arguments: path, [url, new_window]
  urchinTracker(path)
  if(go_url != undefined)
    if(_blank == true)
      window_open(go_url)
    else
      window.location = go_url
}

function window_open(open_url) {
	// Try to pop open a new window and complain if it's blocked
	var foc = window.open(open_url, arguments[1] ? arguments[1] : '', arguments[2] ? arguments[2] : '');
	if( foc ) foc.focus();
	else alert("Your browser has blocked your request.\nPlease enable popup windows for this site.");
}

function video_player(id) {
	window_open( '/player/' + id, 'player', 'width=600, height=450');
}

function store_locator() {
	var url = 'http://cke.know-where.com/carlsjr';
	arguments[0] = arguments[0] + ""
	if(arguments[0]=='undefined') arguments[0]=''
	if(arguments[0].length == 4) arguments[0] = "0" + arguments[0];
	if(arguments[0] || arguments[1]) url = url + '/cgi/selection?';
	if(arguments[0]) url = url + 'zip=' + arguments[0] + '&';
	if(arguments[1]) url = url + 'option=' + arguments[1];
	window_open( url, 'locator', 'width=650, height=650, scrollbars');
}

function cancel() { window.location = document.referrer; }

function takethelead() {
	window.open('/takethelead/')
}
function ttl_rules(id) {
	window.open('/take_the_lead/contest/rules')
}
function contest_form(id) {
	
  document.cookie = 'take_the_lead_id=' + escape(id) + '; path=/';
	window.location = '/take_the_lead/contest/'
}

function green_burrito() {
	window.open('/green_burrito.html', 'green', 'width=883, height=442, left=100, top=100');
}

function online_reader() {
	window.open('/online_reader/', 'reader', 'noscrollbars, width=1001, height=735, left=100, top=100');
}
function wine_pairing() {
	window.open('/wine/', 'reader', 'noscrollbars, width=1001, height=735, left=100, top=100');
}
function pop_map()	{
	window.open('/pop_map', 'map', 'noscrollbars, width=250, height=250, left=100, top=100');
}

function pop_print(id)	{
	window.open('/news_print/' + id, 'print', 'scrollbars, width=660, height=375, left=100, top=100');
}

function print_coupon(filename) {
	window.open('/coupon/' + filename.replace('.jpg', '_jpg'), 'print', 'scrollbars, resizable, width=800, height=800, left=100, top=100');	
}
	
function send_to_friend(id)	{
	if(id==0) void(id);
	window.open('/send_friend/' + id, 'Send', 'width=360, height=430, left=100, top=100');
}

function set_days(m) {
	var days_in_month = Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	var selected_day = document.forms[0].elements['birth_date[birth_day]'].selectedIndex;
	document.forms[0].elements['birth_date[birth_day]'].options.length = 0;
	for(var i = 0; i < days_in_month[m - 1]; i++)
		document.forms[0].elements['birth_date[birth_day]'].options[i] = new Option(i + 1, i + 1);
	document.forms[0].elements['birth_date[birth_day]'].selectedIndex = Math.min(document.forms[0].elements['birth_date[birth_day]'].options.length - 1, selected_day)
}


function update_char_count(n) {
	var r = 2000 - n;
	if( r < 0) {
		document.getElementById('form1').elements['comments'].value = document.getElementById('form1').elements['comments'].value.substr(0, 200);
		r = 0;
	}
	document.getElementById('char_count').innerHTML = '('+ r +' remaining)';
}


// Dreamweaver Rollover
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
