// JavaScript Document
window.addEvent('domready', function(){
	$$('a.OACBanner').addEvent('click', function(){
		var req = new Request({url:'/clickthru.php',
			method: 'get'
		}).send(this.get('rel'));
	});
	
	var aryInputValues=Array();
	$$('input').each(function(item, index){
		aryInputValues[item.get('id')]=item.get('value');
	})

	
	$$('input').addEvent('focus', function(){
		if (this.get('value')==aryInputValues[this.get('id')]) {
			this.set('value','');
		}
	});
	
	$$('input').addEvent('blur', function(){
		if (this.get('value')=="") {
			this.set('value',aryInputValues[this.get('id')]);
			if ($('rfv'+this.get('id'))) {
				validate(this,'');					 
			}
		}
	});
	
	

	$$('div.button-add').addEvent('click', function(){
		var req = new Request({url:'/add-to-tour.php',
			method: 'get',
			onSuccess: function(html,xml) {
				AlertText(html);
			}
		}).send(this.get('rel'));
	});
	
	
	$$('input.auto-productcompare').addEvent('click', function(){
		var req = new Request({url:'/add-to-comparison.php',
			method: 'get',
			onSuccess: function(html,xml) {
				AlertText(html);
			}
		}).send(this.get('rel'));
	});
	
	
	$$('input.auto-productcatalog').addEvent('click', function(){
		var req = new Request({url:'/catalog.php',
			method: 'get',
			onSuccess: function(html,xml) {
				AlertText(html);
			}
		}).send(this.get('rel'));
	});
	
	
	
	if ($('frmOptions')) {
		//buildData();
	}
	
	if ($('frmSubscribe')) {
		$('frmSubscribe').set('send', {
			onSuccess: function(html,xml) {
				AlertText(html);
			}
		});
		
		$('frmSubscribe').addEvent('submit', function(e) {
			if (validate(document.getElementById('frmSubscribe'),'')) {
				new Event(e).stop();
				this.send();
			}
		});
	}
	
	
})


function AlertText(txt) {
	if ($('alert')) {
		$('alert').setStyle('display', 'block'); 
		$('alert').set('html',txt);
	}
}

function OpenLargerNoChrome(src,width,height) {
		window.open(src,'lg','width='+width+',height='+height+',resizable=1,scrollbars=0,location=0,status=0');
	}


function ImgResize(img,container,imgH,imgW,containerH,containerW) {
	return;
	var imgContainer=document.getElementById(container);	
	if (imgContainer) {
		imgContainer.style.display='inline-block';
		imgContainer.style.textAlign='center';
	}
	img.style.verticalAlign='middle';
	img.style.display='inline-block';
	
	containerH=(containerH ? containerH : imgContainer.clientHeight);
	containerW=(containerW ? containerW : imgContainer.clientWidth);
	//alert(containerH);
	var scaleH = containerH / imgH;
	var scaleW = containerW / imgW;	

	if (scaleH < scaleW) {
		img.style.height = containerH + "px";
		img.style.width = Math.round(imgW * scaleH) + "px";
		//img.style.height = imgH + "px";
		//img.style.width = imgW + "px";
	} else {
		img.style.width = containerW + "px";
		img.style.height = Math.round(imgH * scaleW) + "px";
		//img.style.height = imgH + "px";
		//img.style.width = imgW + "px";
	}	

}

