Ext.BLANK_IMAGE_URL = '/extjs/resources/images/default/s.gif';  // Ext 2.0
// gst misc

var lightboxResearch = function(id,intl) {
    Ext.Ajax.request({
        url : '/index.php'
        ,method: 'POST'
        ,params: {module: 'research', action: 'lightbox', ID: id, f_intl_override: intl ? 't' : ''}
        ,success: function(result) {
            if(Ext._lightBoxWindow) {
                Ext._lightBoxWindow.close();
            }
            Ext._lightBoxWindow = new Ext.Window({
                layout       : 'fit'
                ,width       : 680
                ,maxheight   : 640
                ,closeAction :'hide'
                ,plain       : true
                ,title		 : 'RESEARCH PREVIEW'
                ,resizable   : false
                ,html        : result.responseText
				,modal		 : true
                ,autoScroll  : true
            })
    Ext._lightBoxWindow.show();

        }
        ,failure: function(response) {
            Ext.MessageBox.alert('Failed', response.responseText);
        }
    });
}

var lightboxSignup = function() {
    if(Ext._lightBoxWindow) {
        Ext._lightBoxWindow.close();
    }
    Ext._lightBoxWindow = new Ext.Window({
        layout       : 'fit'
        ,width       : 380
        ,height      : 320
        ,closeAction :'hide'
        ,plain       : true
        ,title		 : 'GUIDED TOUR SIGNUP'
        ,resizable   : false
        ,html        : ""
        + '<div class="standard-padding" style="padding-top: 10px">'
        + '  <div id="dynamic">'
        + '     <p>Please provide your Name, Company, and Email address. A member of our Sales team will be in contact with you shortly.</p>'
        + '     <p><input id="f_name" name="f_name" type="text" value="Name" onfocus="if(this.value==\'Name\')this.value = \'\'" placeholder="Name" style="padding: 6px; width: 200px;" /> </p>'
        + '     <p><input id="f_company" name="f_company" type="text" value="Company" onfocus="if(this.value==\'Company\')this.value = \'\'" placeholder="Company" style="padding: 6px; width: 200px;" /> </p>'
        + '     <p><input id="f_email" name="f_email" type="text" value="Email Address" onfocus="if(this.value==\'Email Address\')this.value = \'\'" placeholder="Email" style="padding: 6px; width: 200px;" /> <input type="button" class="button" name="f_submit" value="Sign Up" onclick="submitGuidedSignup()" /></p>'
        + '     <div id="errors"></div>'
        + '  </div>'
        + '  <div id="success" style="display: none"><p>You will be contacted within 24 hours (1 business day) in regards to your inquiry.</p></div>'
    + '</div>'
        ,modal		 : true
        ,autoScroll  : true
    })
    Ext._lightBoxWindow.show();
}

function submitGuidedSignup() {
    
    $.getJSON('/index.php?module=home&action=submitguidedtour&f_email=' + encodeURIComponent($('#f_email').val()) + '&f_name=' + encodeURIComponent($('#f_name').val()) + '&f_company=' + encodeURIComponent($('#f_company').val()), function(result) {
        if(result.length) {
            $('#errors').html('<span style="color: #900;">' + result.join('<br />') + '</span>');
        } else {
            $('#dynamic').hide();
            $('#success').show();
        }
    });    
}

var lightboxVideo = function(id,intl) {
    Ext.Ajax.request({
        url : '/index.php'
        ,method: 'POST'
        ,params: {module: 'video', action: 'lightbox', ID: id, f_intl_override: intl ? 't' : ''}
        ,success: function(result) {
            if(Ext._lightBoxVideo) {
                Ext._lightBoxVideo.close();
            }
            Ext._lightBoxVideo = new Ext.Window({
                layout       : 'fit'
                ,width       : 680
                ,maxheight   : 640
                ,closeAction :'hide'
                ,plain       : true
//                ,title		 : 'View Research'
                ,resizable   : false
                ,html        : result.responseText
				,modal		 : true
                ,autoScroll  : true
            })
    Ext._lightBoxVideo.show();

        }
        ,failure: function(response) {
            Ext.MessageBox.alert('Failed', response.responseText);
        }
    });
}

var lightboxVideoUrlFlash = function(s_url, s_title, i_width, i_height) {
	if(Ext._lightBoxVideo) {
		Ext._lightBoxVideo.close();
	}
	if(typeof i_width == 'undefined') {
		i_width = 400+50;
	} else if(i_width >= 1024) {
		i_width = $(this).width() - 50;
	}
	if(typeof i_height == 'undefined') {
		i_height = 225;
	} else if (i_height >= 568) {
		i_height = $(this).height() - 50;
	}
	Ext._lightBoxVideo = new Ext.ux.MediaWindow({
		id:'MediaWin',
		//renderTo: document.body,
		//height: 300,
//		width: i_width+1,
		title: s_title,
		modal: true,
		autoScroll  : true,
		resizable   : false,
		mediaCfg: {
			mediaType:'SWF',
			url: s_url,
			id:'flashvideo',
			width: i_width,
			height: i_height,
			params: {
				wmode:'opaque'
				,scale: 'exactfit'
				,salign: 't'
				,allowfullscreen: 'true'
			}
		}
	});
	Ext._lightBoxVideo.show();
}

var lightboxVideoUrl = function(s_html, s_title, i_width, i_height) {
	if(Ext._lightBoxVideo) {
		Ext._lightBoxVideo.close();
	}
	if(typeof i_width == 'undefined') {
		i_width = 400+50;
	} else if(i_width >= 1024) {
		i_width = $(this).width() - 50;
	}
	if(typeof i_height == 'undefined') {
		i_height = 225;
	} else if (i_height >= 568) {
		i_height = $(this).height() - 50;
	}
	Ext._lightBoxVideo = new Ext.Window({
                layout       : 'fit'
                ,width       : i_width
                //,maxheight   : i_height
                ,closeAction :'hide'
                ,plain       : true
                ,title		 : s_title
                ,resizable   : false
                ,html        : '<div class="center">' + s_html + '</div>'
				,modal		 : true
                ,autoScroll  : true
            })
	Ext._lightBoxVideo.show();
}

var lightboxHtmlSmall = function(e, url, html_text) {

		if(Ext._lightBoxWindow) {
            Ext._lightBoxWindow.close();
		}

        var windowOptions = {
            layout      : 'fit'
        //				,width       : 700 	//commenting out width will make it auto fit
            ,maxWidth	 : 700
            ,maxHeight	 : 600
        //				,height      : 500  //use autoheight=true
            ,closeAction :'hide'
            ,plain       : true
        //                ,title		 : 'View Research'
            ,resizable   : false
            ,html        : ((url !== null) ? '<img src="' + url + '" />' : '') + ((html_text !== null) ? html_text.innerHTML : '')
            ,modal		 : true //dims background
            ,autoScroll  : true
            ,autoHeight  : true
        };

        if(Ext.isIE7) {
            windowOptions['width'] = 750;
        }

        Ext._lightBoxWindow = new Ext.Window(windowOptions);

		Ext._lightBoxWindow.show();
	}

var corpgovWindow = function(id) {
    Ext.Ajax.request({
        url : '/index.php'
        ,method: 'POST'
        ,params: {module: 'research', action: 'corpgov', 'ID': 6, 'definition': id }
        ,success: function(result) {
            if(Ext._corpgovWindow) {
                Ext._corpgovWindow.close();
            }
            Ext._corpgovWindow = new Ext.Window({
                layout      : 'fit'
                ,width       : 600
                ,height      : 500
                ,closeAction :'hide'
                ,plain       : true
//                ,title		 : 'View Research'
                ,resizable   : false
                ,html        : result.responseText
				,modal		 : true
                ,autoScroll  : true
            })
    Ext._corpgovWindow.show();

        }
        ,failure: function(response) {
            Ext.MessageBox.alert('Failed', response.responseText);
        }
    });
}

var mall_articleWindow = function(articleID) {
    Ext.Ajax.request({

		// function mall_articleWindow(articleID) { window.open('/research/mall/6/?articleID='+articleID,'articleID','height=500,resizable=yes,scrollbars=yes,width=550'); } 

        url : '/index.php'
        ,method: 'POST'
        ,params: {module: 'property', action: 'mall', 'ID': 6, 'articleID': articleID }
        ,success: function(result) {
            if(Ext._articleWindow) {
                Ext._articleWindow.close();
            }
            Ext._articleWindow = new Ext.Window({
                layout      : 'fit'
                ,width       : 550
                ,height      : 500
                ,closeAction :'hide'
                ,plain       : true
//                ,title		 : 'View Research'
                ,resizable   : false
                ,html        : result.responseText
				,modal		 : true
                ,autoScroll  : true
            })
    Ext._articleWindow.show();

        }
        ,failure: function(response) {
            Ext.MessageBox.alert('Failed', response.responseText);
        }
    });
}

var strip_glossaryWindow = function() {
    Ext.Ajax.request({
        url : '/index.php'
        ,method: 'POST'
        ,params: {module: 'property', action: 'strip', 'ID': 7 }
        ,success: function(result) {
            if(Ext._glossaryWindow) { Ext._glossaryWindow.close(); }
            Ext._glossaryWindow = new Ext.Window({
                layout      : 'fit'
                ,width       : 550
                ,height      : 600
                ,closeAction :'hide'
                ,plain       : true
				,title		 : 'Strip Center Glossary'
                ,resizable   : false
                ,html        : result.responseText
				,modal		 : true
                ,autoScroll  : true
            })
			Ext._glossaryWindow.show();
        }
        ,failure: function(response) { Ext.MessageBox.alert('Failed', response.responseText); }
    });
}
