//var $j = jQuery.noConflict(); 
$(document).ready(function($){
	function linkHandler() {
		var objLinksArr = $('a:not([href^=#])');
		var currentDomain=top.location.hostname;
		var seqURL='';
		for (eachLink in objLinksArr){
			if(objLinksArr[eachLink].href){
				if(objLinksArr[eachLink].href.indexOf('javascript') == -1){
					seqURL = objLinksArr[eachLink].href;
					seqURL = seqURL.replace(/http:\/\//gi,'');
					seqURL = seqURL.replace(/https:\/\//gi,'');
					seqURL = seqURL.split('/');
					if(seqURL[0] != currentDomain){
						$(objLinksArr[eachLink]).click(function() {
							window.open(this.href);
							return false;
						});
					}
				}
			}
		}
	}
	//$(".tabs-box").tabs();
	$('.tabs-box').find('li:first').addClass('act');
	$('.tabs-box').find('#fragment-1').attr('style','');
	$.fn.tabs1 = function(options) {
		var item = '';
		$this = $(this);
		$this.find('li').click(function() {
			$(this).parent().find('li').removeClass('act');
			item = $(this).find('a').attr('href').split('#')[1];
			if(options && options.effect) {
				$(this).parent().parent().find('div.rec-item').fadeOut();
				$('#'+item).fadeIn('slow');
			} else {
				$(this).parent().parent().find('div.rec-item').css('display','none');
				$('#'+item).attr('style','');
			}
			$(this).addClass('act');
		});
		return false;
	};

	$('.tabs-box').tabs1();
	
	$.fn.contactForm = function() {
		var element = '';
		$this = $(this);
		$this.find('input,textarea').blur(function() {
			if($(this).attr('value') == '') $(this).attr({'value':$(this).attr('title')});
		}).focus(function() {
			if($(this).attr('value') == $(this).attr('title')) $(this).attr({'value':''});
		});
		return false;
	};
	$('.contact-form').contactForm();
/*
	function actFirst (items) {
		$(items[0]).addClass( 'act' );
	}	
	//  carousel-box  -> fce-carousel		switcher -> fce-browser		 white-> act
	var transitionDelay = 900;
	var imgCounter = 0;
	function tabSlide(items) {
		interval = 7000;
		setTimeout(function () {
			if($(items[imgCounter]).hasClass( 'act' ) && !$('.fce-carousel .fce-browser').hasClass('locked')) { 
							$(items).removeClass( 'act' );
							$('#'+$(items[imgCounter]).attr('href').split('#')[1]).fadeOut(transitionDelay);
							if(items[imgCounter+1]) {
								$(items[imgCounter+1]).addClass( 'act' );
								$('#'+$(items[imgCounter+1]).attr('href').split('#')[1]).fadeIn(transitionDelay);
								imgCounter ++;
							} else {
								imgCounter = 0;
								$(items[imgCounter]).addClass( 'act' );
								$('#'+$(items[imgCounter]).attr('href').split('#')[1]).fadeIn(transitionDelay);
							}
			} else if($('.fce-carousel .fce-browser').hasClass('locked')) {
				// 
			} else if(imgCounter < items.length) {
				imgCounter ++; 
			} else {
				imgCounter = 0; 
			}
			tabSlide(items);
		}, interval);
	}
	
	$('.fce-carousel .fce-browser').idTabs(function(id,list,set){
		if($(id).css('display') == 'none') {
			for(i in list) {
				//if(list[i]==id){ imgCounter = i;}
				if($(list[i]).css('display') != 'none'){
					$(list[i]).fadeOut(transitionDelay);
				} else {
					$(list[i]).hide(); 
				}
			}	
			$(id).fadeIn(transitionDelay);
			$('a',set).removeClass('act');
			$('a',set).filter("[href='"+id+"']",set).addClass('act');
			$('a',set).filter("[href='home.html"+id+"']",set).addClass('act');
		}
		if($('.fce-carousel .fce-browser').hasClass('locked')) $('.fce-carousel .fce-browser').removeClass('locked');
		return false;
	});
	
	$('.fce-carousel .next').click(function () {
//alert(imgCounter);
		ind = 0;
		blocks = $('.fce-carousel .fce-browser a');
		while(!ind) {
			if($(blocks[imgCounter]).hasClass( 'act' )) {
							$(blocks).removeClass( 'act' );
							$('#'+$(blocks[imgCounter]).attr('href').split('#')[1]).fadeOut(transitionDelay);
							if(blocks[imgCounter+1]) {
								$(blocks[imgCounter+1]).addClass( 'act' );
								$('#'+$(blocks[imgCounter+1]).attr('href').split('#')[1]).fadeIn(transitionDelay);
								imgCounter ++;
							} else {
								imgCounter = 0;
								$(blocks[imgCounter]).addClass( 'act' );
								$('#'+$(blocks[imgCounter]).attr('href').split('#')[1]).fadeIn(transitionDelay);
							}
							ind = 1;
			} else if(imgCounter < blocks.length) {
				imgCounter ++;
			} else {
				imgCounter = 0;
			}
		}
		if(!$('.fce-carousel .fce-browser').hasClass('locked')) $('.fce-carousel .fce-browser').addClass( 'locked' );
	});	
	
	$('.fce-carousel .prev').click(function () {
		ind = 0;
		blocks = $('.fce-carousel .fce-browser a'); 
		while(!ind) {
			if($(blocks[imgCounter]).hasClass( 'act' )) {
							$(blocks).removeClass( 'act' );
							$('#'+$(blocks[imgCounter]).attr('href').split('#')[1]).fadeOut(transitionDelay);
							if(blocks[imgCounter-1]) {
								$(blocks[imgCounter-1]).addClass( 'act' );
								$('#'+$(blocks[imgCounter-1]).attr('href').split('#')[1]).fadeIn(transitionDelay);
								imgCounter --;
							} else {
								imgCounter = blocks.length-1;
								$(blocks[imgCounter]).addClass( 'act' );
								$('#'+$(blocks[imgCounter]).attr('href').split('#')[1]).fadeIn(transitionDelay);
							}
							ind = 1;
			} else if(imgCounter > 0) {
				imgCounter --;
			} else {
				imgCounter = blocks.length-1;
			}
		}
		if(!$('.fce-carousel .fce-browser').hasClass('locked')) $('.fce-carousel .fce-browser').addClass( 'locked' );
	});			
		
	
	$('.fce-carousel .fce-browser').hover(function() {
				$('.fce-carousel.fce-browser').toggleClass('locked');
	},function() {
				$('.fce-carousel .fce-browser').toggleClass('locked');
	});

        // $('.carousel-box .fce-browser a:first').addClass( 'act' );
	if ($('.fce-carousel .fce-browser').length){ 
		actFirst($('.fce-carousel .fce-browser a'));
		tabSlide($('.fce-carousel .fce-browser a'));
	}
*/	
	linkHandler();
});
	function getForm(form) {
		//$('.contact-form').find('form').submit();
		$(form).find('input,textarea').each(function() {
			if($(this).attr('value') == $(this).attr('title')) $(this).attr({'value':''});
		});
		$(form).submit();
		return false;
	}
