// Capture the user mouse-click and expand the SmartWindow
// Used for Publish and Preview pages
var marker;
var marker1;
var marker2;
var marker3;
var marker4;
var businessName;


function onSmartWinEvent() {

var words='<div style="width:190px;height:120px;"><table width="175" border="0" cellspacing="0" cellpadding="0" ><tr class="blueboxes"><td width="175"><b>'+businessName+'</b></td></tr><tr class="boxes" ><td height=4 width="175"></td></tr><tr class="boxes"><td width="175">'+document.getElementById('address').value+'</td></tr><tr class="boxes"><td width="175"><a href="javascript:showDrivingPage()">Driving Directions</a></td></tr></table></div>';
marker.openSmartWindow(words);
}
function onSmartWinEvent1() {

var words='<div style="width:190px;height:120px;"><table width="175" border="0" cellspacing="0" cellpadding="0" ><tr class="blueboxes"><td width="175"><b>'+businessName+'</b></td></tr><tr class="boxes" ><td height=4 width="175"></td></tr><tr class="boxes"><td width="175">'+document.getElementById('address').value+'</td></tr><tr class="boxes"><td width="175"><a href="javascript:showDrivingPage()">Driving Directions</a></td></tr></table></div>';
marker1.openSmartWindow(words);
}
function onSmartWinEvent2() {

var words='<div style="width:190px;height:120px;"><table width="175" border="0" cellspacing="0" cellpadding="0" ><tr class="blueboxes"><td width="175"><b>'+businessName+'</b></td></tr><tr class="boxes" ><td height=4 width="175"></td></tr><tr class="boxes"><td width="175">'+document.getElementById('address').value+'</td></tr><tr class="boxes"><td width="175"><a href="javascript:showDrivingPage()">Driving Directions</a></td></tr></table></div>';
marker2.openSmartWindow(words);
}
function onSmartWinEvent3() {

var words='<div style="width:190px;height:120px;"><table width="175" border="0" cellspacing="0" cellpadding="0" ><tr class="blueboxes"><td width="175"><b>'+businessName+'</b></td></tr><tr class="boxes" ><td height=4 width="175"></td></tr><tr class="boxes"><td width="175">'+document.getElementById('address').value+'</td></tr><tr class="boxes"><td width="175"><a href="javascript:showDrivingPage()">Driving Directions</a></td></tr></table></div>';
marker3.openSmartWindow(words);
}
function onSmartWinEvent4() {

var words='<div style="width:190px;height:120px;"><table width="175" border="0" cellspacing="0" cellpadding="0" ><tr class="blueboxes"><td width="175"><b>'+businessName+'</b></td></tr><tr class="boxes" ><td height=4 width="175"></td></tr><tr class="boxes"><td width="175">'+document.getElementById('address').value+'</td></tr><tr class="boxes"><td width="175"><a href="javascript:showDrivingPage()">Driving Directions</a></td></tr></table></div>';
marker4.openSmartWindow(words);
}
// Create a lat/lon object
function showMap(divName)
{
	if(document.getElementById('businessName')=='undefined' || document.getElementById('businessName')==null)
	{
		businessName=document.getElementById('hbusinessName').value;
	}
	else
		businessName=document.getElementById('businessName').innerHTML;

	if(document.getElementById('userHeaderImg')=='undefined' || document.getElementById('userHeaderImg')==null);
	else
	{
	if (document.getElementById('userHeaderImg').width > 788)
	{
		document.getElementById('userHeaderImg').style.width = '788px';
	}
	if (document.getElementById('userHeaderImg').height > 114)
		document.getElementById('userHeaderImg').height = 114
	}
	if(document.getElementById('latitude') && document.getElementById('longitude') && document.getElementById('latitude').value!='' && document.getElementById('longitude').value!='')
	{
	var myPoint = new YGeoPoint(document.getElementById('latitude').value,
		 document.getElementById('longitude').value)
	// Set up map type in the constructor
	var map = new YMap(document.getElementById(divName),YAHOO_MAP_REG);
	// Display the map centered on a lattitude and longitude
	map.drawZoomAndCenter(myPoint, 5);
	if(divName=='mapSectionDivisionOne')
	{
		// Create a marker positioned at a lat/lon
		marker1 = new YMarker(myPoint);
		// Add a label to the marker
		marker1.addLabel("<blink>Y!</blink>");
		// Call onSmartWinEvent when the user clicks on the marker
		YEvent.Capture(marker1, EventsList.MouseOver, onSmartWinEvent1);
		// Display the marker
		map.addOverlay(marker1);
	}
	if(divName=='mapSectionDivisionTwo')
	{
		// Create a marker positioned at a lat/lon
		marker2 = new YMarker(myPoint);
		// Add a label to the marker
		marker2.addLabel("<blink>Y!</blink>");
		// Call onSmartWinEvent when the user clicks on the marker
		YEvent.Capture(marker2, EventsList.MouseOver, onSmartWinEvent2);
		// Display the marker
		map.addOverlay(marker2);
	}
	if(divName=='mapSectionDivisionThree')
	{
		// Create a marker positioned at a lat/lon
		marker3 = new YMarker(myPoint);
		// Add a label to the marker
		marker3.addLabel("<blink>Y!</blink>");
		// Call onSmartWinEvent when the user clicks on the marker
		YEvent.Capture(marker3, EventsList.MouseOver, onSmartWinEvent3);
		// Display the marker
		map.addOverlay(marker3);
	}
	if(divName=='mapSectionDivisionFour')
	{
		// Create a marker positioned at a lat/lon
		marker4 = new YMarker(myPoint);
		// Add a label to the marker
		marker4.addLabel("<blink>Y!</blink>");
		// Call onSmartWinEvent when the user clicks on the marker
		YEvent.Capture(marker4, EventsList.MouseOver, onSmartWinEvent4);
		// Display the marker
		map.addOverlay(marker4);
	}

	YEvent.Capture(map, EventsList.MouseClick, showDrivingPage);	
	map.disableKeyControls();
	map.resizeTo(new YSize(310,425));
	}
	
}

function showChild(toPage,winResize)
{
	if(winResize==1)
		docm=window.open(toPage,'','width=800,height=350,staus=no,scrollbars=yes,toolbar=no,location=no,resizable=yes');
	else if(winResize==2)
		docm=window.open(toPage,'','width=650,height=400,staus=no,scrollbars=yes,toolbar=no,location=no,resizable=yes');
	else if(winResize==3)
		docm=window.open(toPage,'','width=600,height=660,staus=no,scrollbars=yes,toolbar=no,location=no,resizable=yes');
}

function showDrivingPage()
{
        
        var mapurl='http://maps.yahoo.com/beta/#maxp=location&q2='+document.getElementById('address').value+'&tcountry=us';
        //window.open("http://maps.yahoo.com/dd?");
        window.open(mapurl);
}
function showCloseWindowDiv()
{
	// code to display close link in preivew mode
	var closeDiv=document.getElementById('closeWindowDiv');
	closeDiv.innerHTML='<a href="#" onClick="window.close();" alt="Click here to close the Window."  title="Click here to close the Window." style="font-size:13px">Close</a><br />&nbsp;';
	
	closeDiv.style.display='';
	closeDiv.style.align='right';
}
function resizeHeaderImg()
{
	return; 
	if(document.getElementById('userHeaderImg')=='undefined' || document.getElementById('userHeaderImg')==null);
	else
	{
		if (document.getElementById('userHeaderImg').width > 788)
		{
			document.getElementById('userHeaderImg').style.width = '788px';
		}
		if (document.getElementById('userHeaderImg').height > 114)
		{
			document.getElementById('userHeaderImg').height = 114
		}
	}
}
