var CONTACT_popup;
$(document).ready(CONTACT_init);

function CONTACT_init(){
	$("a.CONTACT").click(function(event){
		event.preventDefault();
		this.blur();
		//CONTACT_show(this.href);
		CONTACT_open_popup();
	});
}

function CONTACT_open_popup(radioDefault) {
 
	// Set default radio button option
	var radio = (radioDefault==undefined) ? 0 : radioDefault;
	
	if (CONTACT_popup == undefined || CONTACT_popup.closed) {	
		var width = 500;
		var height = 650;
		var features = '';
		var x, y;
		x = (640 - width)/2, y = (480 - height)/2;
		if (screen) {
			y = (screen.availHeight - height)/2;
			x = (screen.availWidth - width)/2;
		}
		if (screen.availWidth > 1800) { 
			x = ((screen.availWidth/2) - width)/2; 
		} 
		CONTACT_popup = window.open('form_contact.php?radio='+radio,'contact','scrollbars=no,width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+','+features);
	}
	CONTACT_popup.focus();
}	

function CONTACT_close_remote() {
	var opener = window.opener;
	if (opener) {
		this.close();
		opener.focus();
		opener.CONTACT_remove();
	}
}		

function CONTACT_show(url) {
//	if ( !$("#CONTACT_HideSelect").length ) {
//		$("body").append("<iframe id='CONTACT_HideSelect'></iframe><div id='CONTACT_overlay'></div><div id='CONTACT_window'></div>");
//		$("#CONTACT_overlay").click(CONTACT_remove);
//	}
//	$(window).scroll(CONTACT_position);
//	CONTACT_overlaySize();
}

function CONTACT_remove() {
 	$("#CONTACT_imageOff").unbind("click");
	$("#CONTACT_overlay").unbind("click");
	$("#CONTACT_closeWindowButton").unbind("click");
	$("#CONTACT_window").fadeOut("fast",function(){$('#CONTACT_window,#CONTACT_overlay,#CONTACT_HideSelect').remove();});
	$("#CONTACT_load").remove();
	return false;
}

function CONTACT_position() {
	var pagesize = CONTACT_getPageSize();	
	var arrayPageScroll = CONTACT_getPageScrollTop();
	var style = {width: CONTACT_WIDTH, left: (arrayPageScroll[0] + (pagesize[0] - CONTACT_WIDTH)/2), top: (arrayPageScroll[1] + (pagesize[1]-CONTACT_HEIGHT)/2)};
	$("#CONTACT_window").css(style);
}

function CONTACT_overlaySize(){
	if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX) {	
		yScroll = window.innerHeight + window.scrollMaxY;
		xScroll = window.innerWidth + window.scrollMaxX;
		var deff = document.documentElement;
		var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;
		var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;
		xScroll -= (window.innerWidth - wff);
		yScroll -= (window.innerHeight - hff);
	} else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth){
		yScroll = document.body.scrollHeight;
		xScroll = document.body.scrollWidth;
	} else { 
		yScroll = document.body.offsetHeight;
		xScroll = document.body.offsetWidth;
  	}
	$("#CONTACT_overlay").css({"height": yScroll, "width": xScroll});
	$("#CONTACT_HideSelect").css({"height": yScroll,"width": xScroll});
}

function CONTACT_getPageScrollTop(){
	var yScrolltop;
	var xScrollleft;
	if (self.pageYOffset || self.pageXOffset) {
		yScrolltop = self.pageYOffset;
		xScrollleft = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop || document.documentElement.scrollLeft ){	 
		yScrolltop = document.documentElement.scrollTop;
		xScrollleft = document.documentElement.scrollLeft;
	} else if (document.body) {
		yScrolltop = document.body.scrollTop;
		xScrollleft = document.body.scrollLeft;
	}
	arrayPageScroll = new Array(xScrollleft,yScrolltop) 
	return arrayPageScroll;
}

function CONTACT_getPageSize(){
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight
	arrayPageSize = new Array(w,h) 
	return arrayPageSize;
}
