function showDetailsPreviewonView(obj, str) 
{
//alert('temp');	
var masterDetails = {
    flag : "",
    counter : 0,
    show : false
}

	if ( $(obj).css("visibility") == 'hidden' || ( str!=undefined && str!=masterDetails.flag ) ){
          
		masterDetails.flag = str;
		masterDetails.show = true;
		masterDetails.counter++;
		$.get(str, 
		{
		    counter: masterDetails.counter,
		    rndVal: (new Date().getTime())
		}, 
		function(txt){ 
		    var str = txt.split("counterSeparator");
		    if ( masterDetails.counter == str[1] ) { 
		    	
		    	$(obj).html(str[0]); 
		    	
		    	//alert($(obj).html());
		    	
			if ( masterDetails.show ) { $(obj).css("visibility", "visible"); }
		    }
		    
		});				
	  
        }
};	


Rest = new Array();
RestTitle = Array( '', '', 'Link', 'Meal Calculator', 'Other Link', 'Map', 'HealthyID')
RestAction = Array('','','link','link','link','link','Hlink' )
function AddRestaurant( Title, ExtraText, Link, MealCalc, OtherLink, MapLink, HealthyID ){
	//temp = '';
	alert('pppp');
	Rest.push( Array(Title, ExtraText, Link, MealCalc, OtherLink, MapLink, HealthyID) );
/*	temp += Title +"<br>";
	temp += ExtraText +"<br>";
	temp += Link +"<br>";
	temp += MealCalc +"<br>";
	temp += OtherLink +"<br>";
	temp += MapLink +"<br>";
	temp += HealthyID +"<hr>";
*/	
	}


function listRestaurants(obj){

	//alert('temp');
	temp = '<select onchange="showRestaurant(\'#Restaurants\',this.selectedIndex-1); $(\'#HealthyChoices\').html(\'\');"><option>Select One</option>';
	for (i=0; i<Rest.length-1; ++i) {
	  temp += "<option>"+ Rest[i][0] + "</option>" ;
	  Rest[i][1] = unescape(Rest[i][1]);
	} // for
	temp += '</select>';
	
	$(obj).html(temp);


}
function showDetailsPreviewonViewScript(obj, str) 
{
//alert('temp');	
var masterDetails = {
    flag : "",
    counter : 0,
    show : false
}

	if ( $(obj).css("visibility") == 'hidden' || ( str!=undefined && str!=masterDetails.flag ) ){
          
		masterDetails.flag = str;
		masterDetails.show = true;
		masterDetails.counter++;
		$.get(str, 
		{
		    counter: masterDetails.counter,
		    rndVal: (new Date().getTime())
		}, 
		function(txt){ 
		    var str = txt.split("counterSeparator");
		    if ( masterDetails.counter == str[1] ) { 
		    	Rest = str[0].split('|');
		    	for (i=0; i<Rest.length-1; ++i) {
		    		Rest[i] = Rest[i].split(",");
		    	}
		    	listRestaurants('#RestaurantsList');
		    	//$(obj).html(str[0]); 
			if ( masterDetails.show ) { $(obj).css("visibility", "visible"); }
		    }
		    
		});				
	  
        }
};
function showRestaurant(obj,daIndex){
	
	temp = '';
	for (i=0; i<Rest[daIndex].length; ++i) {
		
		if (RestAction[i] == 'link'){
			if (Rest[daIndex][i] !== ''){ 
				temp += "<a href=\"" + unescape(Rest[daIndex][i]) + "\" target=_blank >" + RestTitle[i] + "</a><br>" ;
			}
		}else 
		if (RestAction[i] == 'Hlink'){
			if (Rest[daIndex][i] !== ''){ 
				temp += "<a href=\"javascript:void(0)\" onclick=\"showDetailsPreviewonView('#HealthyChoices', 'HealthierChoicesView.php'+'?mastertable=RestaurantView&amp;masterkey1="+Rest[daIndex][i]+"');\">Healthier Choices</a>";
				//temp += "<a href=\"" + Rest[daIndex][i] + "\">" + RestTitle[i] + "</A><br>" ;
			}
		}else{
	  		temp += "<P>"+RestTitle[i] + " " + Rest[daIndex][i] + "</P>" ;
	  	}
	} // for

	$(obj).html(temp);
	
	}
	
	//document.write('<style type="text/css"> #RestaurantsList { height:50px; width:300px;  background-color:#cccccc;} #Restaurants {} #HealthyChoices {} </style>');
	
