
			

// ONLOAD/ONRESIZE: GET ACTUAL WINDOW HEIGHT FOR ADJUSTED POSITION OF CONTENT
// INITIALIZE N FOR ADJUSTMENTS
function getWindowHeight(){
	if(window.innerHeight != null) {
		return window.innerHeight;
	}
	if (document.body.offsetHeight != null) {
		return document.body.offsetHeight;
	}
	return (null);
}

function getWindowWidth(){
	if(window.innerWidth != null) {
		return window.innerWidth;
	}
	if (document.body.offsetWidth != null) {
		return document.body.offsetWidth;
	}
	return (null);
}

function adjustPos() {
	var topPos = getWindowHeight();
	var leftPos = getWindowWidth();
	
	//document.getElementById('maintable').style.height = (topPos-128) + 'px';
		
}

function mshow(element){
           this.addClass('hover');
           }
function mhide(element){
           this.removeClass('hover');
     }

//-->

// MOOTOOLS EFFECTS

window.addEvent('domready', function() {
	
	//var plusURL = 'http://www.trax.com.my';
	var plusURL = 'http://112.137.167.41';
	
	var headerImage = $('main').getFirst();
	var listPosition = headerImage.getCoordinates();
	var posCorrectionTop = $$('.mainSubMenu').getCoordinates();

	$$( '.mainSubMenu' ).each(function(item){
		//item.setStyles({top: listPosition.top-2, width: listPosition.width-30, right: listPosition.right-15, left: listPosition.left+15 });
		item.setStyles({top: 126, width: listPosition.width-30, right: listPosition.right-15, left: listPosition.left+15 });
		var newSize = item.getCoordinates();
	});
		
	var szNormal = 240, szSmall  = 60, szFull   = 780;
 	
	/*
	var kwicks = $$("#kwicks .kwick");
	var fx = new Fx.Elements(kwicks, {wait: false, duration: 200, transition: Fx.Transitions.Back.easeOut});
	kwicks.each(function(kwick, i) {
		var o = {};
		kwicks.each(function(kwick, i) {
			//o[i] = {width: [kwick.getStyle("width").toInt(), szNormal]}
			o[i] = {width: [kwick.getStyle("width").toInt(), szSmall]}
			o[0] = {width: [kwick.getStyle("width").toInt(), szFull]}
			//$('kwick_red').setStyles({'width':'780px'});
		});			 
		kwick.addEvent("mouseenter", function(event) {
			var o = {};
			o[i] = {width: [kwick.getStyle("width").toInt(), szFull]}
			kwicks.each(function(other, j) {
				if(i != j) {
					var w = other.getStyle("width").toInt();
					if(w != szSmall) o[j] = {width: [w, szSmall]};
				}
			});
			fx.start(o);
		});
		
		fx.start(o);
		
	});
	 
	$("kwicks").addEvent("mouseleave", function(event) {
		var o = {};
		kwicks.each(function(kwick, i) {
			o[i] = {width: [kwick.getStyle("width").toInt(), szSmall]}
			o[0] = {width: [kwick.getStyle("width").toInt(), szFull]}
		});
		fx.start(o);
	})

	*/
	
	
	var dlg = new Dialog({});
	
	//PICLINK FOR TOLLFARE LAUNCH
	$('lauchTFC').addEvent('click',function(e){
				var e = new Event(e);
				e.stop();
				$$('.maske').destroy();
				$$('.poplayer').destroy();
				var myIFrame = new IFrame({
					src: plusURL + '/calculator/index.asp',
					scrolling: 'no',
					allowTransparency: 'true',
					frameborder: '0',
					styles: {
						width: 282,
						height: 442,
						border: '0px none #fff'
					},
					events: {
						
						load: function(data){
							//alert('The iframe has finished loading.');
							//el.set('html',this);
						}
					}
				});
				
				dlg.show(myIFrame);
			});
	
	//TOP LINK FOR LAUNCHING
	$('tollFareLaunch').addEvent('click',function(e){
				$$('.maske').destroy();
				$$('.poplayer').destroy();
				var e = new Event(e);
				e.stop();
				var myIFrame = new IFrame({
					src: plusURL + '/calculator/index.asp',
					scrolling: 'no',
					allowTransparency: 'true', 
					frameborder: '0',
					styles: {
						width: 282,
						height: 442,
						border: '0px none #fff'
					},
					events: {
						
						load: function(data){
							//alert('The iframe has finished loading.');
							//el.set('html',this);
						}
					}
				});
				//var el = new Element('div',{'class':'calcLayer', 'html': '<img src="fileadmin/templates/img/calculator.png" onclick="calculatorFadeOut();" />', 'events': {'click': this.hide.bind(this)}, 'styles':{'padding-left':15,'background':'transparent','width':300}})
				
				dlg.show(myIFrame);
		});
	
	
	
	
	
	new SmoothScroll({ duration:700 }, window); //700 milliseconds to get there
	
	
	//SWF VIA MOOTOOLS
        
	var curtains = new Swiff('fileadmin/flash/curtain.swf', {
		id: 'curtains',
		width: 960,
		height: 445,
		params: {
			wmode: 'opaque'
		},
		vars: {
			plusURL: "http://www.plus.com.my/",
			plusURL2: "http://www.plus.com.my/"
		},
		events: {
			//onLoad: myOnloadFunc
		}
	});
	
	headerImage.set('text', '');
	headerImage.adopt(curtains);
        
	
	
	
	//SWF VIA SWFOBJECT
	/*
	var flashvars = {
	  plusURL: "http://www.plus.com.my/"
	};
	var params = {
	  menu: "false",
	  wmode: "opaque"
	};
	
	var attributes = {};
	swfobject.embedSWF("fileadmin/flash/curtain.swf", "animation", "960", "445", "9.0.0","expressInstall.swf", flashvars, params, attributes);
	*/
});

window.addEvent('resize', function() {
									 
	var headerImage = $('main').getFirst();
	var listPosition = headerImage.getCoordinates();
	$$('.mainSubMenu').setStyles({top: listPosition.top-2, width: listPosition.width-30, right: listPosition.right-15, left: listPosition.left+15 });
	
});

function calculatorFadeOut() {	
			//navFade.start(1);
			var calcfade = new Fx.Tween($('poplayer'), {
					property:'opacity', 
					duration:1500, 
					link: 'cancel',
					onComplete: function(){
						//and here we apply the highlight effect on complete
						$('maske').destroy();
						$('poplayer').destroy();
						$('animation').setStyle({'visibility':'visible'});
					}
					});
			calcfade.start(0);
};
//SWFOBJECT  



