function verifyMe()
{
	var msg='';
	if(document.getElementById('datepicker').value==''){
		msg+='- Data calatoriei \n';}	
	if(document.getElementById('dn_dna').value==''){
		msg+='- Nume si prenume \n';}			
	var email=document.getElementById('email').value;
	if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))){
		msg+='- Adresa de email este invalida: '+email+'\n';}
	if(document.getElementById('email').value==''){
		msg+='- Adresa email\n';}		
	if(msg!='')
	{
		alert('Urmatoarele campuri sunt incomplete:\n'+msg);
		return false;
	} 
	else
	{
		document.rezform.submit();
	}
} 

function insert_field(num)
{
	var ins_obj = document.getElementById("insert_field_place");
	ins_obj.innerHTML = "";
	for(var x = 0; x<num; x++)
	{
		ins_obj.innerHTML = ins_obj.innerHTML+'<div class="form-text" style="width:198px; margin-top:3px;"><label for="age'+x+'">Copil '+(x+1)+'</label><input type="text" id="age'+x+'" name="age'+x+'" style="width:50px; border-left:3px solid #F34D49; font-size:11px; margin-left:3px; margin-top:2px;"  /><label> &nbsp;ani</label><div style="clear:both;"></div></div>';
	}
}

function varsta_copil(c,f)
{
	var out_ = '';
	//varsta copil
	var pre__ = '<div style="padding:5px; margin-left:5px; width: 100%; display:block; border:1px dotted #CCCCCC; float:left;">';
	var label_V = '<label style="width:80px; padding:0 8px 0 0;" for="varsta">Varsta copil X</label>';
	var varsta = '<select style="width: 60px;" id="varsta_copil_X_camera_'+f+'" name="copil_X_camera_'+f+'"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option></select>';
	var post = '</div>';
	if(c==0)
	{
		
	}
	else
	{
		for(n=1; n<=c; n++)
		{
			varsta_n = varsta.replace(/X/g, n);
			label_V_n = label_V.replace(/X/g, n);
			out_ += pre__;
			out_ += label_V_n+varsta_n;
			out_ += post;
		}
	}
	return out_;
}

function display_camere(c, d)
{
	var out = '';

	//camere
	var pre_ = '<div style="padding:10px; width: 65%; display:block; border:1px dotted #CCCCCC; float:right; margin-top:5px;">';
	var label = '<label for="camera_X" style="height:55px;">Camera X</label>';

	//detalii camere
	var label_A = '<label style="width:50px;" for="adulti">Adulti</label>';
	var label_C = '<label style="width:50px;" for="copii">Copii</label>';
	var adulti = '<select style="width: 60px;" id="adulti_camera_X" name="adulti_camera_X"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option></select>';
	var copii = '<select style="width: 60px;" id="copii_camera_X" name="copii_camera_X" onchange="document.getElementById(\'afisare_varsta_copii_X\').innerHTML = varsta_copil(this.value, X);"><option value="0" '+((d==0)?"selected":"")+'>0</option><option value="1" '+((d==1)?"selected":"")+'>1</option><option value="2" '+((d==2)?"selected":"")+'>2</option><option value="3" '+((d==3)?"selected":"")+'>3</option></select>';

	var post = '</div>';
	
	for(var a=1; a<=c; a++)
	{
		label_n = label.replace(/X/g, a);
		adulti_n = adulti.replace(/X/g, a);
		copii_n = copii.replace(/X/g, a);

		out += label_n;
		out += pre_;
		out += label_A+adulti_n;
		out += label_C+copii_n;
		out += '<div style="float:left; width:39%;" id="afisare_varsta_copii_'+a+'">';

		out += varsta_copil(0,a);

		out += '</div>';
		out += post;
	}
	return out;
}



//home page slider

	$(document).ready(function(){
		var slider_area;
		var slider_buttons;

		// Which slider
		if ($('#slider_area').length>0){
			
			// Home Page Slider
			slider_area="#slider_area";	
			slider_buttons="#numbers";
		
		
			$(slider_area).cycle({ 
				fx:     'fade', 
				timeout:  4000,
				//easing: 'backout', 
				prev: '.prev', 
				next: '.next',
				cleartype:  1,
				pause:           true,     // true to enable "pause on hover"
				pauseOnPagerHover: true,   // true to pause when hovering over pager link				
				before:  onBefore, 
				after:   onAfter ,				
				pagerAnchorBuilder: function(idx) { 
					return '<a href="#" title=""><img src="/content/uploads/generic/pixel.gif" width="14" heigth="14"></a>'; 
				}
			});
			
		}

		if ($('.product_detail').length>0){
			
			// Home Page Slider
			slider_area_pp=".product_photos";	
 
			$(slider_area_pp).cycle({ 
				fx:     'fade', 
				timeout:  4000,
				pager:'.product_photos_pager',
				cleartype:  1
			});
			
		}
		
		
	jQuery('.prev, .next').css({opacity:0});
  	jQuery('#slider').hover(function()
	{
		jQuery('.prev, .next').stop().animate({opacity:1},400);
	},
	function()
	{
		jQuery('.prev, .next').stop().animate({opacity:0},400);
	});


	function onBefore() { 
		jQuery('.desc').stop().animate({opacity:0.9},400);
	} 
	function onAfter() { 
		jQuery('.desc').stop().animate({opacity:0.9},400);
	}

		
	});



//pretty photo
	$(document).ready(function(){
		$("a[rel^='prettyPhoto']").prettyPhoto();
	});


//image effects 
	$(document).ready(function(){
			var image_e= $(".image.portf, .image.product_image");
			image_e.mouseover(function(){$(this).stop().animate({ opacity:0.4
					}, 400);
			}).mouseout(function(){
				image_e.stop().animate({ 
					opacity:1
					}, 400 );
			});
	});

//validate contact form
$(document).ready(function(){

		// show a simple loading indicator
		var loader = jQuery('<img src="/content/uploads/generic/loading.gif" alt="loading..." />')
			.appendTo(".loading")
			.hide();
		jQuery().ajaxStart(function() {
			loader.show();
		}).ajaxStop(function() {
			loader.hide();
		}).ajaxError(function(a, b, e) {
			throw e;
		});
		
		jQuery.validator.messages.required = "";
		var v = jQuery("#validate_form").validate({
			submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					target: "#result"
				});
			}
		});
		
		jQuery("#reset").click(function() {
			v.resetForm();
		});
 });



//cufon fonts
	$(document).ready(function(){
		
		var cufon_list="h1,h2,h3,h4,h5,h6"
		var rt_cufon_class = jQuery(cufon_list);	

		rt_cufon_class.each(function(){
			 jQuery(this).addClass('cufon');
		});
	
		Cufon.replace(cufon_list, {hover: true});
	});
	
 

//RT single level drop down menu
function rt_navigation(){

	var rt_dd_menu = jQuery(".navigation ul.navigation > li");	
	var first_li_items = jQuery(".navigation ul.navigation li > ul");
	
	first_li_items.each(function(){
		 jQuery(this).find('>li:first').addClass('first_li'); // class for first li
		 jQuery(this).find('>li:last a').addClass('last_li'); // remove last border

	});
	
	//current item
	jQuery(".navigation ul.navigation >li .current_page_item").parent("li:eq(0)").addClass('active');
	 
	//first-last list items
	rt_dd_menu.each(function(){

		
		$(this).children("ul:eq(0)").addClass('first_ul');
		 jQuery(".navigation ul.navigation li > ul").addClass('first_ul');
		 jQuery(this).find('li:first').addClass('first_li'); // class for first li
		 jQuery(this).find('li:last a').addClass('last_li'); // remove last border
	});
		
		
	//hover		 
	jQuery(".navigation ul.navigation > li").hover(function() {
		jQuery(this).addClass('li_active');
		jQuery(this).children("a:eq(0)").addClass('a_active');
		jQuery(this).find('ul:first').stop().css({overflow:"hidden", height:"auto", display:"none",'paddingTop':'5px','paddingBottom':'15px'}).slideDown(200, function(){jQuery(this).css({overflow:"visible", height:"auto"});});
	}, function() {
		jQuery(this).find('ul:first').stop().slideUp(200, function(){jQuery(this).css({overflow:"hidden", display:"none"});});
		var active_class=jQuery(this).attr("class");			
		if (active_class!="active"){	
			jQuery(this).removeClass('li_active');
			jQuery(this).children("a:eq(0)").removeClass('a_active');
		}
	});
}

$(document).ready(function() {
	rt_navigation();
});

 

//search field function
$(document).ready(function() {
	var search_text=jQuery(".search_bar .search_text").val();

	jQuery(".search_bar .search_text").focus(function() {
		jQuery(".search_bar .search_text").val('');
	})

});
	
	
	
//product tabs
$(document).ready(function() {
if ($('#tabs').length>0){	
	$('#tabs > ul').tabs({ fx: { height: 'toggle', opacity: 'toggle' } });
}
});


//preloading 
$(function () {
	//$('.preload').hide();//hide all the images on the page
	$('.play,.magnifier').css({opacity:0});
	$('.preload').css({opacity:0});
	$('.preload').addClass("animated");
	$('.play,.magnifier').addClass("animated_icon");
});

var i = 0;//initialize
var cint=0;//Internet Explorer Fix
$(window).bind("load", function() {//The load event will only fire if the entire page or document is fully loaded
	var cint = setInterval("doThis(i)",70);//500 is the fade in speed in milliseconds

});

function doThis() {
	var images = $('.preload').length;//count the number of images on the page
	if (i >= images) {// Loop the images
		clearInterval(cint);//When it reaches the last image the loop ends
	}
	//$('.preload:hidden').eq(i).fadeIn(500);//fades in the hidden images one by one
	$('.animated_icon').eq(0).animate({opacity:1},{"duration": 500});
	$('.animated').eq(0).animate({opacity:1},{"duration": 500});
	$('.animated').eq(0).removeClass("animated");
	$('.animated_icon').eq(0).removeClass("animated_icon");
	i++;//add 1 to the count
}



$(document).ready(function() {
$(".photo_gallery img[title]").tooltip({

   // tweak the position
   offset: [40, 0],

   // use the "slide" effect
   effect: 'slide'

// add dynamic plugin with optional configuration for bottom edge
}).dynamic({ bottom: { direction: 'down', bounce: true } });
});

