
//////////////////////////////////////////////////////////////////////// SAN
function openTypModal(url){
	var myTypModal = new Control.Modal({
		href: url
		},
		{
		//overlayCloseOnClick: false,
		fade: true
	});
	myTypModal.open();
}

function openIframeModal(url){
	var myIFModal = new Control.Modal({
		href: url
		},
		{
		 overlayCloseOnClick: true,
		fade: true,
		iframe: true,
		iframeTemplate: new Template('<iframe src="#{href}" width="690px" height="660px" frameborder="0" id="#{id}"></iframe>')
	});
	myIFModal.open();
}

function openCoupon(url){
	var myModal = new Control.Modal({
		href: url
		},
		{
		//overlayCloseOnClick: false,
		fade: true,
		offsetLeft: 110, //for use with 'relative'
		offsetTop: 50, //for use with 'relative'
		position: 'relative' //'absolute' or 'relative'
	});
	myModal.open();
}

function disableModalPrint() {
	document.getElementById('modalPrint').disabled=true;
}

function enableModalPrint() {
	document.getElementById('modalPrint').disabled=false;
}

function onElementAvailable( sId , callback ){
	if( (typeof(sId) != 'string') || 
		(typeof(callback) != 'function') ) return false;
	
	
	var fn = function(){
		var el = document.getElementById(sId);
		if( el) return callback.call(el);
		fn = null;
		return setTimeout(arguments.callee);
	};
	fn();

}

function onElementContentReady( sId , callback ){
	if( (typeof(sId) != 'string') ||
		(typeof(callback) != 'function') ) return false;
	
	var fn = function(){
		var el = this;
		var sTag = el.tagName ;
		var fn2 = function(){
			
			//check readyState first
			if(el.readyState != 'complete') return setTimeout(arguments.callee,100);
			
			//if close tag is not required, then call callback
			if(!el.canHaveHTML){
				//close tag is not required
				return callback.call(el);
			}

			//check if it has a close tag
			if(el.cloneNode(false).outerHTML.indexOf( '</' + sTag + '>') === -1 ) {
				//close tag is not available yet
				return setTimeout(arguments.callee,100);
			}
			
			//now we have the full outerHTML
			
			fn = fn2  = null; //release some memory, if applicable
			callback.call(el);//call callback			
		};
		fn2();
	}
	onElementAvailable( sId , fn )
}