Contact = Class.create();
Contact.prototype = {
	initialize : function(base, iframe_title, instance) {
		this.base = base;
		this.iframeTitle = (iframe_title) ? iframe_title : 'Contact Us';
		
		this.instance = (instance) ? instance : 'Contact';//获取实例名
		
		$('chat-popup-closed').show();
		
		var obj = this;
		$('contactscript').select('.chat-link-open').each(function(each_element) {
			each_element.observe('click', obj.openIframeWindow.bindAsEventListener(obj));
		});
	},
	
	openIframeWindow : function() {
		var tempurl = this.base + '/contact/iframe/';
		var xscroll = document.documentElement.clientWidth - 200;
		var openwindow_x = (xscroll / 2) - 100;
		
		var getframe = document.createElement("iframe");
		getframe.setAttribute("id", "contactiframe");
		getframe.setAttribute("scrolling", "no");
		getframe.setAttribute("frameBorder", "0");
		getframe.setAttribute("src", tempurl);
		
		var closewindow = document.createElement("div");
		closewindow.innerHTML = '<div id="contactiframe-close"><div class="contactiframe-close-text">' + this.iframeTitle + '</div><div class="contactiframe-close-img"><a href="" onclick="' + this.instance + '.closeIframeWindow();return false;"><img src="' + this.base + '/images/contact/close.gif" /></a></div></div>';

		var chatlayer = document.createElement("div");
		chatlayer.setAttribute("id", "contactiframe-parent");
		chatlayer.style.left = openwindow_x + "px";
		chatlayer.appendChild(closewindow);
		chatlayer.appendChild(getframe);
		
		document.body.appendChild(chatlayer);
		$('contactscript').hide();
	},
	
	closeIframeWindow : function() {
		$('contactiframe-parent').remove();
		$('contactscript').show();
	}
};

