$(function() {

	//*********************************//
	//***SETTING PRICES AND CURRENCY***//
	//*********************************//
	var currency = new Array();
	
	currency['kn']=1;
	currency['$']=5.4;
	currency['€']=7.09;

	var price = new Array();	
	//PRICE PER DAY
	price['days']= new Array;
	price['days'][1]=1599;
	price['days'][2]=1399;
	price['days'][3]=1199;
	price['days'][4]=999;
	price['days'][5]=899;
	price['days'][6]=799;
	price['days'][7]=699;
	
	var other_pages_discount = 0.3;
	//var discount = 30;
	
	price['code_seo']=0;
	price['favicon']=50;
	price['simple_jquery']=100;
	price['complex_jquery']=1000;
	price['commented_code']=200;
	
	price['w3c']=0;
	price['ie6']=0;
	price['ie7']=0;
	price['ie8']=0;
	price['firefox3']=0;
	price['safari3']=0;
	price['opera96']=0;
	price['chrome']=0;
	
	price['wordpress']=1300;
	price['joomla']=1300;
	price['expression']=1300;
	price['drupal']=1300;
	
	price['drop_down_menu']=100; /*XXXX*/
	price['slideshow']=300; /*XXXX*/
	price['sifr']=200;
	price['css_reset']=0; /*XXXX*/
	
	//CODING
	price['full_cms']=3500;
	price['simple_contact_form']=500;
	price['complex_contact_form']=750;
	price['rss']=400;
	price['blog']=2000;
	price['web_shop']=5000;
	price['online_payment']=2000;
	
	price['cms_news']=700;
	price['cms_poll']=700;
	price['cms_photo_gallery']=700;
	price['cms_dynamic_photo_gallery']=1600;
	price['cms_simple_search']=700;
	price['cms_complex_search']=1200;
	price['cms_faq']=700;
	price['cms_articles']=1600;
	price['cms_comments']=2500;
	price['cms_statistics']=500;
	
	// OTHER
	price['seo']=1600;
	price['keywords_optimization']=2000;
	price['flash']=5000;
	price['flash_programming']=10000;
	price['flash_banner']=2600;
	price['magento']=2600;
	price['newsletter']=1200;
	price['google_maps']=360;
	price['phpbb']=1300;
	
	var total_price = 0;
	
	var selected_currency = 'kn';
	var old_currency = 'kn';
	
	
	$("#box_price h2 a").click(function(){ return false; })
	
	//CHANGING CURRENCY
	$("#box_price h2 a").each(function()
	{
		$(this).click(function(){
			
			//$("#info_box_order h2 .price").text("0 " + selected_currency);
			
			
			currency_id = $(this).attr("class");
			
			//console.log(currency_id);
			
			old_currency = selected_currency;
			
			selected_currency = currency_id.substring(currency_id.indexOf("_")+1);
						
			//set_option_prices();
			
			$("#info_box_order .price").each(function()
			{			

				sel_price = $(this).text();
			
				sel_price = sel_price.substring(0, sel_price.indexOf(" "));
				sel_price = sel_price.replace(".", "")
				
				sel_price = $(this).prev().attr("name");
				sel_price = price[sel_price];
				
			    //console.log('sel price: '  +  sel_price);
				
				if(isNaN(sel_price)||sel_price == '')
				{
					//a = 1; //alert("juhu")
					//This is not a number - Free
				}
				else
				{
					//console.log(selected_currency);
										
					sel_price = (sel_price/currency[selected_currency]).toFixed(0);

					//sel_price = sel_price.toFixed(0);
					
					if(sel_price.length>3)
					{
						sel_price = sel_price.substring(0, sel_price.toString().length-3)
									  + '.'
									  + sel_price.substring(sel_price.toString().length-3);
					}
					//$("#design_slicing").next().next().next()
					$(this).html(sel_price + ' ' + selected_currency);
					
					//console.log(selected_currency);
					
				}//end else
				
			}) // end "#info_box_order .price" .each
			
			//set_slicing_price();
			//set_option_prices();

			nr_days = $('#slider_nr_days').slider('option', 'value');			
			nr_pages = $('#slider_nr_pages').slider('option', 'value');
			//console.log(nr_pages);
			
			var design_slicing_price = (price['days'][nr_days]/currency[selected_currency]).toFixed(0);
			
			first_page = design_slicing_price;
			
			other_pages = (((nr_pages)-1) * ((price['days'][nr_days]/currency[selected_currency])).toFixed(0));
			
			discount = (other_pages * other_pages_discount).toFixed(0);
						
			other_pages = other_pages - discount; 
			//other_pages = other_pages.toFixed(0);
			design_slicing_price = parseInt(first_page) + parseInt(other_pages);
			slider_slicing_price = design_slicing_price.toString();
			
			design_slicing_price = design_slicing_price.toString();
			if(design_slicing_price.length>3)
			{
				design_slicing_price = design_slicing_price.substring(0, design_slicing_price.toString().length-3)
		  							 + '.'
									 + design_slicing_price.substring(design_slicing_price.toString().length-3);
			}

			
			
			$("#box_order_details p:first span").html(design_slicing_price + ' ' + selected_currency);

			set_h2_price();
			//price_summary();
			//$("#nr_pages").val( ui.value )
			
			//$('#slider_nr_days').slider({ ui.value = 5 });
			
			return false;
			
		}) // end $(this).click
		
	}); // end changing currency - ("#box_price h2 a") .each
	
	
	//SETTING H2 PRICE
	function set_h2_price()
	{
		$("#info_box_order h2 .price").text("0 " + selected_currency);
		first_pass = false;
		group_pass = 1;
		option_group_price = 0;
		$("form #info_box_order .group").each(function()
		{
						
			//console.log('.');
			//console.log('.');
			//console.log('group_pass: ' + group_pass);
			
			h2_price = 0;
			option_group_price = 0;
			$(this).find(".group_options input:checkbox:checked").each(function()
			{
				/*
				if(first_pass==false)
				{
					h2_price = $("#box_order_details p:first span").text();
					
					h2_price = h2_price.substring(0, h2_price.indexOf(" "));
					h2_price = parseInt(h2_price.replace(".", ""));
					
					
					//console.log('selected currency: ' + selected_currency);
					//console.log('h2prics: ' + h2_price);
					
					option_group_price = h2_price;
					h2_price = parseInt(0);
					//h2s = (h2_price * (currency[selected_currency])).toFixed(0);
					
					//console.log("defaultna vrijednost za rezanje: "  +  option_group_price);
				
					first_pass = true;
				}
				*/
				this_price = $(this).attr('name');
				
				//this_price = (this_price / currency[selected_currency]).toFixed(0);
				
				//console.log('this price= ' + this_price);			
	//			h2_price.toFixed(0);
				h2_price = h2_price + parseInt( price[this_price] );
				
				
			})
			

			//SET PRICE OF THE GROUP
			/*
			if(old_currency != 'kn')
			{
				h2_price = (h2_price*currency[old_currency]);
			}
			*/
			
			
			
			h2_price = (h2_price/currency[selected_currency]).toFixed(0);
			
			//console.log("defaultna vrijednost za rezanje1: "  +  option_group_price);
			//console.log(h2_price)
			/*
			if(group_pass == 1)
			{
				h2_price = parseInt(h2_price) + parseInt(option_group_price);
			}
			*/
			//console.log("h2_price6: " + h2_price);
			/*
			if(h2_price.toString().length>3)
			{
				h2_price = h2_price.substring(0, h2_price.toString().length-3)
				+ '.'
				+ h2_price.substring(h2_price.toString().length-3);
			}
			*/
			
			//$(this).prev().find(".price").html(h2_price + ' ' + selected_currency);
						
			//console.log("id= "+$(this).prev().find(".price").attr("id"))
						
			group_pass++;
			
		});
		
		price_summary();
	} // end function setting_h2_price()
	
	
	//SETTING OPTION PRICES
	function set_option_prices()
	{
	$("form input:checkbox").not("h2 input").each(function()
	{
		//slicing_price = $("#design_slicing").next().next().		
		
		this_price = $(this).attr('name');
				
		current_price = (price[this_price]/currency[selected_currency]).toFixed(0).toString();
		
		if(current_price.length>3)
		{
			current_price = current_price.substring(0, current_price.toString().length-3)
						  + '.'
						  + current_price.substring(current_price.toString().length-3);
		}
		if(current_price == '0')
		{	
			switch(selected_currency)
			{
				case 'kn':
				$(this).next().html('Besplatno');
				//console.log(selected_currency);
 				break;
				
				default:
				$(this).next().html('Free');
				//console.log(selected_currency);
			}			
		}
		else if(current_price == 'NaN')
		{
			if(selected_currency == 'kn')
			{
				$(this).next().html('Na upit');
			}
				
			else 
			{
				$(this).next().html('On request');
			}
		}
		else
		{
			if($(this).next().hasClass("from"))
			{
				// IF PRICE IS "FROM"
				//$(this).next().html('~ '+current_price+' '+selected_currency);
				
				$(this).next().html(current_price+' '+selected_currency);
			}
			else
			{
				$(this).next().html(current_price+' '+selected_currency);
			}
		}
		
	}) // end each
	
	set_h2_price();
	
	}//end function set_option_prices
	
	
	//***********************//
	//*SETTING PRICE SUMMARY*//
	//***********************//
	function price_summary()
	{
		
		$("#box_price .group").remove();
		$("#info_box_order h2 :checkbox:checked").each(function()
		{
				//console.log(this_h2)
				total_price = total_price + h2_price;
				option_price = '';
				
				//console.log("total prajs: " + total_price);
				
				//console.log($(this).parent().next().find(".group_options").attr("class"));
				
				$(this).parent().next().find(".group_options :checkbox:checked").each(function()
				{
					if(($(this).next().text()!='Besplatno')&&($(this).next().text()!='Free')&&
					   ($(this).next().text()!='Na upit')&&($(this).next().text()!='On request'))
					{
					
					option_price =  option_price + 
									'<li><span>' +
									$(this).next().text() +
									'</span>' +
									$(this).prev().prev().text() +
									'</li>';
					}
					
				})
				service_name = $(this).next().text();
				
				service_price = $(this).next().next().next().text();

				//service_nr = $(this).next().attr("class");
	
				//service_nr = service_nr.replace("k", "")
				//serv_array = new Array();
				
				//serv_array[0] = 0;
				
				//serv_array[service_nr] = service_nr;
				//serv_array[1]
				//serv_array[2]
				
				//console.log('sr nae: ' + service_nr);

				//console.log('servis pricce: '  +  service_price);
				
				if((service_name == "Rezanje dizajna") || (service_name == "Design slicing"))
				{
					h2_price = $("#box_order_details p span").text();
					h2_price = h2_price.substring(0, h2_price.indexOf(" "));
					h2_price = parseInt(h2_price.replace(".", ""));
					//h2_price = (h2_price/currency[selected_currency]).toFixed(0);
					h2_price = h2_price.toFixed(0);
					
					//console.log("prajs samuraj: " + h2_price);					
					//service_price = service_price + h2_price;
					
					p_nr = $("#nr_pages").val();
					d_nr = $("#nr_days").val();
					//console.log(d_nr);
					if(p_nr == 1 )
					{
						p_name = ' stranica';
					}
					else if((p_nr > 1)&&(p_nr < 5))
					{
						p_name = ' stranice';
					}
					else
					{
						p_name = ' stranica';
					}
					
					basic_slicing_cost = '<li><span>'+ h2_price + ' ' + selected_currency +'  </span> '+ service_name +' (' + p_nr + p_name + ', ' + d_nr  + ')'  +'</li>';
					
				}
				else
				{
					basic_slicing_cost = '';
				}
				
				//console.log('sp: ' + service_price);
				
				$("#box_price #sum_total").before
				(
				 '<div class="group">' +
				 
				 '<h3><span>' + service_price +  ' </span>' + service_name + '</h3>' +
				 
				 '<ul>' +
				 
				 basic_slicing_cost +
				 
				 option_price +
				 				 
				 '</ul>'+
				 
				 '</group>'
				)
				
		});
		total_price = 0;
		option_price = 0;
		h2_nr = 0;
		
		//total_price = parseInt(h2_price);
		
		//#BOX_PRICE TOTAL
		//$("#box_price .group h3 span").each(function()
		//$("#box_price .group ul li span").each(function()
														  
		$("#box_price .group ul").each(function()
		{
			$(this).find("li span").each(function()
			{
				sel_price = $(this).text();
				
				sel_price = sel_price.substring(0, sel_price.indexOf(" "));
				sel_price = sel_price.replace(".", "");
			
				total_price = total_price + parseInt(sel_price);
				option_price = option_price + parseInt(sel_price);
			})
			
			//console.log("cij gfru: "  +  $(this).prev().find("span").text());
			//console.log(option_price);
			
			option_price = option_price.toString();
			
			if(option_price.length>3)
			{
			option_price = option_price.substring(0, option_price.toString().length-3)
						  + '.'
						  + option_price.substring(option_price.toString().length-3);
			}
			
			$(this).prev().find("span").text(option_price + ' ' + selected_currency);
			
			//console.log('h3span ' + $("#box_price h3:eq(0)").find("span").html());
			//console.log(this_h2.next().next().next().attr("class"))
			//this_h2.next().next().next().text(option_price + ' ' + selected_currency);
			
			
			
			//this_h2 = parseInt(this_h2);
			//console.log('h2: ' + this_h2);
//			$("#info_box_order h2 .price:eq(" +  + ")").text(option_price + ' ' + selected_currency);
			
			$("#info_box_order h2 :checkbox:checked:eq(" + h2_nr + ")").next().next().next().text(option_price + ' ' + selected_currency);
			
			
			
			h2_nr++;
			
			option_price = 0;
			
		}) // end #box_price .each		
		
		//console.log("total: " + $("#box_order_details p:first span").text());
//		total_price = total_price + parseInt(h2_price);
		total_price = total_price.toString();
		
		if(total_price.length>3)
		{
			total_price = total_price.substring(0, total_price.toString().length-3)
						  + '.'
						  + total_price.substring(total_price.toString().length-3);
		}
//		console.log('totalnus cijenus: ' + h2_price);
		
		$("#box_price #sum_total span").html(total_price+ ' '+ selected_currency);
		
		
		
		toggle_click();
	}; // end price_summary()
	
	
	set_option_prices();


	//*******************//
	//***PAGES SLIDERS***//
	//*******************//
	$("#slider_nr_pages").slider
	({
	 	range: "min",
		value:1,
		min: 1,
		max: 20,
		step: 1,
		slide: function(event, ui) 
		{
/*			if((ui.value == 2)||(ui.value == 3)||(ui.value == 4))
			$("#amount").val( ui.value + ' stranice');
			else*/
			$("#nr_pages").val( ui.value );
			
			days_delivery = $("#slider_nr_days").slider("value");
									
			pages_price = price['days'][days_delivery]/currency[selected_currency];
			first_page = pages_price.toFixed(0);
			
			other_pages = (((ui.value)-1) * ((price['days'][days_delivery]/currency[selected_currency])).toFixed(0));
			other_pages = other_pages.toFixed(0);
			
			
			discount = (other_pages * other_pages_discount).toFixed(0);
			
			other_pages = other_pages - discount;
			
			pages_price = parseInt(first_page) + parseInt(other_pages);
			pages_price = pages_price.toString();
			if(pages_price.length>3)
			{
			pages_price = pages_price.substring(0, pages_price.toString().length-3)
						  + '.'
						  + pages_price.substring(pages_price.toString().length-3);
			}
			//cijena = cijena + (((br_stranica-1) * (cijene[br_dana] * 0.7)));
						
			$("#box_order_details p:first span").html(pages_price + ' ' + selected_currency);
		},
		stop: function(){ set_h2_price(); price_summary(); }
	});
	
	$("#nr_pages").val( $("#slider_nr_pages").slider("value") );
	
		
	//VALUES FOR DAYS SLIDER ON LOAD PAGE LOAD
	slider_price = price['days'][7]/currency[selected_currency];
	slider_price = slider_price.toFixed(0)
	if(slider_price.length>3)
	{
	slider_price = slider_price.substring(0, slider_price.toString().length-3)
				  + '.'
				  + slider_price.substring(slider_price.toString().length-3);
	}
	$("#box_order_details p:first span").html(slider_price + ' ' + selected_currency);
	price_summary();
	
	
	//*******************//
	//*** DAYS SLIDER ***//
	//*******************//
	$("#slider_nr_days").slider
	({
	 	range: "min",
		value:7,
		min: 1,
		max: 7,
		step: 1,
		slide: function (event, ui) 
		{
			if(ui.value == 1)
			{
				$("#nr_days").val( ui.value + ' dan');
			}
			else
			{
				$("#nr_days").val( ui.value + ' dana');
			}
			
			nr_pages = $("#slider_nr_pages").slider("value");
			
			slider_price = price['days'][ui.value]/currency[selected_currency];
			slider_price = slider_price.toFixed(0)
			
			first_page = slider_price;		
			
			other_pages = (((nr_pages)-1) * ((price['days'][ui.value]/currency[selected_currency])).toFixed(0));
			
			discount = (other_pages * other_pages_discount).toFixed(0);
						
			other_pages = other_pages - discount; 
			//other_pages = other_pages.toFixed(0);
			slider_price = parseInt(first_page) + parseInt(other_pages);
			slider_price = slider_price.toString();
			
			//console.log("first page: " + first_page);
			//console.log("discount: " + discount);
			//console.log("first page: " + first_page);

			if(slider_price.length>3)
			{
			slider_price = slider_price.substring(0, slider_price.toString().length-3)
						  + '.'
						  + slider_price.substring(slider_price.toString().length-3);
			}
			
			$("#box_order_details p:first span").html(slider_price + ' ' + selected_currency);
			//$("#box_order_details p:first span").html(price['days'][ui.value] + ' kn');
			
			//set_h2_price();
			//price_summary();
			
		},
		stop: function(){ set_h2_price(); price_summary(); }
	});
	
	$("#nr_days").val( $("#slider_nr_days").slider("value") + ' dana');
	

	//***********************//
	//***** CHECKBOXES ******//
	//***********************//
	
	//EACH OPTION CHECK
	$(".option_check").each(function()
	{
		var a = $(this).prev().prev().attr('checked');
		//console.log(a);
		if( a == true)
		{
			$(this).css( { backgroundImage : "url(design/checkbox_checked.png)" } );
		}
		else
		{
			$(this).css( { backgroundImage : "url(design/checkbox.png)" } );
		}
		
	});
		
	var h2_each = false;
	//EACH H2 OPTION CHECK
	$("#info_box_order h2 .option_check").click(function()
	{		
		var checked = $(this).prev().prev().attr('checked');
		h2_each = true;
		
		if(checked == true)
		{
			$(this).css( { backgroundImage : "url(design/checkbox.png)" } );
			$(this).prev().prev().attr('checked', '');
			$(this).next().text("0 " + selected_currency);
		}
		else
		{
			$(this).css( { backgroundImage : "url(design/checkbox_checked.png)" } );
			$(this).prev().prev().attr('checked', 'checked');
			
			tab_to_open = $(this).parent().next();
			tab_to_open_b = tab_to_open.is(":hidden")
			
			if(tab_to_open.height()==0)
			{
			//$(".group.active").css( {height : "0", display : "none" }).removeClass("active");

			tab_to_open.css( { display: "block", height : "auto" })
			}
			
		}
		
		price_summary();
		//$("#info_box_order h2 :checkbox").click(function(){ $("#info_box_order h2 .price").text("0"); })
		//set_h2_price();
	})
		
	//CLICK ON LI LIST TO CHECK CHECKBOX (PICTURE)
	$(".group_options li").click(function()
	{		
		var checked = $(this).find(":nth-child(3)").attr('checked');			

		//console.log(checked);
		
		if(checked == true)
		{
			$(this).find(".option_check").css( { backgroundImage : "url(design/checkbox.png)" } );
			$(this).find(".checkbox").attr('checked', '');
		}
		else
		{
			$(this).find(".option_check").css( { backgroundImage : "url(design/checkbox_checked.png)" } );
			$(this).find(".checkbox").attr('checked', 'checked');
		}
		set_h2_price();
		//transparent url(../design/checkbox_checked.png) no-repeat scroll 0 0									  
	})
	
	
	// OPENING AND CLOSING .GROUP DIVs
	$("#info_box_order .group ul li").click(function()
	{
		var group_index = $('#info_box_order .group').index($(this).parent().parent());
		var li_link = $('#info_box_order .group:eq(' + group_index + ') ul li').index(this);
		
		var x = $(this).parent().parent().find(".group_options:eq("+li_link+")").css("display");
		//console.log('disply: '+ x);
		
		$(this).parent().parent().find(".active:not(a)").css("display", "none").removeClass(".active");
		$(this).parent().parent().find(".active").removeClass("active");
		$(this).find("a").addClass("active");
		
		$(this).parent().parent().find(".group_options:eq("+li_link+")").css("display", "block").addClass("active");
		
		var group_option = $(this).parent().parent().find(".group_options:eq("+li_link+")").attr("class");
		//console.log(group_option);
		//console.log('li link: '+li_link);
		//console.log('group index: ' + group_index);
		return false;
	})

	
	//SERVICES TABS
	$("#info_box_order .group:not(:eq(0))").css("height", 0);
	//$("#info_box_order .group").css("height", 0);
	
	//H2 HOVER DUE TO IE6
	$("#info_box_order h2").hover(function(){ $(this).css( "text-decoration", "underline" ) }, function(){ $(this).css( "text-decoration", "none" ) })
	
	//H2 A .CLICK
	$("#info_box_order h2").click(function()
	{
		if(h2_each == false)
		{
		//var element = $(this).parent().next();
		var element = $(this).next();		
		//console.log(h2_each)
		if(element.height()==0)
		{
			//$(".group.active").css( {height : "0", display : "none" }).removeClass("active");

			element.css( { display: "block", height : "auto" }) //.addClass("active");
			//element.css( { display: "none", height : "auto" }) //.addClass("active");
			//element.slideDown(5600);
			$(this).find(".option_check").css( { backgroundImage : "url(design/checkbox_checked.png)" } );
			$(this).find(".option_check").prev().prev().attr('checked', 'checked');
			price_summary();
		}
		else
		{
			//$(".group.active").removeClass("active");
			element.css("height", 0);
			element.css("display", "none");
			//element.slideUp(5600, function(){ element.css("height", 0); });
			
			
		}
		
		//if($('body').scrollTop() > 130) $('body').animate({scrollTop:'130px'}, 500);
		//if($('html').scrollTop() > 130) $('html').animate({scrollTop:'130px'}, 500);		
		}
		h2_each = false;
		return false;
		
	});


	//Hidding/Showing price summary details
	function toggle_click()
	{
		$("#box_price .group h3").click(function()
		{
			$(this).next().toggle();
		})
	}

	//sidebar hide / show boxes
	$("#box_order_details h2, #box_price h2, #box_payment h2").click(function()
	{
		$(this).next().toggle();
	})

	
	//MAIN CONTACT FORM TOGGLE
	$("#contact h2").click(function()
	{
		$(this).next().toggle();
		return false;
	})
	
	

	//**************
	// FORM SUBMIT
	//**************
	
	//on click submit
	submit_nr = 0;
	$("form").submit(function()
	{
		if(submit_nr<8)
		{
			send_order();
			submit_nr++;
		}
		return false;
	
	}) // end form .submit()
	
	
	$("#send_order_big a").click(function()
	{
		if(submit_nr<8)
		{
			send_order();
			submit_nr++;
		}
		return false;
	})
	
	
	function check_form_name()
	{
		
		order_name = $("form #name").val();
		order_name.replace(" ", "");
		
		if(order_name == '')
		{
			$("form #name").css({'background-color' : '#FF5B5B'});
		}
		else
		{
			$("form #name").css({'background-color' : '#fff'});
		}
		
		//$("form #name").remove();
	}
	
	function check_form_email()
	{
		
		order_email = $("form #email").val();
		order_email.replace(" ", "");
		
		if(order_email == '')
		{
			$("form #email").css({'background-color' : '#FF5B5B'});
		}
		else
		{
			$("form #email").css({'background-color' : '#fff'});
		}
		
	}
	
	//FORM REQUIRED FIELDS ON BLUR
	$("form #email, form #name").blur(function()
	{ 
		check_form_name();
		check_form_email();
	})
	
	//sending order
	function send_order()
	{
		
		order_name = $("form #name").val();
		order_name.replace(" ", "");
		order_email = $("form #email").val();
		order_email.replace(" ", "");
		
		$(".message_order_error").css("display", "none");
		$(".message_order_ok").css("display", "none");
		
		check_form_name();
		check_form_email();
		
		if((order_name == '') || (order_email == ''))
		{

			$(".message_order_error").css("display", "block");
			
			if($('#contact .group').is(':hidden')) $('#contact .group').toggle();
			
			return false;
		}
		else
		{	
		
		var for_submit = '';
		var text_name;
		var text_value;
		
		for_submit = 'Total: ' + $("#sum_total span").text() + "\n\r <br />";
		
		$("form :text").each(function()
		{
			text_name = $(this).attr("name");
			text_value = $(this).val();
			
			if(text_value.replace(" ","")!='')
			{
				for_submit = for_submit + text_name + ' : ' + text_value + " \n\r <br />";
			}
			
		}) // end form :text each()
		
		text_value = $("#contact #contact_comments").val();
		text_name = $("#contact #contact_comments").attr("name");
		
		for_submit = for_submit + '<br /><b>' + text_name + '</b> \n\r <br />' + text_value + '\n\r <br />';
		
		for_submit = for_submit + '\n\r\n\r <br />';
		
		
		$("form h2 :checkbox:checked").each(function()
		{
			
			text_name = '<b>' + $(this).next().find("label").text();
			text_value = $(this).next().next().next().text() + '</b>';
			
			for_submit = for_submit + text_name + ' : ' + text_value + "\n\r\n\r <br /><br />";
			
			$(this).parent().next().find(":checkbox:checked").each(function()
			{
				//text_name = $(this).attr("name");
				text_name = $(this).prev().prev().text();
				text_value = $(this).next().text();
				
				for_submit = for_submit + text_name + ' : ' +  text_value + " \n\r <br />";
						
			})
			
			$(this).parent().next().find("textarea").each(function()
			{
				text_value = $(this).val();
				if(text_value.replace(" ", "")!='')
				{
					text_name = $(this).prev().text() + ' (' + $(this).attr("name") + ')';
					
					for_submit = for_submit + "\n <br />" + text_name + "\n <br />" + text_value + " \n\r <br />";
					
				}
			})
			
			for_submit = for_submit + "\n\r <br />";
			
		}) // end form h2 each()
		
		//console.log(for_submit)
		
		for_submit = for_submit + $("#uploaded_files").html() + "\n\r <br />";
		
		
		for_submit = 'podaci = ' + for_submit;
		
		$(".message_none").load( 'scripts/order_page.php', for_submit, function(data)
		{
			
			if(data == 'ok')
			{
				$(".message_order_ok").css("display", "block");
				//$("input[type='submit']").attr("disabled", "true");
			}
			else
			{
				$(".message_order_error").text(data).css("display", "block");
			}
			
		});
			
		
		}
		
		
	}//end function send_order()
	
	
	
	
});