$(document).ready(function(){

// Preload Image Function --------------------//	
	$.preloadImages = function() {
	  for(var i = 0; i<arguments.length; i++) {
		$("<img>").attr("src", arguments[i]);
	  }
	};
	
// Fading Links --------------------//
/*	$(".thumb a").css("opacity","1");
	$(".thumb a").hover(function (){
		$(this).stop().animate({opacity: 0.25}, 200);
	},
	function (){
		$(this).stop().animate({opacity: 1}, 200);
	});*/

// qTip --------------------//
	$.fn.qtip.styles.nsitip = { // Last part is the name of the style
		background: '#111111',
		textAlign: 'left',
		border: {color: '#111111', width:3, radius:5},
		tip: {corner: 'bottomMiddle', color: '#000000', size: {x:5, y:5}},
		name: 'dark' // Inherit the rest of the attributes from the preset dark style
	}
	
	
	$(".thumb a[title]").qtip({ 
		content: {text:false},
		style: {name:'nsitip', tip:true},
		position: {corner: {target: 'topMiddle', tooltip: 'bottomLeft'}, adjust: { x:0, y:-1 }}
	});
	
	$(".qtright[title]").qtip({ 
		content: {text:false},
		style: {name:'nsitip', tip:true},
		position: {corner: {target: 'topMiddle', tooltip: 'leftMiddle'}, adjust: { x:10, y:10 }}
	});	
	
	$(".qtinputright[title]").qtip({ 
		content: {text:true},
		style: {
				name:'nsitip', tip:true, 
				width: 185, 
				background: '#fbfff5', 
				border: {color: '#89c436', width:1, radius:5}, 
				color: '#000000', 
				'font-size': 10,
				tip: {corner: 'leftMiddle', color: '#89c436', size: {x:19, y:20}}
				},
		show: { delay: 500, effect: 'fade'},			
		position: {corner: {target: 'rightMiddle', tooltip: 'leftMiddle'}, adjust: { x:0, y:0 }}
	});	
		
	
	$(".qttop[title]").qtip({ 
		content: {text:false},
		style: {name:'nsitip', tip:true},
		position: {corner: {target: 'bottomMiddle', tooltip: 'topLeft'}, adjust: { x:-100, y:-5 }}
	});
	
	$(".qtbot[title]").qtip({ 
		content: {text:false},
		style: {name:'nsitip', tip:true},
		position: {corner: {target: 'bottomMiddle', tooltip: 'topLeft'}, adjust: { x:10, y:6 }}
	});		
	
// Colorbox --------------------//
/*	$(".thumb a").colorbox(); */
	$(".pop-up").colorbox({width:"700", height:"420", scrolling: false});
	$(".pop-up-small").colorbox({width:"500", height:"300", scrolling: false});
	$(".pop-up-small-frame").colorbox({width:"500", height:"320", scrolling: false, iframe: true});	
	$(".pop-up-small-frame-refresh").colorbox({width:"500", height:"320", scrolling: false, iframe: true, 
		onClosed:function(){location.reload(true);} 
	});	
	
		
	$(".pop-up-topup").colorbox({width:"600", height:"350", scrolling: false, iframe: true});
	$(".pop-up-contacts").colorbox({width:"600", height:"570", scrolling: false, iframe: true});	

	$(".pop-up-miestai").colorbox({width:"900", height:"440", scrolling: false, transition:"none"});
	
	$("a[rel='photos']").colorbox({transition:"none", slideshow:false});		

	$(".pop-up-changepass").colorbox({width:"500", height:"420", scrolling: false, iframe:true, overlayClose:false, escKey:false, open:true, 
		onLoad: function() {$('#cboxClose').remove();},
		onClosed:function(){window.location = "/account";}
	});	
});


// hover script  //

	function tover(q) {q.children.tags('a')[0].style.color = "black";}
	function trtover(q) {q.style.backgroundColor='#fee3b1'; q.style.cursor='hand'}
 
	function tout(q) {q.children.tags('a')[0].style.color = "black";}
	function trtout(q) {q.style.backgroundColor = 'white';}

	function vipover(q) {q.style.backgroundColor='#e4c0f7'; q.style.cursor='hand'}
	function vipout(q) {q.style.backgroundColor ='#f1d7ff';}

	function vipover2(q) {q.style.backgroundColor='yellow'; q.style.cursor='hand'}
	function vipout2(q) {q.style.backgroundColor ='pink';}
 
	function LmUp(path) {location.href = path;}
	
	
// Chars limit counter

function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}
