﻿// JavaScript Document

var ie6 = (navigator.userAgent.indexOf("MSIE 6")>0) ? true : false;
$(document).ready(function(){
	
	// Detect *ucing IE6 and throw it to hell
	if(ie6){
			$("<div>").css({
				'position' : 'absolute',
				'top' : '0',
				'left' : '0',
				backgroundColor : '#000',
				'opacity' : '0.75',
				'width' : '100%',
				'height' : $(window).height(),
				zIndex : 5000
				}).appendTo("body");
			$("<div style='padding:4px;'><img src='./img/icons/ie-at-trash.jpg' alt='' style='float:right; margin-left:12px;'/><h4 style='margin-top:18px;'> < Internet Explorer 6</h4><p style='direction:rtl; text-align:right;'><br />دوست عزیز مرورگر شما حداقل برای ده سال پیش است! حتی خود سازنده‌ی آن صدایش درآمده٬ که هیچ ما بعنوان صنف طراحان وب موهایمان سفید شد و ریخت! شما جهت دچار نشدن به همچین دردی٬ برای لذت بردن از امکانات جدید وب٬ برای امنیت بیشتر٬ برای سلامتی روانی آنرا ارتقا دهید.<br /> پیشنهاد بی شرمانه تر! استفاده از بهترین مرورگر حال حاضر یعنی <a href='http://getfirefox.org'>فایرفاکس</a> است. <br /><strong>خودتان را رستگار کنید.</strong></p><br />").css({
				'position' : 'absolute',
				'top' : '50%',
				'left' : '50%',
				backgroundColor : '#f0f0f0',
				'width' : '410px',
				'height' : '200px',
				marginLeft: -210,
				marginTop: -100,
				paddingRight: 10,
				zIndex : 6000				
				}).appendTo("body");
		} // end if

	// Page fade-in except *ucked IE
	//if(!$.browser.msie) {
		//$('body').hide().fadeIn(1000);
	//}

	// Prelodify images
	$(".project-list").preloadify({ imagedelay:500 });
	
	// Fire feature-news
	$("#featured-news").loopedSlider({
		//autoStart: 3000,
		slidespeed: 300,
		containerClick: false,
		//restart: 2500,
		fadespeed: 200,
		hoverPause: true
	});
	
	// Initiate and fire the Colorbox
	$(".example5").colorbox({
		speed: 500,
		initialWidth: '200px',
		initialHeight: '200px',
		innerWidth: '700px',				
		opacity: 0.8,
		transition: function(){if($.browser.msie) { return 'none'; } else { return 'fade'; }}
	});
	
	// Manipulate the Colorbox
	$(document).bind('cbox_complete', function(){
		$("#close-button").click($.fn.colorbox.close);
		//$('#previous-button').click($.fn.colorbox.prev);
		//$('#next-button').click($.fn.colorbox.next);
		$('#popup-slider').nivoSlider({
			directionNav: false,
			effect: 'fade',
			//manualAdvance: true,
			slices: 1
		});		
		var bullet_counts = $('.nivo-controlNav a').size();
		var via_left = Math.round(( 562 - ( bullet_counts * 11 + (bullet_counts-1) * 4 + 4 ) ) / 2) + 'px';
		$('.nivo-controlNav').css('left', via_left);
		
		$('a.full-screen').hover(
			function() {
				var $this = $(this);
				if($.browser.msie) {
					$this.find('span').show();
				}
				else {
					$this.find('span').stop(false, true).animate({
						opacity: 'toggle',
						top: '-24px'
					}, 300);
				}
				return false;
			},
			function() {
				var $this = $(this);
				if($.browser.msie) {
					$this.find('span').hide();
				}
				else {
					$this.find('span').stop(false, true).animate({
						opacity: 'toggle',
						top: '-21px'
					}, 200);
				}
				return false;
			}
		);		
	});
	
	// Roll-over navigation
	$('li#cell, li#resume, a.full-screen').hover(
		function() {
			var $this = $(this);
			if($.browser.msie) {
				$this.find('span').show();
			}
			else {
				$this.find('span').stop(false, true).animate({
					opacity: 'toggle',
					top: '-24px'
				}, 300);
			}
			return false;
		},
		function() {
			var $this = $(this);
			if($.browser.msie) {
				$this.find('span').hide();
			}
			else {
				$this.find('span').stop(false, true).animate({
					opacity: 'toggle',
					top: '-21px'
				}, 200);
			}
			return false;
		}
	);
	
	// Initiate and fire the Fancybox	
	$("#order").fancybox({
		'width'				: 480,
		'height'			: 505,
		'autoScale'			: false,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'type'				: 'iframe'
	});	
	
	//if($.browser.msie) {
		//var textshadow = $("h2.textshadow");
		//textshadow.append("<em></em>");
		//textshadow.each (function(){
		//	var dupetext = $(this).text();
		//	$(this).find("em").text(dupetext);
		//	}
		//);
	//}	
	
});
