function expandResult(theID){
	expandRestaurant(theID);
}

function expandRestaurant(theID){
    var divID = "dine_rest_extra_" + theID;
    var divAwardID = "dine_result_awards_" + theID;
    var divRestID = "dine_rest_" + theID;

     if (document.getElementById(divID).style.display != "none") {
       document.getElementById(divID).style.display = "none"
       document.getElementById(divAwardID).style.display = "none";
       document.images['dine_results_img_' + theID ].src="/images/dine_results_expand.gif";
       document.getElementById(divRestID).style.background = "#FFFFFF";
       document.getElementById(divID).style.display = "none";
     }
     else {
       document.getElementById(divID).style.visibility = "visible";
       document.getElementById(divAwardID).style.visibility = "visible";
       document.images['dine_results_img_' + theID ].src="/images/dine_results_collapse.gif";

	// rob	
	  document.getElementById(divAwardID).style.display = "block";
       
	document.getElementById(divAwardID).style.visibility = "visible";
       document.getElementById(divRestID).style.background = "#FEF5A2";
       document.getElementById(divID).style.display = "block";
     }
 }


function expandRetailer(theID){
    var divID = "rhome_retailer_extra_" + theID;
    var divRetID = "rhome_retailer_" + theID;

     if (document.getElementById(divID).style.display != "none") {
       document.getElementById(divID).style.display = "none"
       document.images['rhome_results_img_' + theID ].src="/images/dine_results_expand.gif";
       document.getElementById(divRetID).style.background = "#FFFFFF";
       document.getElementById(divID).style.display = "none";
     }
     else {
       document.getElementById(divID).style.visibility = "visible";
       document.images['rhome_results_img_' + theID ].src="/images/dine_results_collapse.gif";
       document.getElementById(divRetID).style.background = "#FEF5A2";
       document.getElementById(divID).style.display = "block";
     }
 }




function expandBlogComments(theID){
    var divID = "blog_comments_" + theID;

     if (document.getElementById(divID).style.display != "none") {
       document.getElementById(divID).style.display = "none";
     }
     else {
       document.getElementById(divID).style.visibility = "visible";
       document.getElementById(divID).style.display = "block";
     }
 }

function openForwardToFriend(articleID){
//Open a modal window with an iframe page inside, and assign the result to a global variable called "emailwindow"
    f2fwindow=dhtmlmodal.open('ForwardToFriend', 'iframe', '/modalfiles/forwardtofriend.php?articleID=' + articleID, 'Forward to a friend', 'width=500px,height=400px,center=1,resize=0,scrolling=1,border=0,frameborder=0');
}

function openForwardRetailerToFriend(retailerID){
//Open a modal window with an iframe page inside, and assign the result to a global variable called "emailwindow"
    f2fwindow=dhtmlmodal.open('ForwardRetailerToFriend', 'iframe', '/modalfiles/forwardretailertofriend.php?retailerID=' + retailerID, 'Forward to a friend', 'width=500px,height=400px,center=1,resize=0,scrolling=1,border=0,frameborder=0');
}



function openAddArticleComment(contentID){
//Open a modal window with an iframe page inside, and assign the result to a global variable called "emailwindow"
    articleCommentwindow=dhtmlmodal.open('ArticleComment', 'iframe', '/modalfiles/articleComment.php?contentID=' + contentID, 'Add Article Comment', 'width=500px,height=400px,center=1,resize=0,scrolling=1,border=0,frameborder=0');
}


function openAddBlogComment(contentID){
//Open a modal window with an iframe page inside, and assign the result to a global variable called "emailwindow"
    blogCommentwindow=dhtmlmodal.open('BlogComment', 'iframe', '/modalfiles/blogComment.php?contentID=' + contentID, 'Add Blog Comment', 'width=500px,height=550px,center=1,resize=0,scrolling=1,border=0,frameborder=0');
}

function openAddEvent(){
//Open a modal window with an iframe page inside, and assign the result to a global variable called "emailwindow"
    submitEventwindow=dhtmlmodal.open('SubmitEvent', 'iframe', '/modalfiles/eventCalendar.php', 'Submit Event', 'width=500px,height=600px,center=1,resize=0,scrolling=1,border=0,frameborder=0');
}

function openRSSSubscriptions(){
//Open a modal window with an iframe page inside, and assign the result to a global variable called "emailwindow"
    rssSubscriptionswindow=dhtmlmodal.open('RSSSubscriptions', 'iframe', '/modalfiles/rssSubscriptions.php', 'RSS Subscriptions', 'width=500px,height=400px,center=1,resize=0,scrolling=1,border=0,frameborder=0');
}

function openReportBlogComment(blogID){
    reportBlogCommentwindow=dhtmlmodal.open('ObjectionalBlogComments', 'iframe', '/modalfiles/reportBlogComment.php?blogID=' + blogID, 'Report Blog Comment', 'width=500px,height=400px,center=1,resize=0,scrolling=1,border=0,frameborder=0');
}


function openAddRestaurant(){
//Open a modal window with an iframe page inside, and assign the result to a global variable called "emailwindow"
    submitEventwindow=dhtmlmodal.open('SubmitRestaurant', 'iframe', '/modalfiles/addRestaurant.php', 'Submit Restaurant', 'width=500px,height=600px,center=1,resize=0,scrolling=1,border=0,frameborder=0');
}



//var featuredArticle = 1;



var TimeToFade = 250.0;
var fadeInterval = 0;
function fade(eid,featureAction,isClick)
{
  var element = document.getElementById(eid);
  if(element == null)
    return;
   
  if(element.FadeState == null)
  {
    if(element.style.opacity == null 
        || element.style.opacity == '' 
        || element.style.opacity == '1')
    {
      element.FadeState = 2;
    }
    else
    {
      element.FadeState = -2;
      
    }
  }
    
  if(element.FadeState == 1 || element.FadeState == -1)
  {
    element.FadeState = element.FadeState == 1 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
    
  
  }
  else
  {
    element.FadeState = element.FadeState == 2 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade;
    fadeInterval = setTimeout("animateFade(" + new Date().getTime() + ",'" + eid  + "','"+featureAction+"',"+isClick+")", 33);
      
  }  
  //swapHomeFeatures2(featureAction,isClick)
}

function animateFade(lastTick, eid,featureAction,isClick)
{  
	 
	
  var curTick = new Date().getTime();
  var elapsedTicks = curTick - lastTick;
  
  var element = document.getElementById(eid);
 
  if(element.FadeTimeLeft <= elapsedTicks)
  {
    element.style.opacity = element.FadeState == 1 ? '1' : '0';
    element.style.filter = 'alpha(opacity = ' 
        + (element.FadeState == 1 ? '100' : '0') + ')';
    element.FadeState = element.FadeState == 1 ? 2 : -2;
	if(element.FadeState == -2){
		
		 clearInterval(fadeInterval);
		  swapHomeFeatures2(featureAction,isClick);
	}

    return;
  }
 
  element.FadeTimeLeft -= elapsedTicks;
  var newOpVal = element.FadeTimeLeft/TimeToFade;
  if(element.FadeState == 1)
    newOpVal = 1 - newOpVal;

  element.style.opacity = newOpVal;
  element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
  
    fadeInterval = setTimeout("animateFade(" + new Date().getTime() + ",'" + eid  + "','"+featureAction+"',"+isClick+")", 33);
}
function swapHomeFeatures(featureAction,isClick){
	//fade out

	fade('features_module_img',featureAction,isClick);
	//swapHomeFeatures2(featureAction,isClick)
}


function swapHomeFeatures2(featureAction,isClick){
	//swap and fade in
    var featureNum;

    if ( featureAction=='p' ) {

        if (featuredArticle == 1) {
            featureNum = featuredArticleMax;
        } else {
             featureNum = featuredArticle - 1;
        }

    } else if ( featureAction=='n' ) {

        if (featuredArticle == featuredArticleMax) {
            featureNum = 1;
        } else {
             featureNum = featuredArticle + 1;
        }

    }  else {
        featureNum = parseFloat(featureAction) ;
    }


    document.getElementById("features_module_header").innerHTML = feature_module_header[ featureNum -1 ];
    document.getElementById("features_module_copy").innerHTML = feature_module_copy[ featureNum -1 ];
    document.getElementById("features_module_img").src = "/images/articles/featuresportal/" + feature_module_images[ featureNum -1 ];
    document.getElementById("features_module_category").innerHTML = feature_module_category[ featureNum -1 ];;

    theFeaturedNum = featureNum-1;
    theFeaturedNum = theFeaturedNum.toString();

    var featuredArticleID = "featuredArticle_" + theFeaturedNum;
    for( intX=0; intX < featuredArticleMax ;  intX++){  
      //  document.getElementById( "featuredArticle_" + intX ).setAttribute("class", "features_module_paging");
          document.getElementById( "featuredArticle_" + intX ).className= "features_module_paging";
    }

    // document.getElementById( featuredArticleID ).setAttribute("class", "features_module_paging_on");
     document.getElementById( featuredArticleID ).className = "features_module_paging_on";



   fade('features_module_img');

    featuredArticle = featureNum;

    if ( isClick == true) {
        clearInterval(featuredArticleIntervalId);
 	  	  document.getElementById("pause_btn_holder").innerHTML = "<a href=\"javascript:playHomeFeatures();\" class='features_module_paging' ><img onmouseover=\"swap_btn('pause_btn','/images/play_on.gif');\" onmouseout=\"swap_btn('pause_btn','/images/play_off.gif');\" id=\"pause_btn\" src=\"/images/play_off.gif\" border=\"0\"></a>";
    }


    

}


	

function swap_btn(which,img){
	
	 document.getElementById( which ).src=img;	
}

function pauseHomeFeatures(){
	  clearInterval(featuredArticleIntervalId);
	  clearInterval(fadeInterval)
	  	  document.getElementById("pause_btn_holder").innerHTML = "<a href=\"javascript:playHomeFeatures();\" class='features_module_paging' ><img onmouseover=\"swap_btn('pause_btn','/images/play_on.gif');\" onmouseout=\"swap_btn('pause_btn','/images/play_off.gif');\" id=\"pause_btn\" src=\"/images/play_off.gif\" border=\"0\"></a>";
	  
	  
}

function playHomeFeatures(){
	
  	  document.getElementById("pause_btn_holder").innerHTML = "<a href=\"javascript:pauseHomeFeatures();\" class='features_module_paging' ><img onmouseover=\"swap_btn('pause_btn','/images/pause_on.gif');\" onmouseout=\"swap_btn('pause_btn','/images/pause_off.gif');\" id=\"pause_btn\" src=\"/images/pause_off.gif\" border=\"0\"></a>";
	swapHomeFeatures('n',false);
	rotateHomeFeatures();	
}
	
// get date var from datepicker.js
/*******************************************************/
function setDateOptionToCalendarSelect(clickDate){
		
	var dataArray;
	var dateStr = String(clickDate);
	
	//alert(dateStr);
	
	dateArray = dateStr.split(" ");

	var selectMonth = dateArray[1];
	var selectDay = dateArray[2];
	var selectYear = dateArray[3];
	
	dateArray = dateStr.split(" ");

	var m = dateArray[1];
	var d = dateArray[2];
	var y = dateArray[3];
	
	//alert(m + " " + d + " " + y);

	
	selectDateOptions(m,d,y,m,d,y);

	document.getEvents.submit();

}

function convertMonth(theMonth){
	var retVal;

	retVal = theMonth

	if (theMonth=="Jan"){
		retVal = '01';
	}

	if (theMonth=="Feb"){
		retVal = '02';
	}

	if (theMonth=="Mar"){
		retVal = '03';
	}

	if (theMonth=="Apr"){
		retVal = '04';
	}

	if (theMonth=="May"){
		retVal = '05';
	}

	if (theMonth=="Jun"){
		retVal = '06';
	}
	
	if (theMonth=="Jul"){
		retVal = '07';
	}

	if (theMonth=="Aug"){
		retVal = '08';
	}

	if (theMonth=="Sep"){
		retVal = '09';
	}

	if (theMonth=="Oct"){
		retVal = '10';
	}

	if (theMonth=="Nov"){
		retVal = '11';
	}

	if (theMonth=="Dec"){
		retVal = '12';
	}

	return retVal;
}


// update form fields with selected dates
/*******************************************************/	
function selectDateOptions(sm,sd,sy,em,ed,ey){
	var selectMonth1 = sm.substring(0,3);

	selectMonth1 = convertMonth(selectMonth1)	
	
	var selectDay1 = sd;
	var selectYear1 = sy ; //sy.substring(2);
	
	//alert (selectMonth1);
	
	var selectMonth2 = em.substring(0,3);

	selectMonth2 = convertMonth(selectMonth2);	

	var selectDay2 = ed;
	var selectYear2 = ey; // ey.substring(2);
	//alert (selectMonth2+selectDay2+selectYear2);


// update start dates	
	for(intX=0; intX < document.getEvents.startMonth.options.length;  intX++){
          if (document.getEvents.startMonth.options[intX].value == selectMonth1 ){
		document.getEvents.startMonth.value = selectMonth1;
		
          }     
	}   
	
	for(intX=0; intX < document.getEvents.startDay.options.length;  intX++){
          if (document.getEvents.startDay.options[intX].value == selectDay1 ){
		document.getEvents.startDay.value = selectDay1;          
          }     
	}
	
	for(intX=0; intX < document.getEvents.startYear.options.length;  intX++){
          if (document.getEvents.startYear.options[intX].value == selectYear1 ){
		document.getEvents.startYear.value = selectYear1;          
          }     
	}
	
// update end dates

	for(intX=0; intX < document.getEvents.endMonth.options.length;  intX++){
	   if (document.getEvents.endMonth.options[intX].value == selectMonth2 ){
		document.getEvents.endMonth.value = selectMonth2;          
	   }     
	}
	
	for(intX=0; intX < document.getEvents.endDay.options.length;  intX++){
	   if (document.getEvents.endDay.options[intX].value == selectDay2 ){
		document.getEvents.endDay.value = selectDay2;          
	   }     
	}
	
	for(intX=0; intX < document.getEvents.endYear.options.length;  intX++){
	   if (document.getEvents.endYear.options[intX].value == selectYear2 ){
		document.getEvents.endYear.value = selectYear2;          
	   }     
	}   

	
}


/* The following function creates a new input field and then calls datePickerController.create();
   to dynamically create a new datePicker widgit for it */
function newline() {
	  var total = document.getElementById("newline-wrapper").getElementsByTagName("table").length;
	  total++;

	  // Clone the first div in the series
	  var tbl = document.getElementById("newline-wrapper").getElementsByTagName("table")[0].cloneNode(true);

	  // DOM inject the wrapper div
	  document.getElementById("newline-wrapper").appendChild(tbl);

	  var buts = tbl.getElementsByTagName("a");
	  if(buts.length) {
		    buts[0].parentNode.removeChild(buts[0]);
		    buts = null;
	  }

	  // Reset the cloned label's "for" attributes
	  var labels = tbl.getElementsByTagName('label');

	  for(var i = 0, lbl; lbl = labels[i]; i++) {
		    // Set the new labels "for" attribute
		    if(lbl["htmlFor"]) {
				lbl["htmlFor"] = lbl["htmlFor"].replace(/[0-9]+/g, total);
		    } else if(lbl.getAttribute("for")) {
				lbl.setAttribute("for", lbl.getAttribute("for").replace(/[0-9]+/, total));
		    }
	  }

	  // Reset the input's name and id attributes
	  var inputs = tbl.getElementsByTagName('input');
	  for(var i = 0, inp; inp = inputs[i]; i++) {
		    // Set the new input's id and name attribute
		    inp.id = inp.name = inp.id.replace(/[0-9]+/g, total);
		    if(inp.type == "text") inp.value = "";
	  }

	  // Call the create method to create and associate a new date-picker widgit with the new input
	  datePickerController.create(document.getElementById("date-" + total));

	  var dp = datePickerController.datePickers["dp-normal-1"];

	  // No more than 5 inputs
	  if(total == 5) document.getElementById("newline").style.display = "none";

	  // Stop the event
	  return false;
}

function createNewLineButton() {
	  var nlw = document.getElementById("newline-wrapper");

	  var a = document.createElement("a");
	  a.href="#";
	  a.id = "newline";
	  a.title = "Create New Input";
	  a.onclick = newline;
	  nlw.parentNode.appendChild(a);

	  a.appendChild(document.createTextNode("+"));
	  a = null;
}

function loadSWF(swf,width,height,flashvars){
    document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='" + width + "' height='" + height + "' align='middle' ID='flashMovie' >");
    document.write("<param name='allowScriptAccess' value='sameDomain' />");
    document.write("<param name='movie' value='" + swf + "'/>");
    document.write("<param name='quality' value='high' />");
    document.write("<PARAM NAME='FlashVars' VALUE='" + flashvars + "' />");
    document.write("<embed src='" + swf + "' quality='high' width='" + width + "' height='" + height + "' FlashVars='" + flashvars + "' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' NAME='flashMovie' swliveconnect=true  />");
    document.write("</object>");
}

function swapRegion( regionID ) {
    document.getElementById('travel_region_contents').innerHTML = zoneInfo[regionID];

}

function changeImage(theID, theImage){
	document.getElementById(theID).src= theImage;
}

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];}
}
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.0
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 && document.getElementById) x=document.getElementById(n); return x;
}
MM_preloadImages('image.gif');



	






function rotateHomeFeatures(){

    featuredArticleIntervalId = setInterval( "swapHomeFeatures('n',false)" , 4000 ); 
}


