var JqueryAbdul = jQuery.noConflict();
/* Smooth Link Top */
(function(jQuery) {
jQuery.fn.lavaLamp = function(o) {
	o = jQuery.extend({ fx: 'swing', 
					  	speed: 500, 
						click: function(){return true}, 
						startItem: 'no',
						autoReturn: true,
						returnDelay: 0,
						setOnClick: true,
						homeTop:0,
						homeLeft:0,
						homeWidth:0,
						homeHeight:0,
						returnHome:false
						}, 
					o || {});

	return this.each(function() {
		var path = location.pathname + location.search + location.hash;
		var JqueryAbdulselected = new Object;
		var delayTimer;
		var JqueryAbdulback;
		var JqueryAbdulhome;
		var ce;
		
		//
		// create homeLava element if origin and dimensions set and startItem == off
		if (o.homeTop || o.homeLeft) { 
			JqueryAbdulhome = jQuery('<li class="homeLava selectedLava"></li>').css({ left:o.homeLeft, top:o.homeTop, width:o.homeWidth, height:o.homeHeight, position:'absolute' });
			jQuery(this).prepend(JqueryAbdulhome);
		}
		
		var JqueryAbdulli = jQuery('li', this);
		// check for complete path match, if so flag element into JqueryAbdulselected
		if ( o.startItem == 'no' )
			JqueryAbdulselected = jQuery('li a[hrefJqueryAbdul="' + path + '"]', this).parent('li');
			
		// double check, this may be just an anchor match
		if (JqueryAbdulselected.length == 0 && o.startItem == 'no' && location.hash)
			JqueryAbdulselected = jQuery('li a[hrefJqueryAbdul="' + location.hash + '"]', this).parent('li');

		// no default selected element matches worked, 
		// or the user specified an index via startItem
		if (JqueryAbdulselected.length == 0 || o.startItem != 'no') {
			// always default to first item, if no startItem specified.
			if (o.startItem == 'no') o.startItem = 0;
			JqueryAbdulselected = jQuery(JqueryAbdulli[o.startItem]);
		}
		// set up raw element - this allows user override by class .selectedLava on load
		ce = jQuery('li.selectedLava', this)[0] || jQuery(JqueryAbdulselected).addClass('selectedLava')[0];

		// add mouseover event for every sub element
		JqueryAbdulli.mouseover(function() {
			if (jQuery(this).hasClass('homeLava')) {
				ce = jQuery(this)[0];
			}
			move(this);
		});

		JqueryAbdulback = jQuery('<li class="backLava"><div class="leftLava"></div><div class="bottomLava"></div><div class="cornerLava"></div></li>').appendTo(this);
		
		// after we leave the container element, move back to default/last clicked element
		jQuery(this).mouseout( function() {
			if (o.autoReturn) {
				
				if (o.returnHome && JqueryAbdulhome) {
					move(JqueryAbdulhome[0]);
				}
				else if (o.returnDelay) {
					if(delayTimer) clearTimeout(delayTimer);
					delayTimer = setTimeout(move,o.returnDelay + o.speed);
				}
				else {
					move();
				}
			}
		});

		JqueryAbdulli.click(function(e) {
			if (o.setOnClick) {
				jQuery(ce).removeClass('selectedLava');
				jQuery(this).addClass('selectedLava');
				ce = this;
			}
			return o.click.apply(this, [e, this]);
		});

		// set the starting position for the lavalamp hover element: .back
		if (o.homeTop || o.homeLeft) 
			JqueryAbdulback.css({ left:o.homeLeft, top:o.homeTop, width:o.homeWidth, height:o.homeHeight });
		else
			JqueryAbdulback.css({ left: ce.offsetLeft, top: ce.offsetTop, width: ce.offsetWidth, height: ce.offsetHeight });


		function move(el) {
			if (!el) el = ce;
			// .backLava element border check and animation fix
			var bx=0, by=0;
			if (!jQuery.browser.msie) {
				bx = (JqueryAbdulback.outerWidth() - JqueryAbdulback.innerWidth())/2;
				by = (JqueryAbdulback.outerHeight() - JqueryAbdulback.innerHeight())/2;
			}
			JqueryAbdulback.stop()
			.animate({
				left: el.offsetLeft-bx,
				top: el.offsetTop-by,
				width: el.offsetWidth,
				height: el.offsetHeight
			}, o.speed, o.fx);
		};
	});
};
})(jQuery);
/* End Smooth Link Top */
//----------------------------------------------------------
//----------------------------------------------------------
//----------------------------------------------------------
/* pop up */
var popupStatus = 0;
//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		JqueryAbdul(".backgroundPopup").css({
			"opacity": "0.6"
		});
		JqueryAbdul(".backgroundPopup").fadeIn("slow");
		JqueryAbdul(".popupContact").fadeIn("slow");
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		JqueryAbdul(".backgroundPopup").fadeOut("slow");
		JqueryAbdul(".popupContact").fadeOut("slow");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = JqueryAbdul(".popupContact").height();
	var popupWidth = JqueryAbdul(".popupContact").width();
	//centering
	JqueryAbdul(".popupContact").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	JqueryAbdul(".backgroundPopup").css({
		"height": windowHeight
	});
	
}


//CONTROLLING EVENTS IN jQuery
JqueryAbdul(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	JqueryAbdul(".bahasa").click(function(){
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});
				
	//CLOSING POPUP
	//Click the x event!
	JqueryAbdul(".popupContactClose").click(function(){
		disablePopup();
	});
	//Click out event!
	JqueryAbdul(".backgroundPopup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	JqueryAbdul(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});
/* End pop up */
//----------------------------------------------------------
//----------------------------------------------------------
//----------------------------------------------------------
/* Contact */
(function(JqueryAbdul){var ie6=JqueryAbdul.browser.msie&&parseInt(JqueryAbdul.browser.version)==6&&typeof window['XMLHttpRequest']!="object",ieQuirks=null,w=[];JqueryAbdul.modal=function(data,options){return JqueryAbdul.modal.impl.init(data,options);};JqueryAbdul.modal.close=function(){JqueryAbdul.modal.impl.close();};JqueryAbdul.fn.modal=function(options){return JqueryAbdul.modal.impl.init(this,options);};JqueryAbdul.modal.defaults={opacity:50,overlayId:'simplemodal-overlay',overlayCss:{},containerId:'simplemodal-container',containerCss:{},dataCss:{},zIndex:1000,close:true,closeHTML:'<a class="modalCloseImg" title="Close"></a>',closeClass:'simplemodal-close',position:null,persist:false,onOpen:null,onShow:null,onClose:null};JqueryAbdul.modal.impl={opts:null,dialog:{},init:function(data,options){if(this.dialog.data){return false;}ieQuirks=JqueryAbdul.browser.msie&&!JqueryAbdul.boxModel;this.opts=JqueryAbdul.extend({},JqueryAbdul.modal.defaults,options);this.zIndex=this.opts.zIndex;this.occb=false;if(typeof data=='object'){data=data instanceof jQuery?data:JqueryAbdul(data);if(data.parent().parent().size()>0){this.dialog.parentNode=data.parent();if(!this.opts.persist){this.dialog.orig=data.clone(true);}}}else if(typeof data=='string'||typeof data=='number'){data=JqueryAbdul('<div/>').html(data);}else{alert('SimpleModal Error: Unsupported data type: '+typeof data);return false;}this.dialog.data=data.addClass('simplemodal-data').css(this.opts.dataCss);data=null;this.create();this.open();if(JqueryAbdul.isFunction(this.opts.onShow)){this.opts.onShow.apply(this,[this.dialog]);}return this;},create:function(){w=this.getDimensions();if(ie6){this.dialog.iframe=JqueryAbdul('<iframe src="javascript:false;"/>').css(JqueryAbdul.extend(this.opts.iframeCss,{display:'none',opacity:0,position:'fixed',height:w[0],width:w[1],zIndex:this.opts.zIndex,top:0,left:0})).appendTo('body');}this.dialog.overlay=JqueryAbdul('<div/>').attr('id',this.opts.overlayId).addClass('simplemodal-overlay').css(JqueryAbdul.extend(this.opts.overlayCss,{display:'none',opacity:this.opts.opacity/100,height:w[0],width:w[1],position:'fixed',left:0,top:0,zIndex:this.opts.zIndex+1})).appendTo('body');this.dialog.container=JqueryAbdul('<div/>').attr('id',this.opts.containerId).addClass('simplemodal-container').css(JqueryAbdul.extend(this.opts.containerCss,{display:'none',position:'fixed',zIndex:this.opts.zIndex+2})).append(this.opts.close?JqueryAbdul(this.opts.closeHTML).addClass(this.opts.closeClass):'').appendTo('body');this.setPosition();if(ie6||ieQuirks){this.fixIE();}this.dialog.container.append(this.dialog.data.hide());},bindEvents:function(){var self=this;JqueryAbdul('.'+this.opts.closeClass).bind('click.simplemodal',function(e){e.preventDefault();self.close();});JqueryAbdul(window).bind('resize.simplemodal',function(){w=self.getDimensions();self.setPosition();if(ie6||ieQuirks){self.fixIE();}else{self.dialog.iframe&&self.dialog.iframe.css({height:w[0],width:w[1]});self.dialog.overlay.css({height:w[0],width:w[1]});}});},unbindEvents:function(){JqueryAbdul('.'+this.opts.closeClass).unbind('click.simplemodal');JqueryAbdul(window).unbind('resize.simplemodal');},fixIE:function(){var p=this.opts.position;JqueryAbdul.each([this.dialog.iframe||null,this.dialog.overlay,this.dialog.container],function(i,el){if(el){var bch='document.body.clientHeight',bcw='document.body.clientWidth',bsh='document.body.scrollHeight',bsl='document.body.scrollLeft',bst='document.body.scrollTop',bsw='document.body.scrollWidth',ch='document.documentElement.clientHeight',cw='document.documentElement.clientWidth',sl='document.documentElement.scrollLeft',st='document.documentElement.scrollTop',s=el[0].style;s.position='absolute';if(i<2){s.removeExpression('height');s.removeExpression('width');s.setExpression('height',''+bsh+' > '+bch+' ? '+bsh+' : '+bch+' + "px"');s.setExpression('width',''+bsw+' > '+bcw+' ? '+bsw+' : '+bcw+' + "px"');}else{var te,le;if(p&&p.constructor==Array){var top=p[0]?typeof p[0]=='number'?p[0].toString():p[0].replace(/px/,''):el.css('top').replace(/px/,'');te=top.indexOf('%')==-1?top+' + (t = '+st+' ? '+st+' : '+bst+') + "px"':parseInt(top.replace(/%/,''))+' * (('+ch+' || '+bch+') / 100) + (t = '+st+' ? '+st+' : '+bst+') + "px"';if(p[1]){var left=typeof p[1]=='number'?p[1].toString():p[1].replace(/px/,'');le=left.indexOf('%')==-1?left+' + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"':parseInt(left.replace(/%/,''))+' * (('+cw+' || '+bcw+') / 100) + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"';}}else{te='('+ch+' || '+bch+') / 2 - (this.offsetHeight / 2) + (t = '+st+' ? '+st+' : '+bst+') + "px"';le='('+cw+' || '+bcw+') / 2 - (this.offsetWidth / 2) + (t = '+sl+' ? '+sl+' : '+bsl+') + "px"';}s.removeExpression('top');s.removeExpression('left');s.setExpression('top',te);s.setExpression('left',le);}}});},getDimensions:function(){var el=JqueryAbdul(window);var h=JqueryAbdul.browser.opera&&JqueryAbdul.browser.version>'9.5'&&JqueryAbdul.fn.jquery<='1.2.6'?document.documentElement['clientHeight']:el.height();return[h,el.width()];},setPosition:function(){var top,left,hCenter=(w[0]/2)-((this.dialog.container.height()||this.dialog.data.height())/2),vCenter=(w[1]/2)-((this.dialog.container.width()||this.dialog.data.width())/2);if(this.opts.position&&this.opts.position.constructor==Array){top=this.opts.position[0]||hCenter;left=this.opts.position[1]||vCenter;}else{top=hCenter;left=vCenter;}this.dialog.container.css({left:left,top:top});},open:function(){this.dialog.iframe&&this.dialog.iframe.show();if(JqueryAbdul.isFunction(this.opts.onOpen)){this.opts.onOpen.apply(this,[this.dialog]);}else{this.dialog.overlay.show();this.dialog.container.show();this.dialog.data.show();}this.bindEvents();},close:function(){if(!this.dialog.data){return false;}if(JqueryAbdul.isFunction(this.opts.onClose)&&!this.occb){this.occb=true;this.opts.onClose.apply(this,[this.dialog]);}else{if(this.dialog.parentNode){if(this.opts.persist){this.dialog.data.hide().appendTo(this.dialog.parentNode);}else{this.dialog.data.remove();this.dialog.orig.appendTo(this.dialog.parentNode);}}else{this.dialog.data.remove();}this.dialog.container.remove();this.dialog.overlay.remove();this.dialog.iframe&&this.dialog.iframe.remove();this.dialog={};}this.unbindEvents();}};})(jQuery);

JqueryAbdul(document).ready(function () {
	JqueryAbdul('.header_link a.contact').click(function (e) {
		e.preventDefault();
		// load the contact form using ajax
		JqueryAbdul.get("includes/contact.php", function(data){
			// create a modal dialog with the data
			JqueryAbdul(data).modal({
				close: false,
				position: ["15%",],
				overlayId: 'contact-overlay',
				containerId: 'contact-container',
				onOpen: contact.open,
				onShow: contact.show,
				onClose: contact.close
			});
		});
	});

	// preload images
	var img = ['cancel.png', 'form_bottom.gif', 'form_top.gif', 'loading.gif', 'send.png'];
	JqueryAbdul(img).each(function () {
		var i = new Image();
		i.src = 'images/contact/' + this;
	});
});

var contact = {
	message: null,
	open: function (dialog) {
		// add padding to the buttons in firefox/mozilla
		if (JqueryAbdul.browser.mozilla) {
			JqueryAbdul('#contact-container .contact-button').css({
				'padding-bottom': '2px'
			});
		}
		// input field font size
		if (JqueryAbdul.browser.safari) {
			JqueryAbdul('#contact-container .contact-input').css({
				'font-size': '.9em'
			});
		}

		// dynamically determine height
		var h = 280;
		if (JqueryAbdul('#contact-subject').length) {
			h += 26;
		}
		if (JqueryAbdul('#contact-cc').length) {
			h += 22;
		}

		var title = JqueryAbdul('#contact-container .contact-title').html();
		JqueryAbdul('#contact-container .contact-title').html('Loading...');
		dialog.overlay.fadeIn(200, function () {
			dialog.container.fadeIn(200, function () {
				dialog.data.fadeIn(200, function () {
					JqueryAbdul('#contact-container .contact-content').animate({
						height: h
					}, function () {
						JqueryAbdul('#contact-container .contact-title').html(title);
						JqueryAbdul('#contact-container form').fadeIn(200, function () {
							JqueryAbdul('#contact-container #contact-name').focus();

							JqueryAbdul('#contact-container .contact-cc').click(function () {
								var cc = JqueryAbdul('#contact-container #contact-cc');
								cc.is(':checked') ? cc.attr('checked', '') : cc.attr('checked', 'checked');
							});

							// fix png's for IE 6
							if (JqueryAbdul.browser.msie && JqueryAbdul.browser.version < 7) {
								JqueryAbdul('#contact-container .contact-button').each(function () {
									if (JqueryAbdul(this).css('backgroundImage').match(/^url[("']+(.*\.png)[)"']+JqueryAbdul/i)) {
										var src = RegExp.JqueryAbdul1;
										JqueryAbdul(this).css({
											backgroundImage: 'none',
											filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' +  src + '", sizingMethod="crop")'
										});
									}
								});
							}
						});
					});
				});
			});
		});
	},
	show: function (dialog) {
		JqueryAbdul('#contact-container .contact-send').click(function (e) {
			e.preventDefault();
			// validate form
			if (contact.validate()) {
				JqueryAbdul('#contact-container .contact-message').fadeOut(function () {
					JqueryAbdul('#contact-container .contact-message').removeClass('contact-error').empty();
				});
				JqueryAbdul('#contact-container .contact-title').html('Sending...');
				JqueryAbdul('#contact-container form').fadeOut(200);
				JqueryAbdul('#contact-container .contact-content').animate({
					height: '80px'
				}, function () {
					JqueryAbdul('#contact-container .contact-loading').fadeIn(200, function () {
						JqueryAbdul.ajax({
							url: 'includes/contact.php',
							data: JqueryAbdul('#contact-container form').serialize() + '&action=send',
							type: 'post',
							cache: false,
							dataType: 'html',
							complete: function (xhr) {
								JqueryAbdul('#contact-container .contact-loading').fadeOut(200, function () {
									JqueryAbdul('#contact-container .contact-title').html('Thank you!');
									JqueryAbdul('#contact-container .contact-message').html(xhr.responseText).fadeIn(200);
								});
							},
							error: contact.error
						});
					});
				});
			}
			else {
				if (JqueryAbdul('#contact-container .contact-message:visible').length > 0) {
					var msg = JqueryAbdul('#contact-container .contact-message div');
					msg.fadeOut(200, function () {
						msg.empty();
						contact.showError();
						msg.fadeIn(200);
					});
				}
				else {
					JqueryAbdul('#contact-container .contact-message').animate({
						height: '30px'
					}, contact.showError);
				}
				
			}
		});
	},
	close: function (dialog) {
		JqueryAbdul('#contact-container .contact-message').fadeOut();
		JqueryAbdul('#contact-container .contact-title').html('Goodbye...');
		JqueryAbdul('#contact-container form').fadeOut(200);
		JqueryAbdul('#contact-container .contact-content').animate({
			height: 40
		}, function () {
			dialog.data.fadeOut(200, function () {
				dialog.container.fadeOut(200, function () {
					dialog.overlay.fadeOut(200, function () {
						JqueryAbdul.modal.close();
					});
				});
			});
		});
	},
	error: function (xhr) {
		alert(xhr.statusText);
	},
	validate: function () {
		contact.message = '';
		if (!JqueryAbdul('#contact-container #contact-name').val()) {
			contact.message += 'Name is required. ';
		}

		var email = JqueryAbdul('#contact-container #contact-email').val();
		if (!email) {
			contact.message += 'Email is required. ';
		}
		else {
			if (!contact.validateEmail(email)) {
				contact.message += 'Email is invalid. ';
			}
		}

		if (!JqueryAbdul('#contact-container #contact-message').val()) {
			contact.message += 'Message is required.';
		}

		if (contact.message.length > 0) {
			return false;
		}
		else {
			return true;
		}
	},
	validateEmail: function (email) {
		var at = email.lastIndexOf("@");

		// Make sure the at (@) sybmol exists and  
		// it is not the first or last character
		if (at < 1 || (at + 1) === email.length)
			return false;

		// Make sure there aren't multiple periods together
		if (/(\.{2,})/.test(email))
			return false;

		// Break up the local and domain portions
		var local = email.substring(0, at);
		var domain = email.substring(at + 1);

		// Check lengths
		if (local.length < 1 || local.length > 64 || domain.length < 4 || domain.length > 255)
			return false;

		// Make sure local and domain don't start with or end with a period
		if (/(^\.|\.JqueryAbdul)/.test(local) || /(^\.|\.JqueryAbdul)/.test(domain))
			return false;

		// Check for quoted-string addresses
		// Since almost anything is allowed in a quoted-string address,
		// we're just going to let them go through
		if (/!^"(.+)"JqueryAbdul/.test(local)) {
			// It's a dot-string address...check for valid characters
			if (/!^[-a-zA-Z0-9!#JqueryAbdul%*\/?|^{}`~&'+=_\.]*JqueryAbdul/.test(local))
				return false;
		}

		// Make sure domain contains only valid characters and at least one period
		if (!/^[-a-zA-Z0-9\.]*JqueryAbdul/.test(domain) || domain.indexOf(".") === -1)
			return false;	

		return true;
	},
	showError: function () {
		JqueryAbdul('#contact-container .contact-message')
			.html(JqueryAbdul('<div class="contact-error">').append(contact.message))
			.fadeIn(200);
	}
};
/* End Contact */
//----------------------------------------------------------
//----------------------------------------------------------
//----------------------------------------------------------

//----------------------------------------------------------
//----------------------------------------------------------
//----------------------------------------------------------
