////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////FUNCTII CSS/////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$(function ()
			{
				$(".buton_text_header, .menu_item, .tbl, .mod_cat").mouseover( function () 
												{
													$(this).addClass("over");
												}
									);
				$(".buton_text_header, .menu_item, .tbl, .mod_cat").mouseout( function () 
												{
													$(this).removeClass("over");
												}
									);
			}
 );
$(function ()
			{
				$(".buton_text_footer, .categorii").mouseover( function () 
												{
													$(this).addClass("on");
												}
									);
				$(".buton_text_footer, .categorii").mouseout( function () 
												{
													$(this).removeClass("on");
												}
									);
			}
 );
$(function ()
			{
				$(".buton_edit_vw, .admin_categorie").click( function () 
												{
													$(this).addClass("click");
												}
									);
			}
 );

function file_exists(file, url, id)
{

	file		= url + file;
	//alert (id);
	//alert (file);
	var url 	= "scripts/files.php";
	var param	= "file="+file;
	$.ajax({ 
			type: "POST",
			url: url,
			data: param,
			success: function(msg)
			{
				if (msg=='1')
				{								
					alert("Fisierul exista deja!");
					$("#"+id).val('');
					$("#"+id).focus();
				}
				else
				{
					return;	
				}
			} 
			});
}

$(function()
{
	$("textarea#prezentare_produs").tinymce(
	{
		script_url:"../../functions/tinymce/tiny_mce.js",
		elements : "ajaxfilemanager",
		file_browser_callback : "ajaxfilemanager",
		// General options
		mode : "textareas",
		theme : "advanced",
		plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

		// Theme options
		theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
		theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,

		// Example content CSS (should be your site CSS)
		//content_css : "css/content.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",

		// Replace values for the template plugin
		template_replace_values : 
		{
			username : "Some User",
			staffid : "991234"
		}
	});
});



function select_page(adresa)
{
	//alert((obj).value);
	window.location=adresa;
}



////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ordonare_meniu(poz_new, poz_old, poz_sup, id_selected, nivel)
{
		//alert ('poz_new=' + poz_new +' poz_old' +poz_old);
		//alert (tabel+ '  '+tabel_child+'   '+ poz_new+'   '+ poz_old +'   '+poz_cat_sup);
        var param	= "nivel="+nivel+"&old_poz="+poz_old+"&new_poz="+poz_new+"&poz_sup="+poz_sup;
	if(nivel=='cat')
	{		
		var url_back	= 'administrare.php?u=p&c=m&mc='+id_selected;
	}
	else if(nivel=='subcat')
	{
		var url_back	= 'administrare.php?u=p&c=m&ms='+poz_sup+'&pid='+id_selected;
	}
	else if(nivel=='prod')
	{
		var url_back	= 'administrare.php?u=p&c=m&pc='+poz_sup+'&pid='+id_selected;
	}
	var url 	= "scripts/change_poz.php";
	$.ajax({ 
			type: "POST",
			url: url,
			data: param,
			success: function(msg)
			{
				if (msg=='1')
				{					
					window.location=url_back;
					alert ('REPOZITIONAREA A FOST REALIZATA!');
				}
				else
				{
					alert('OPERATIUNE ESUATA!');
					window.location=url_back;
				}
			} 
			});
}
function ordonare_reclame(poz_new, poz_old, poz_cat_prod, id_selected)
{
		//alert ('poz_new=' + poz_new +' poz_old' +poz_old);
		//alert (tabel+ '  '+tabel_child+'   '+ poz_new+'   '+ poz_old +'   '+poz_cat_sup);
	if(poz_cat_prod=='-1')
	{
		var param	= "nivel="+"-1"+"&old_poz="+poz_old+"&new_poz="+poz_new;
		//alert(param);
		var url_back	= 'administrare.php?u=r&c=m&mc='+id_selected;
	}
	else
	{
		var param	= "nivel="+poz_cat_prod+"&old_poz="+poz_old+"&new_poz="+poz_new;
		var url_back	= 'administrare.php?u=r&c=m&pc='+poz_cat_prod+'&pid='+id_selected;
	}
	var url 	= "scripts/change_pub.php";
	$.ajax({ 
			type: "POST",
			url: url,
			data: param,
			success: function(msg)
			{
				if (msg=='1')
				{					
					window.location=url_back;
					alert ('OPERATIUNE REALIZATA!');
				}
				else
				{
					window.location=url_back;
					alert('OPERATIUNE ESUATA!');					
				}
			} 
			});
}
function modificaProdus(str1, str2, str3, str4, str5, url, tabel) 
{	

	var param = "str1=" + str1 + '&str2=' + str2+'&str3='+str3+'&str4='+str4+'&str5='+str5+'&tabel='+tabel;
	var optiuni = {
					method: 'post',
					parameters: param,
					onSuccess: 
					function(transport) 
					{						
						//alert (transport.responseText);
						window.location=transport.responseText;										
					},
					onFailure: 
					function() 
					{
						alert("Error connect to php script !!!") ;	
					}						
		          };
							   
	new Ajax.Request(url, optiuni) ;	
}

function modificaDate(str1, str2, str3, str4, str5, str6, url, tabel) 
{	
	var param = "str1=" + str1 + '&str2=' + str2+'&str3='+str3+'&str4='+str4+'&str5='+str5+'&str6='+str6+'&tabel='+tabel;
	var optiuni = {
					method: 'post',
					parameters: param,
					onSuccess: 
					function(transport) 
					{						
														
						window.location="administrare.php?url=Date de contact";		
										
					},
					onFailure: 
					function() 
					{
						alert("Error connect to php script !!!") ;	
					}						
		          };
							   
	new Ajax.Request(url, optiuni) ;	
}
function sterge(nr_crt, denumire, ers, url1, url2, poz_prod, poz_cat)
{	
	if(confirm('Stergeti inregistrarea '+denumire+'?'))
	{
	 window.location="eraser.php?nr_crt="+nr_crt+'&ers='+ ers + '&url=' + url1 + '&url2=' + url2  + '&poz_prod=' + poz_prod  + '&poz_cat=' + poz_cat;
	}
}
