// JavaScript Document
function antispam(name,domain) {
document.location = "mailto:" + name + "@" + domain;
}


function scrollImage(event_id)
	{
		var scroll = new Fx.Scroll('scrollpane_wrapper', {wait: false, duration: 590, transition: Fx.Transitions.Quad.easeInOut});
		scroll.toElement(event_id);
	}

function selectEvent(id)
	{
		scrollImage('site_'+id+'_img');
	}
function autoScrollEvents()
	{
		var selected = $$('a.selected_image')[0];
		id = parseInt(selected.id.split("_")[1]) + 1;
		if(id != 5)
		{
			$('site_'+(id-1)+'_img').removeClass('selected_image');
			$('select_'+(id-1)).setStyle('background-position','top left');
			selectEvent(id);
			$('site_'+id+'_img').addClass('selected_image');
			$('select_'+id).setStyle('background-position','left -33px');
		}
		else
		{
			selectEvent(1);
			$('site_1_img').addClass('selected_image');
			$('select_1').setStyle('background-position','left -33px');
			$('select_'+(id-1)).setStyle('background-position','top left');
		}
		timer = setTimeout('autoScrollEvents()', 3500);
	}


//Attach Events
window.addEvent('domready', function() {
						 
	
	if($$('div#latest_images_scrollpane')[0])
	{
		var storySelectors = $$('a.latest_select');
		storySelectors.each(function(element) {
				
				element.addEvent('mouseover', function(){
				});
				element.addEvent('mouseout', function() {
				});
		});
		
		timer = setTimeout('autoScrollEvents()', 3500);
		scrollImage('site_4_img');
	}
	
	if($$('div.portofolio_buttons'))
	{
		var buttons = $$('div.portofolio_buttons span');
		buttons.each(function(element) {			 
			element.addEvent('mouseover', function(){
				element.setStyle('background-position','left -33px');
			});
			element.addEvent('mouseout', function() {
				element.setStyle('background-position','top left');
			});
			element.addEvent('click', function(){
				var id = element.id.split("_")[0];
				var num = element.id.split("_")[1];
				var scroll = new Fx.Scroll(id, {wait: false, duration: 540, transition: Fx.Transitions.Quad.easeInOut});
				scroll.toElement(id+"_"+num);
			});
		});
	}
	//Tool Tips
	//store titles and text
	$$('.tipz').each(function(element,index) {
		var content = element.get('title').split('::');
		element.store('tip:title', content[0]);
		element.store('tip:text', content[1]);
	});
	
	//create the tooltips
	var tipz = new Tips('.tipz',{
		className: 'tipz',
		fixed: false,
		hideDelay: 50,
		showDelay: 50
	});
	tipz.addEvents({
	'show': function(tip) {
		tip.fade('in');
	},
	'hide': function(tip) {
		tip.fade('out');
	}
	});

	
	$$('.tipzz').each(function(element,index) {
		var content = element.get('title').split('::');
		element.store('tip2:title', content[0]);
		element.store('tip2:text', content[1]);
	});
	
	//create the tooltips
	var tipzz = new Tips2('.tipzz',{
		className: 'tipzz',
		fixed: false,
		hideDelay: 50,
		showDelay: 50
	});
	tipzz.addEvents({
	'show': function(tip2) {
		tip2.fade('in');
	},
	'hide': function(tip2) {
		tip2.fade('out');
	}
	});
	
	$$('.tipzzz').each(function(element,index) {
		var content = element.get('title').split('::');
		element.store('tip3:title', content[0]);
		element.store('tip3:text', content[1]);
	});
	
	//create the tooltips
	var tipzzz = new Tips3('.tipzzz',{
		className: 'tipzzz',
		fixed: false,
		hideDelay: 50,
		showDelay: 50
	});
	tipzzz.addEvents({
	'show': function(tip3) {
		tip3.fade('in');
	},
	'hide': function(tip3) {
		tip3.fade('out');
	}
	});



	
	if($$('div#serv_right_buttons')[0])
	{
		var services = $$('div#serv_right_buttons span');
		services.each(function(element) {			 
			element.addEvent('mouseover', function(){
				element.setStyle('background-position','left -32px');
			});
			element.addEvent('mouseout', function() {
				element.setStyle('background-position','top left');
			});
			element.addEvent('click', function(){
				var id = element.id.split("_")[0];
				var scroll = new Fx.Scroll('serv_explain', {wait: false, duration: 540, transition: Fx.Transitions.Quad.easeInOut});
				scroll.toElement(id);
			});
		});
	}
	
}); 
window.addEvent('resize', function() {
	if($$('div.overlay'))
		{
			var overlay = $$('div.overlay');
			overlay.each(function(element) {
				repositionOverlay(element);
			});
		}
});