var newURL = '';

function insertSlideShow(agencyNo) {
    var objSlideShow = document.getElementById("SlideShow");
    if (objSlideShow != null){
        newURL = "http://www.unitedcountry.com/AgencyFeaturedProperties.aspx?AgencyNo=" + agencyNo;
        objSlideShow.innerHTML = "<iframe src=" + newURL + " marginwidth=1 marginheight=1 scrolling=no align=center frameborder=0 />";
    }
    return;
}

function hideBody() {
	document.getElementById('pageContent').style.visibility="hidden";
	document.getElementById('pageContent').style.display="none";
	document.getElementById('swapContent').style.visibility="visible";
	document.getElementById('swapContent').style.display="block";
	return frame;
}

function frame(agencyNo) {
	var query = window.location.search.substring(1);
	if (query.indexOf('frame=quick') > -1) {
		hideBody();
		newURL = "http://www.unitedcountry.com/aa/ALLOfficeListings.asp?office=" + agencyNo;
	}
	
	if (query.indexOf('frame=detail') > -1) {
		hideBody();
		newURL = "http://www.unitedcountry.com/aa/OfficeDetailedSearch.asp?office=" + agencyNo;
	}

	document.getElementById('frame').src = newURL;
}

function customSearch() {

    $('#UCSearch a').click(function(){
        hideBody();
        newURL = $(this).attr('href');
        $(this).attr('href','#');
        document.getElementById('frame').src = newURL;
    }); 

}

function officePic(officeID){
    objPic = document.getElementById('OfficePic');
    
    if (objPic != null){
       path = "/OfficePhotos/" + officeID +".jpg";
       $("#OfficePic").attr('src', path);
    }
}

// On Load
function onLoad() {
    insertSlideShow();
    frame(agencyNo);
    officePic(officeID);   
}
