function set_up(){
	Shadowbox.init({
		players:['iframe']
	});
}

function pagePreview(Page,Title){
    Shadowbox.open({
		content:    'http://www.dcv.bg/bg/catalog/p:'+Page, 
		player:     'iframe', 
		title:      Title
    });
}




/*$(window).keypress(function(event) {
	
    if (!((event.which == 115|| event.which == 83) && event.ctrlKey) && !(event.which == 19)){ 
    	alert("Ctrl-S pressed");
		return true;
	}
   event.preventDefault();
    return false;
});*/

$(function(){
	footerPartnersImg();
	historyButtons();
	cutCherti();
})

function footerPartnersImg(){
	$('.footer .list img').hover(function(){
		var curentUrl = $(this).attr('src');
		var split = curentUrl.split('.png');
		var newUrl = split[0]+'_o.png';
		$(this).attr('src', newUrl);
	}, function(){
		var curentUrl = $(this).attr('src');
		var split = curentUrl.split('_o.png');
		var newUrl = split[0]+'.png';
		$(this).attr('src', newUrl);
	});	
}

function historyButtons(){
	if($('.historyButtons a').length===0){return false;}
	var opacity = 0.7;
	
	$('.historyButtons a').css({"opacity":opacity});
	
	$('.historyButtons a').hover(function(){
		$(this).animate({"opacity":1}, 100);
	},function(){
		$(this).animate({"opacity":opacity}, 100);
	});
	/*
	$('.historyButtons a.prev').click(function(e){		
		e.preventDefault();
		history.go(-1);
	});
	*/
	$('.historyButtons a.next').click(function(e){
		e.preventDefault();
		history.go(1);
	});	
}

function cutCherti(){
	//Вземаме шиорчината на целия прозорец
	var width = $(window).width();	
	var chertaWidth = width - ((width-700)/2);
	$('.cherta.small').css({"width":chertaWidth+"px", "float":"left"});
}

function sendContact(){
	//Събираме данните от формата
	var form = $('form.contactForm');
	var postdata = form.serialize();
	
	var url = $.domain+$.language+'/sendContact';
	$.post(url, postdata, function(data){	
		obj = string2json(data);
		if(obj.status == false){			
			viewMess(obj.mess);
			return false;			
		}else if(obj.status==true){
			viewMess(obj.mess);		
			clearForm(form);
		}else{
			viewMess('Грешка! Опитайте по късно или се свържете с администратор на сайта');
			return false;
		}
	});	
}
