﻿$(document).ready(
	function() {
		// narazie nic nie ma .. można zainicjowac fotki "zaufauli nam"
		slideSwitch('partner-slideshow', 2000);
		slideSwitch('lastreal-slideshow', 5000);
	}
);

function onGalleryTypeChange( obj_select_id ) {
	var arrGalsWithVisibilityChoose = ['real', 'realisation', 'realisations'];
	
	// jeśli galeria nie wymaga definiowania widoczności ..
	var bool_check = parseInt($.inArray($('#'+ obj_select_id).attr('value'), arrGalsWithVisibilityChoose));
	
	if ( !isNaN(bool_check) && bool_check == -1 ) {
		// .. wyłącz tę opcję
		$('#visible-element').hide();
		$('#visible-label').hide();
	}
	else { // .. w przeciwnym wypadku ..
		//  .. włącz opcję
		$('#visible-element').show();
		$('#visible').attr('checked', 'checked');
		$('#visible-label').show();
	}
	
}

function slideSwitch( slide_div_id, interval ) {
	var obj_slide_div = $('#'+ slide_div_id);
	if ( obj_slide_div.length > 0 ) {
		obj_slide_div.cycle({
			delay	: interval,
			height	: 'auto',
			speed	: 2500,
			fx		: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		});
	}
}

function menuHover( menu_item ) {
	switch ( menu_item ) {
		case 1:
			$('#ws_desc_title').html('Poligrafia');
			$('#ws_desc_desc').html('Wizytówki, ulotki, plakaty reklamowe, teczki, papiery firmowe, biznes karty');
		break;

		case 2:
			$('#ws_desc_title').html('Reklama zewnętrzna');
			$('#ws_desc_desc').html('Tablice reklamowe, bilboardy, kasetony świetlne, pylony, semafory, formy ze styrodutu');
		break;

		case 3:
			$('#ws_desc_title').html('Kalendarze');
			$('#ws_desc_desc').html('Jedno i trójdzielne, książkowe, ścienne, listwowe, kieszonkowe');
		break;

		case 4:
			$('#ws_desc_title').html('Oklejanie samochodów, Oklejanie pojazdów');
			$('#ws_desc_desc').html('Wyklejanie pojazdów, mobile reklamowe');
		break;

		case 5:
			$('#ws_desc_title').html('Opakowania');
			$('#ws_desc_desc').html('Torby papierowe, torby foliowe, torby ekologiczne, opakowania z tektury');
		break;

		case 6:
			$('#ws_desc_title').html('Odzież reklamowa');
			$('#ws_desc_desc').html('Koszulki reklamowe, bluzy, czapeczki, daszki, uniformy pracownicze');
		break;

		case 7:
			$('#ws_desc_title').html('Gadżety reklamowe');
			$('#ws_desc_desc').html('Artykuły piśmiennicze i biurowe, upominki, smycze reklamowe, galanteria');
		break;

		case 8:
			$('#ws_desc_title').html('Reklama na nośnikach');
			$('#ws_desc_desc').html('Wizytówki CD, płyty CD/DVD reklamowe, nadruki na płytach, Pendrive\'y');
		break;

		case 9:
			$('#ws_desc_title').html('Słodycze reklamowe');
			$('#ws_desc_desc').html('Cukierki, lizaki, czekoladki, żelki');
		break;

		case 10:
			$('#ws_desc_title').html('Systemy wystawiennicze');
			$('#ws_desc_desc').html('Roll up, mini rollup, l-baner, x-baner, potykacze, stoiska na ulotki i degustacyjne');
		break;

		case 11:
			$('#ws_desc_title').html('Banery, Billboardy, Siatka');
			$('#ws_desc_desc').html('Banery, siatki, folie samoprzylepne, papiery, płótno, fototapety, flagi');
		break;

		case 12:
			$('#ws_desc_title').html('Strony www, Sklepy internetowe, CMS');
			$('#ws_desc_desc').html('Strony WWW, sklepy internetowe');
		break;

		case 13:
			$('#ws_desc_title').html('Projektowania graficzne');
			$('#ws_desc_desc').html('Projekty znaków firmowych, logo, identyfikacja wizualna');
		break;

		case 14:
			$('#ws_desc_title').html('Wynajem powierzchni reklamowych');
			$('#ws_desc_desc').html('CityLight\'y w wiatach przystankowych');
		break;

		case 15:
			$('#ws_desc_title').html('Fotografia reklamowa');
			$('#ws_desc_desc').html('Profesjonalna fotografia wszelkiego rodzaju produktów. Sesje plenerowe i studyjne');
		break;

		case 16:
			$('#ws_desc_title').html('Kampanie');
			$('#ws_desc_desc').html('Kampanie reklamowe i akcje promocyjne, kampanie wyborcze');
		break;

		case 17:
			$('#ws_desc_title').html('Organizacja stoisk targowych');
			$('#ws_desc_desc').html('Projektowanie, organizowanie i realizacja zabudowy stoisk targowych');
		break;

		case 18:
			$('#ws_desc_title').html('Wybory samorządowe 2010');
			$('#ws_desc_desc').html('Specjalna oferta dla kandydatów');
		break;

		default:
			$('#ws_desc_title').html('');
			$('#ws_desc_desc').html('');
		break;
	}
}

function validate_required(value,alerttxt)
{
  if (value==null||value=="")
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
}

function sendContactForm() {
	
	var fname = $('#f_fname').attr('value');
	var lname = $('#f_lname').attr('value');
	var subject = $('#f_subject').attr('value');
	var content = $('#f_content').attr('value');
	
	if (validate_required(fname,"Uzupełnij Imię!") && validate_required(lname,"Uzupełnij Nazwisko!") && validate_required(subject,"Uzupełnij E-mail!") && validate_required(content,"Uzupełnij Treść!"))
	{
		$('#f_fname').attr('disabled', 'disabled');
		$('#f_lname').attr('disabled', 'disabled');
		$('#f_subject').attr('disabled', 'disabled');
		$('#f_content').attr('disabled', 'disabled');
		$('#sendingProgress').toggle();
		
		var postBody = {
				f_fname: $('#f_fname').attr('value'),
				f_lname: $('#f_lname').attr('value'),
				f_subject: $('#f_subject').attr('value'),
				f_content: $('#f_content').attr('value')
			};
		
		var controller = 'index';
		var action = 'contact';
		$.ajax({
			type	: 'POST',
			url		: strBaseUrl + controller +'/'+ action,
			data	: postBody,
			error	: function(response) {
				$('#f_fname').removeAttr('disabled');
				$('#f_lname').removeAttr('disable');
				$('#f_subject').removeAttr('disabled');
				$('#f_content').removeAttr('disabled');
				$('#sendingProgress').toggle();
				alert('Niestety nie udało się wysłać formularza. Spróbuj ponownie później.');
			},
			success	: function(response){
				$('#f_fname').removeAttr('disabled').attr('value', '');
				$('#f_lname').removeAttr('disabled').attr('value', '');
				$('#f_subject').removeAttr('disabled').attr('value', '');
				$('#f_content').removeAttr('disabled').attr('value', '');
				$('#sendingProgress').toggle();
			}
		});
	}
}

function newsletterSubscribe() {
	$('#f_fname').attr('disabled', 'disabled');
	$('#f_lname').attr('disabled', 'disabled');
	$('#f_email').attr('disabled', 'disabled');
	$('#sendingProgress').toggle();
	
	var controller = 'index';
	var action = 'subscribe';
	var action = 'contact';
	var postBody = {
		f_fname: $('#f_fname').attr('value'),
		f_lname: $('#f_lname').attr('value'),
		f_email: $('#f_email').attr('value')
	};
	
	$.ajax({
		type	: 'POST',
		url		: strBaseUrl + controller +'/'+ action,
		data	: postBody,
		error	: function(response) {
			$('#f_fname').removeAttr('disabled');
			$('#f_lname').removeAttr('disabled');
			$('#f_email').removeAttr('disabled');
			$('#sendingProgress').toggle();
			alert('Niestety nie udało się zapisać subskrypcji. Spróbuj ponownie później.');
		},
		success	: function(response){
			$('#f_fname').removeAttr('disabled').attr('value', '');
			$('#f_lname').removeAttr('disabled').attr('value', '');
			$('#f_email').removeAttr('disabled').attr('value', '');
			$('#sendingProgress').toggle();
		}
	});
}

function showGallery( gal_id ) {
	window.location.href = strBaseUrl +'gallery/show/type/'+ gal_id;
}

function showArticle( article_code ) {
	window.location.href = strBaseUrl +'index/article/name/'+ article_code;
}


