
thisURL=""



function overThisMenu(theObj){
	if(theObj){
	    URL_txt = theObj.getAttribute("thisURL");
	    theClassName = theObj.className;
	    theObj.className = theClassName + "_on";

   		theObj.onmouseout = outThisMenu;
		theObj.onclick = clickThisMenu;
	}
}

function outThisMenu(){
	this.className = theClassName;
}

function clickThisMenu(){
    if(URL_txt != "#"){
   	    this.className = theClassName;
        document.location = URL_txt;
    }
}

function requiredThis(objId){
    if(typeof objId == "string"){
        if(document.getElementById(objId)){
            document.getElementById(objId).innerHTML = "&nbsp;*";
        }
    } else {
        for(var i=0; i<objId.length; i++){
            if(document.getElementById(objId[i])){
                document.getElementById(objId[i]).innerHTML = "&nbsp;*";
            }
        }
    }
}

function notRequired(){
 for(var i=0; i<notRequired.arguments.length; i++){
    if(typeof notRequired.arguments[i] == "string"){
        if(document.getElementById(notRequired.arguments[i])){
          document.getElementById(notRequired.arguments[i]).innerHTML = "";
        }
    } else {
        for(var j=0; j<notRequired.arguments[i].length; j++){
            if(document.getElementById(notRequired.arguments[i][j])){
                document.getElementById(notRequired.arguments[i][j]).innerHTML = "";
            }
        }
    }
 }
}

var id="required";
var emailID = id+"Email";
var addressID = new Array();
    addressID.push(id+"Street");
    addressID.push(id+"City");
    addressID.push(id+"State");
    addressID.push(id+"Zip");
var telephoneID = id+"Telephone";

var requiredElements = new Array();

function requiredFormElement(id, type, label, validate, group){
    this["object"];
    this["id"] = id;
    this["type"] = type;
    this["label"] = label;
    this["active"] = validate;
    this["group"] = group;
}

function requiredNow(required){

    if(required && required != ""){
        switch (required) {
            case "Email": {
                requiredThis(emailID);
                notRequired(addressID, telephoneID);
                activateRequiredGroup(required);
                return true;
            }
            case "Mail": {
                requiredThis(addressID);
                notRequired(emailID, telephoneID);
                activateRequiredGroup(required);
                return true;
            }
            
            case "Telephone": {
                requiredThis(telephoneID);
                notRequired(emailID, addressID);
                activateRequiredGroup(required);
                return true;
            }
            default: return false;
        }
    }
}

function requiredNowByDivision(required, division)
{
    if(required && required != "")
    {
    /*This was changed for Market 1st*/
//		if (division && division != "" && division == "255000000000")
//		{
//			requiredThis(emailID);
//			requiredThis(addressID);
//			requiredThis(telephoneID);
//			groupsToActivate = new Array();
//			groupsToActivate.push("Email");
//			groupsToActivate.push("Mail");
//			//groupsToActivate.push("Telephone");
//			//activateRequiredGroups(groupsToActivate);
//			
//			for(var j=0; j<requiredElements.length; j++){
//				var active = false;
//				if(requiredElements[j]["group"]){
//					if (groupsToActivate)
//					{
//						for (var k=0; k < groupsToActivate.length; k++)
//						{
//							if(requiredElements[j]["group"] == groupsToActivate[k])
//							{
//								active = true;
//								break;
//							}
//						}
//						
//						requiredElements[j]["active"] = active;
//					}
//				}
//			}
//    
//			return true;
//		}
//		else
//		{
			switch (required) 
			{
				case "Email": {
					requiredThis(emailID);
					notRequired(addressID, telephoneID);
					activateRequiredGroup(required);
					return true;
				}
				case "Mail": {
					requiredThis(addressID);
					notRequired(emailID, telephoneID);
					activateRequiredGroup(required);
					return true;
				}
				case "Telephone": {
					requiredThis(telephoneID);
					notRequired(emailID, addressID);
					activateRequiredGroup(required);
					return true;
				}
				default: return false;
			}
        }
    }
//}

var lastList;

function initSwitch(listObj){
  if(listObj.options.length>0){
    if(listObj.options[0].selected){
        for(var j=1; j<listObj.options.length; j++){
            listObj.options[j].selected = false;
        }
    }
    
    if(lastList && lastList != listObj){
        for(var i=0; i<lastList.options.length; i++){
            lastList.options[i].selected = false;
        }
    }
    lastList = listObj;
  }
}

function expandCollapse(imgObj){
	var blockObj
	if( typeof imgObj == "object"){
		blockObj = imgObj.parentNode.parentNode.getElementsByTagName("DIV").item(0);
		
		if(blockObj.style.display == "none"){
			blockObj.style.display = "block";
			imgObj.src = "images/collapseThis.jpg";
		} else {
			blockObj.style.display = "none";
			imgObj.src = "images/expandThis.jpg";
		}
	}
}

function getFormElement(formThis, formElementID){
    for(var i=0; i<formThis.elements.length; i++){
        var thisID = formThis.elements[i].id;
        var nameSplitArray = thisID.split("_");
        var name = nameSplitArray[nameSplitArray.length - 1];
        if(name == formElementID){
            return formThis.elements[i];
        }
    }
}
function copyContactInfo(checkBoxObj){
    if(checkBoxObj){
      formThis = checkBoxObj.form;
      var toObjectIdList = checkBoxObj.value.split(",");
        for(var i=0; i<toObjectIdList.length; i++){
            toObject = getFormElement(formThis, toObjectIdList[i]);
            fromObject = getFormElement(formThis, toObjectIdList[i].replace("Owner", "Contact"));
            
            toObject.value = (checkBoxObj.checked)? fromObject.value : fromObject.defaultValue;
            toObject.focus();
        }
    }
}

function openWindow(url){
    if(typeof url == "string"){
        window.open(url, 'Window', 'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=1,resizable=0,width=700,height=700,left = 10,top = 10');
    } 
}

function openWindowInvestorRelations(url){
    if(typeof url == "string"){
        window.open(url, 'Window', 'toolbar=1,scrollbars=yes,location=1,statusbar=1,menubar=1,resizable=1,width=700,height=700,left = 10,top = 10');
    }
}

function openWindowInsurance(url){
    if(typeof url == "string"){
        window.open(url, 'Window', 'toolbar=1,scrollbars=yes,location=1,statusbar=1,menubar=1,resizable=1,width=700,height=700,left = 10,top = 10');
    }
}

function openWindowInsurance2(url){
    if(typeof url == "string"){
        window.open(url, 'Window');
    }
}

function openWindowMortgageCalculator(url){
    if(typeof url == "string"){
        window.open(url, 'Window', 'toolbar=0,scrollbars=yes,location=0,statusbar=1,menubar=0,resizable=yes,width=680,height=450,left = 10,top = 10');
    }
}

function openWindowNavigation(url){
    if(typeof url == "string"){
        window.open(url, 'Window', 'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=1,resizable=0,width=700,height=700,left = 10,top = 10');
    }
    
}

function openWindowDrivingDirections(url){
    if(typeof url == "string"){
        window.open(url, 'DrivingDirectionsWindow', 'toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=1,resizable=0,width=785,height=700,left = 10,top = 10');
    }
}

function openWindowPlanPopup(url){
    if(typeof url == "string"){
        window.open(url, "Window", "toolbar=no,scrollbars=yes,resizable=yes,location=0,statusbar=0,menubar=0,width=1024,height=768");
    }
}

function getCleanContent(sourceDoc, id){
	thisObj = sourceDoc.getElementById(id);
	//Strip off corner images
	allImages = thisObj.getElementsByTagName("IMG");
	for (var i=0; i<allImages.length; ++i){
	    if(allImages.item(i).src.indexOf("frameCorner") > 0){
	        allImages.item(i).src = getPath() + "images/empty.gif";
	    }
	}
	
	//Strip off none-printable elements
	allDivs = thisObj.getElementsByTagName("DIV");
	for (var j=0; j<allDivs.length; ++j){
	    if(allDivs.item(j).className == "nonePrintable"){
	        allDivs.item(j).className = "noneVisible";
	        allDivs.item(j).innerHTML = "";
	    }
	}	
	return thisObj.innerHTML;
}

function printPreview(id){
    var thisPath = getPath();
    //Get complete content
    var containerObj = document.getElementById(id);
    
    var containterAttributes = containerObj.attributes;
 
    content = "<" + containerObj.tagName;
	
	for (var i = 0; i < containterAttributes.length; i++)
		content += " " + containterAttributes[i].name + "=\"" + containterAttributes[i].value + "\"";
		
	content += ">" + containerObj.innerHTML + "</" + containerObj.tagName + ">";
		  
	TheNewWin = window.open('', 'Print', 'toolbar=1,scrollbars=1,location=0,statusbar=0,menubar=1,resizable=1,width=810,height=900,left = 100,top = 100');
	TheNewWin.document.open();
	TheNewWin.document.write(content);
	TheNewWin.document.close();
	//Strip off and frame non printable content
    

	content = getCleanContent(TheNewWin.document, id);
	TheNewWin.document.open();
	TheNewWin.document.write("");
	TheNewWin.document.close();
	builtHTML = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">'
	    + '<head>'
	    + '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />'
	    + '<title>MI Homes</title>'
	    + '<link href="'
	    + thisPath
	    + 'linked/css/print.css" rel="stylesheet" type="text/css" />'
	    + '<script language="JavaScript" type="text/javascript">'
	    + 'function hideTable(){'
        + 'document.getElementById("tblHeader").style.visibility = "hidden";'
        + 'document.getElementById("tblFooter").style.visibility = "hidden";'
        + '}'
	    + 'function printit(){'
	    + 'if (!window.print){'
	    + 'alert("You need NS4.x or IE5 to use this print button!");'
	    + 'return false;'
	    + '}'
	    + 'window.print(); return false;'
	    + '}'
	    + '</script>'
	    + '</head>'
	    + '<body onLoad="hideTable()">'
	    + '<table width="711px" align="center" ><tr><td valign="top">'
	    + '<tr><td class="printHeader"><img src="'+thisPath+'images/logo_print.jpg" border="0" width="711px" /></td></tr>'
	    + '<tr><td valign="top" style="padding-right: 15px;">'
	    + content 
	    + '</td></tr>'
	    + '<tr><td class="printCopyright"><img src="'+thisPath+'images/horLine_print.jpg" border="0" /></td></tr><tr><td class="printCopyright">Copyright 2007, M/I Homes, Inc. All rights reserved.</td></tr></table>'
	    + '</body>'
	    + '</html>';
	
	TheNewWin.document.open();
	TheNewWin.document.write(builtHTML);
	TheNewWin.document.close();
}

function printPreviewBasic()
{
    window.print();  
}

function ExpandMainNavigation()
{
	var divObj = document.getElementById('menuMain');
	divObj.style.height = '85px';
	divObj.style.zIndex = '400';
}

function CollapseMainNavigation()
{
	var divObj = document.getElementById('menuMain');
	divObj.style.height = '85px';
	divObj.style.zIndex = '1';
}

function ResetAllFormFields()
{
	document.getElementById('hiddenResetButton').click();
}

// POST DNA - IE.. Cool Stuff

function showhideitems(item, containerImage, maxImage, minImage)
{
    if((document.getElementById(item).style.display == 'inline') || (document.getElementById(item).style.display == ''))
	{
	    document.getElementById(item).style.display = 'none';
	    if(containerImage != '')
	    {
		    document.getElementById(containerImage).style.backgroundImage="url('"+minImage+"')";
	    }
	}
	else
	{
		document.getElementById(item).style.display = 'inline';
		if(containerImage != '')
	    {
		    document.getElementById(containerImage).style.backgroundImage="url('"+maxImage+"')";
	    }
	}
}



