function formFieldFocus(i,n) {
	f = fields_ids[i];
	t = fields_txt[i];
	o = document.getElementById(n)[f];
	if(o.value === t) o.value = '';
	return true;
}

function formFieldBlur(i,n) {
	f = fields_ids[i];
	t = fields_txt[i];
	o = document.getElementById(n)[f];
	if(obj.value === '') obj.value = t;
	return true;
}

function submitForm(n) {
	for(i = 0; i < fields_ids.length; ++i) {
		o = document.getElementById(fields_ids[i]);
		if(o.value === fields_txt[i]) o.value = '';
	}
	document.getElementById(n)[submit()];
	return false;
}

function openInNewWindow() {
	var newWindow = window.open(this.getAttribute('href'), '_blank');
	if(newWindow) newWindow.focus();
	return false;
}

function getNewWindowLinks() {
	if (document.getElementById && document.createElement && document.appendChild) {
		var objWarningText, strWarningText, link, links = document.getElementsByTagName('a'), i;
		for (i = 0; i < links.length; i++) {
			link = links[i];
			if (link.getAttribute && link.getAttribute) {
				if (link.getAttribute('href') && link.getAttribute('rel') == 'external') link.onclick = openInNewWindow;
			}
		}
		objWarningText = null;
	}
}


$(function() {
	getNewWindowLinks();

	// Colorbox
	// The below validates in HTML5, using data-group instead of rel
	$('.colorbox-fade').each(function(){
		$(this).colorbox({
			rel:$(this).attr('data-group'),
			transition: 'fade',
			scalePhotos: true,
			maxHeight: "95%",
		});
	});
	$('.colorbox-youtube').colorbox({iframe:true, innerWidth:640, innerHeight:390});

	$('.noAutoComplete').attr('autocomplete', 'off');
	$('#checkout_has_javascript').show();

	$("#mainContent .offer-sell .item:nth-child(3n+1)").addClass("firstItem");
	$("#fullContent .offer-sell .item:nth-child(4n+1)").addClass("firstItem");

	$("#easyslider").easySlider({
		auto: false,
		continuous: false,
		pause: 7500,
		numeric: true
	});
	$("#easyslider ul li").css('display', 'block');

    $(window).load(function () {
        $('#slider').nivoSlider({
			effect: 'fade',
			animSpeed: 1000,
			pauseTime: 5000
		});
    });

	$('#getSocial').tabSlideOut({
        tabHandle: '.trigger',                    //class of the element that will become your tab
        imageHeight: '190px',                     //height of tab image           //Optionally can be set using css
        imageWidth: '61px',                       //width of tab image            //Optionally can be set using css
        tabLocation: 'right',                     //side of screen where tab lives, top, right, bottom, or left
        speed: 300,                               //speed of animation
        action: 'click',                          //options: 'click' or 'hover', action to trigger animation
        topPos: '152px',                          //position from the top/ use if tabLocation is left or right
        fixedPosition: true                      //options: true makes it stick(fixed position) on scroll
    });

    $('ol#controls li a').click( function() {
	    $('div.intro').removeClass('show');
	});

    $('span.morePortfolio').click( function() {
	    $('div.intro').toggleClass('show');
	});

});
