// This declares the popup type
var typeOfPopup;
var currentPopup;
var lastVisied = "alert";


//Print fix....This fixes the IE background problem by hiding it

function addNewPrintStyle(){
    alert('f');
	document.getElementById('printbg').innerHTML = "<div id='printBgFix'></div>";
}
    
function closeWindow(){
	ModalPopups.Close('thisPopup');
	screenOff();
}

function populateAgentMessage()
{
    //alert('sddd');
    document.getElementById('emailAgentMessage').value="dasasd";
}



// Email Agent Popup Function
function emailAgentPopup(path) {   
  
         
         
       var formTag = path + ' " width="389" height="480" scrolling="no" frameborder="0">'
          
      
          var container = document.createElement("div");
          popUpOn = true;
          
          //document.getElementById('imageHome').style.visibility = "hidden";
          container.id = "popupCont";
          document.body.appendChild(container);
          document.getElementById('popupCont').innerHTML = '<div id="popUpContainer_newsSignup" onclick="removePopup()"></div>' +
           '<div id="popUp_newsSignup">' +
            '<iframe src=' +  formTag +
           
      		'</div>' +
      		'</div>';
      	
      	e = document.getElementById('popUpContainer_newsSignup');
      	f = document.getElementById('popUp_newsSignup');
      	repositionPopup();
      	
      	document.getElementById('imageHome').style.visibility = "hidden";
              
        replaceHomeFlash();
} 

// Email Agent Popup Function
function emailFriendPopup(path) {   
      
	   var popWidth = "389px";
	   var popHeight = "498px";
       var formTag = path + ' " width="' + popWidth + '" height="'+ popHeight + '" scrolling="no" frameborder="0">'
      
      
          var container = document.createElement("div");
          popUpOn = true;
          
          //document.getElementById('imageHome').style.visibility = "hidden";
          container.id = "popupCont";
          document.body.appendChild(container);
          document.getElementById('popupCont').innerHTML = '<div id="popUpContainer_newsSignup" onclick="removePopup()"></div>' +
          '<div id="popUp_newsSignup" style="width: ' + popWidth +  '; height: ' + popHeight +'">' +
            '<iframe src=' +  formTag +
           
      		'</div>' +
      		'</div>';
      	
      	e = document.getElementById('popUpContainer_newsSignup');
      	f = document.getElementById('popUp_newsSignup');
      	repositionPopup();
      	
      	document.getElementById('imageHome').style.visibility = "hidden";
              
        replaceHomeFlash(); 
}

function cardPopup(path)
{
    var formTag = path + ' " width="389" height="344" scrolling="no" frameborder="0">'
    
  
    var container = document.createElement("div");
    popUpOn = true;
    
    //document.getElementById('imageHome').style.visibility = "hidden";
    container.id = "popupCont";
    document.body.appendChild(container);
    document.getElementById('popupCont').innerHTML = '<div id="popUpContainer_newsSignup" onclick="removePopup()"></div>' +
     '<div id="popUp_newsSignup">' +
     
        '<iframe src=' +  formTag +
     
		'</div>' +
		'</div>';
	
	e = document.getElementById('popUpContainer_newsSignup');
	f = document.getElementById('popUp_newsSignup');
	repositionPopup();
	
	//var myPopup = document.getElementById('popCont');
	
	//document.getElementById('imageHome').style.visibility = "hidden";
        
    replaceHomeFlash();
} 

function exampleCardPopup(path)
{
	
	var popWidth = "390px";
	var popHeight = "288px";
    var formTag = path + ' " width="' + popWidth + '" height="'+ popHeight + '" scrolling="no" frameborder="0">'
    
  
    var container = document.createElement("div");
    popUpOn = true;
    
    //document.getElementById('imageHome').style.visibility = "hidden";
    container.id = "popupCont";
    document.body.appendChild(container);
    document.getElementById('popupCont').innerHTML = '<div id="popUpContainer_newsSignup" onclick="removePopup()"></div>' +
     '<div id="popUp_newsSignup" style="width: ' + popWidth +  '; height: ' + popHeight +'">' +
     
        '<iframe src=' +  formTag +
     
		'</div>' +
		'</div>';
	
	e = document.getElementById('popUpContainer_newsSignup');
	f = document.getElementById('popUp_newsSignup');
	repositionPopup();
	

} 




function mapPopup2(path)
{
    
    
   
	var popWidth = "328px";
	var popHeight = "434px";
	var formTag = path + ' " width="' + popWidth + '" height="'+ popHeight + '" scrolling="no" frameborder="0">'
  
    var container = document.createElement("div");
    popUpOn = true;
    
    //document.getElementById('imageHome').style.visibility = "hidden";
    container.id = "popupCont";
    document.body.appendChild(container);
    document.getElementById('popupCont').innerHTML = '<div id="popUpContainer_newsSignup" onclick="removePopup()"></div>' +
     '<div id="popUp_newsSignup" style="width: ' + popWidth +  '; height: ' + popHeight +'">' +
     
        '<iframe src=' +  formTag +
     
		'</div>' +
		'</div>';
	
	e = document.getElementById('popUpContainer_newsSignup');
	f = document.getElementById('popUp_newsSignup');
	repositionPopup();
	
	document.getElementById('imageHome').style.visibility = "hidden";
        
    replaceHomeFlash();
} 

function mapPopup(path)
{
  alert('hello');
    
	var popWidth = "727px";
	var popHeight = "397px";
	var formTag = path + ' " width="' + popWidth + '" height="'+ popHeight + '" scrolling="no" frameborder="0">'
  
    var container = document.createElement("div");
    popUpOn = true;
    
    //document.getElementById('imageHome').style.visibility = "hidden";
    container.id = "popupCont";
    document.body.appendChild(container);
    document.getElementById('popupCont').innerHTML = '<div id="popUpContainer_newsSignup" onclick="removePopup()"></div>' +
     '<div id="popUp_newsSignup" style="width: ' + popWidth +  '; height: ' + popHeight +'">' +
     
        '<iframe src=' +  formTag +
     
		'</div>' +
		'</div>';
	
	e = document.getElementById('popUpContainer_newsSignup');
	f = document.getElementById('popUp_newsSignup');
	repositionPopup();
	
	document.getElementById('imageHome').style.visibility = "hidden";
        
    replaceHomeFlash();
} 


// Big map click to display address
function mapShowAddress(parentDiv) {
    typeOfPopup = "info";
	currentPopup = ModalPopups.Info(parentDiv, "thisPopup",   
        "",   
         "<div id='infoDetailContainer'>" +
			 
			 '<div class="mapPopContainer">' +
            '<img class="floatLeft" src="/images/mapPop_top.gif" alt="" />' +
            '<div class="mapPopContent">' +
                '<div class="popControls">' +
                    '<ul>' +
                    '<li class="close"><a onClick="ModalPopups.Close(\'thisPopup\'); screenOff()">CLOSE</a></li>' +
                    '</ul>' +
                '</div>' +
                
                '<div class="printLogo"><img src="/images/logo-local-insurance-agents-sm.gif" width="171" height="66" alt="logo" /></div>' +
                '<div class="contactInfo">' +
                    
                     '<table cellpadding="0" cellspacing="0" border="0">' +
                    '<tr>' +
                        '<td colspan="2"></td>' +
                    '</tr>' +
                    '<tr>' +
                        '<td colspan="2" class="header">Local Insurance Agency</td>' +
                    '</tr>' +
                    '<tr>' +
                        '<td class="label">Phone Number:</td>' +
                        '<td class="info">888-555-1212</td>' +
                    '</tr>' +
                    '<tr>' +
                        '<td class="label">Address:</td>' +
                        '<td class="info">1234 Main Street<br />Any Town, USA 11111</td>' +
                    '</tr>' +
                '</table>' +
                    
                '</div>' +
            '</div>' +
            '<div class="mapPopBottom">' +
                '<div class="mapDirectionLabel">Get Directions:</div>' +
                '<div class="mapDirectionTo"><a href="#">To Here</a></div>' +
                '<div class="mapDirectionFrom"><a href="#">From Here</a></div>' +
            '</div>' +
            
            '<img class="floatLeft" src="/images/mapPop_bottom.gif" alt="" />' +
        '</div>' +
			 
			 
		"</div>",    
        {   
            okButtonText: "Close"  
        }   
    ); 
    
    screenOn();
    
    document.getElementById('infoDetailContainer').style.left =  x+"px";
    document.getElementById('infoDetailContainer').style.top =  y+"px";
    document.getElementById('infoDetailContainer').style.visibility = "visible";
	var opacityTween = new OpacityTween(document.getElementById('infoDetailContainer'),Tween.regularEaseIn, 0, 100, .5);
	opacityTween.start();
}

var x=0,y=0;  

    
function getMousePosition(e) 
{ 
    return e.pageX ? {'x':e.pageX, 'y':e.pageY} : {'x':e.clientX + document.documentElement.scrollLeft + document.body.scrollLeft, 'y':e.clientY + document.documentElement.scrollTop + document.body.scrollTop}; 
} 

function showMousePos(e) 
{ 
    if (!e) e = event; // make sure we have a reference to the event 
    var mp = getMousePosition(e); 
    x=mp.x; 
    y=mp.y; 
    //alert('x:'+x+'y:'+y); 
} 
function init() 
{ 
    document.onmousemove = showMousePos; 
} 

// Info Alt Tag Over

function overlib() {
	if (!olLoaded || isExclusive(overlib.arguments)) return true;
	if (olCheckMouseCapture) olMouseCapture();
	if (over) {
		over = (typeof over.id != 'string') ? o3_frame.document.all['overDiv'] : over;
		cClick();
	}

	// Load defaults to runtime.
  olHideDelay=0;
	o3_text=ol_text;
	o3_cap=ol_cap;
	o3_sticky=ol_sticky;
	o3_background=ol_background;
	o3_close=ol_close;
	o3_hpos=ol_hpos;
	o3_offsetx=ol_offsetx;
	o3_offsety=ol_offsety;
	o3_fgcolor=ol_fgcolor;
	o3_bgcolor=ol_bgcolor;
	o3_textcolor=ol_textcolor;
	o3_capcolor=ol_capcolor;
	o3_closecolor=ol_closecolor;
	o3_width=ol_width;
	o3_border=ol_border;
	o3_cellpad=ol_cellpad;
	o3_status=ol_status;
	o3_autostatus=ol_autostatus;
	o3_height=ol_height;
	o3_snapx=ol_snapx;
	o3_snapy=ol_snapy;
	o3_fixx=ol_fixx;
	o3_fixy=ol_fixy;
	o3_relx=ol_relx;
	o3_rely=ol_rely;
	o3_fgbackground=ol_fgbackground;
	o3_bgbackground=ol_bgbackground;
	o3_padxl=ol_padxl;
	o3_padxr=ol_padxr;
	o3_padyt=ol_padyt;
	o3_padyb=ol_padyb;
	o3_fullhtml=ol_fullhtml;
	o3_vpos=ol_vpos;
	o3_aboveheight=ol_aboveheight;
	o3_capicon=ol_capicon;
	o3_textfont=ol_textfont;
	o3_captionfont=ol_captionfont;
	o3_closefont=ol_closefont;
	o3_textsize=ol_textsize;
	o3_captionsize=ol_captionsize;
	o3_closesize=ol_closesize;
	o3_timeout=ol_timeout;
	o3_function=ol_function;
	o3_delay=ol_delay;
	o3_hauto=ol_hauto;
	o3_vauto=ol_vauto;
	o3_closeclick=ol_closeclick;
	o3_wrap=ol_wrap;	
	o3_followmouse=ol_followmouse;
	o3_mouseoff=ol_mouseoff;
	o3_closetitle=ol_closetitle;
	o3_css=ol_css;
	o3_compatmode=ol_compatmode;
	o3_fgclass=ol_fgclass;
	o3_bgclass=ol_bgclass;
	o3_textfontclass=ol_textfontclass;
	o3_captionfontclass=ol_captionfontclass;
	o3_closefontclass=ol_closefontclass;
	
	setRunTimeVariables();
	
	fnRef = '';
	
	// Special for frame support, over must be reset...
	o3_frame = ol_frame;
	
	if(!(over=createDivContainer())) return false;

	parseTokens('o3_', overlib.arguments);
	if (!postParseChecks()) return false;

	if (o3_delay == 0) {
		return runHook("olMain", FREPLACE);
 	} else {
		o3_delayid = setTimeout("runHook('olMain', FREPLACE)", o3_delay);
		return false;
	}
}


// Info Alt Tag off

// Clears popups if appropriate
function nd(time) {
	if (olLoaded && !isExclusive()) {
		hideDelay(time);  // delay popup close if time specified

		if (o3_removecounter >= 1) { o3_showingsticky = 0 };
		
		if (o3_showingsticky == 0) {
			o3_allowmove = 0;
			if (over != null && o3_timerid == 0) runHook("hideObject", FREPLACE, over);
		} else {
			o3_removecounter++;
		}
	}
	
	return true;
}


var screenState = false;

// Screen background check
function checkScreenStatus(){
	if(screenState == true){
		screenOn();
	}
}


function screenOn(){
	var documentW;
	var documentH;
	
	if(typeOfPopup == "info"){
		document.getElementById('blockDiv').style.visibility = "visible";
		document.getElementById('blockDiv').style.filter="alpha(opacity='0')";
			document.getElementById('blockDiv').style.MozOpacity = '0';
	}
	else{
		document.getElementById('blockDiv').style.visibility = "visible";
		document.getElementById('blockDiv').style.filter="alpha(opacity='85')";
		document.getElementById('blockDiv').style.MozOpacity = '0.85';
		}
	
	if (navigator.appName=="Netscape" || browserVersion == "notIE") {
		documentW = document.body.clientWidth;
		documentH = document.body.clientHeight;
		document.getElementById('blockDiv').style.width = (documentW)+"px";
		document.getElementById('blockDiv').style.height = (documentH)+"px";
	}
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		documentW = document.body.offsetWidth;
		documentH = document.body.offsetHeight;
		document.getElementById('blockDiv').style.width = documentW - 1;
		document.getElementById('blockDiv').style.height = documentH - 1;
	}
	
	
	if(browserVersion == "ie6" && typeOfPopup != "info"){
		var dropdownHolder = document.getElementsByTagName('select');
		var dropdownTotal = dropdownHolder.length;
		for(var i=0; i<dropdownTotal; i++){
			dropdownHolder[i].style.visibility = "hidden";
		}
	}
	
	
	var popBackgroundDiv = document.getElementById('thisPopup_background');
	if(browserVersion != "ie6"){
		popBackgroundDiv.style.visibility = "visible";
	}
	if(typeOfPopup != "info"){
		document.getElementById('blockDiv').style.visibility = "visible";
	}
	
	if(browserVersion != "ie6"){
		popBackgroundDiv.setAttribute('onclick', 'ModalPopups.Close("thisPopup"); screenOff();'); 
	}
	screenState = true;
}

function screenOff(){
	alert('screenOFF');
	screenState = false;
	typeOfPopup = "alert";
	if(document.getElementById('pageCont'))
	    document.getElementById('pageCont').className = '';
	
	if(document.getElementById('printbg')){
		document.getElementById('printbg').innerHTML = "";
	}
			
	var popBackgroundDiv = document.getElementById('thisPopup_background');
	
	if(popBackgroundDiv){
		popBackgroundDiv.parentNode.removeChild(ModalPopupsSupport.findControl("thisPopup_background"));
	}
	
	document.getElementById('blockDiv').style.visibility = "hidden";
	
	if(browserVersion == "ie6" && typeOfPopup != "info"){
		var dropdownHolder = document.getElementsByTagName('select');
		var dropdownTotal = dropdownHolder.length;
		for(var i=0; i<dropdownTotal; i++){
			dropdownHolder[i].style.visibility = "visible"
		}
	}

}
