

function popitup(url) {
	newwindow=window.open(url,'name','height=550,width=500');
	if (window.focus) {newwindow.focus()}
	return false;
}




function delete_image(id,cat_id)
{
	$('#upload_poza').load(id,null,function()
	{
		$('#upload_poza').load('/admin/offers/upload/'+cat_id);
	});
}

function load_upload(id)
{
	
	$('#upload_poza').html('<img src="/images/admin/ajax_loader.gif" />');
	$('#button_div').hide();
	$('#upload_poza').load('/admin/offers/upload/'+id,null,function(){$('#button_div').show();});
	
}
function load_upload_pub(id)
{
	
	$('#upload_poza').html('<img src="/images/admin/ajax_loader.gif" />');
	$('#button_div').hide();
	$('#upload_poza').load('/admin/publicitate/upload/'+id);
	
}

function delete_image_pub(id,cat_id)
{
	$('#upload_poza').load(id,null,function()
	{
		$('#upload_poza').load('/admin/publicitate/upload/'+cat_id);
	});
}

var contor=0;
function add_image()
{
	
	txt = '<br/><input type="file" name="userfile_'+contor+'"  id="user_file" />';
	$('#upload_input').append(txt);
	contor++;
	
}	

function print_it (id, width_i)
{
	if (document.getElementById)
	{
		var content = document.getElementById (id).innerHTML;
		/*content = content.substring (0, content.indexOf ('<script')) + content.substring (content.indexOf ('</script>')+9);*/

		var printWin = window.open ('','', 'width='+width_i+',height=800');
		printWin.document.open ();
		printWin.document.write ('<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"http://www.way2web.ro/css/domenii.css\" /></head><body style=\"background-color:#fff;\">');

// 		printWin.document.write ('<div style="width:1000px; margin:0px auto;">');
		printWin.document.write (content);
// 		printWin.document.write ("</div>");
		printWin.document.write ('</body></html>');
		printWin.document.close ();
		printWin.focus ();
		printWin.print ();

		setTimeout ("", 1000);

		printWin.close();
	}
	return false;
}

function wopen(url, name, w, h)
{
// Fudge factors for window decoration space.
 // In my tests these work well on all platforms & browsers.
w += 32;
h += 96;
 var win = window.open(url,
  name,
  'width=' + w + ', height=' + h + ', ' +
  'location=no, menubar=no, ' +
  'status=no, toolbar=no, scrollbars=yes, resizable=no');
 win.resizeTo(w, h);
 win.focus();
}

function validate_required(field,alerttxt)
{
with (field)
{
if (value==NULL||value=='Nume' && value=='')
  {alert(alerttxt);return false}
else {return true}
}
}



function popup(url, img)
			{
				
				if (typeof window.innerWidth != 'undefined')
 				{
     				viewportwidth = window.innerWidth;
     				viewportheight = window.innerHeight;
					offwidth = document.getElementsByTagName('html')[0].offsetWidth;
			        offheight = document.getElementsByTagName('html')[0].offsetHeight;
				}

				// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

				else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
				{
			       viewportwidth = document.documentElement.clientWidth;
			       viewportheight = document.documentElement.clientHeight;
			       offwidth = document.getElementsByTagName('html')[0].offsetWidth;
			       offheight = document.getElementsByTagName('html')[0].offsetHeight;
				}

				// older versions of IE

				else
				{
			       viewportwidth = document.getElementsByTagName('html')[0].clientWidth;
			       viewportheight = document.getElementsByTagName('html')[0].clientHeight;
				   offwidth = document.getElementsByTagName('html')[0].offsetWidth;
			       offheight = document.getElementsByTagName('html')[0].offsetHeight;
				}
				if(url!=null)
				{
				$('<div id="overall_page" onclick="cancel_mail()" class="overall_page" style="width:'+offwidth+'px; height:'+offheight+'px" ></div>').appendTo("body");
				}
				else
				{
					$('<div id="overall_page" class="overall_page" style="width:'+offwidth+'px; height:'+offheight+'px" ></div>').appendTo("body");
				}
				$('#overall_page').fadeTo("slow", 0.65 ,function(){
					$('#overall_page').after('<div class="main_panel" id="main_panel"></div>');

			if(url!=null){
					$('#main_panel').load( url , null, function(){
						p_width = document.getElementById('main_panel').offsetWidth;
						p_height = document.getElementById('main_panel').offsetHeight;

						new_width  = viewportwidth/2-p_width/2;
						new_height = viewportheight/2-p_height/2;
						document.getElementById('main_panel').style.top = new_height+'px';
						document.getElementById('main_panel').style.left = new_width+'px';
					});}
			else if(img!=null)
			{
				
						$('#main_panel').html('<div class="loading"> <img src="'+img+'" alt="Loading..."/> </div>');
						p_width = document.getElementById('main_panel').offsetWidth;
						p_height = document.getElementById('main_panel').offsetHeight;

						new_width  = viewportwidth/2-p_width/2;
						new_height = viewportheight/2-p_height/2;
						document.getElementById('main_panel').style.top = new_height+'px';
						document.getElementById('main_panel').style.left = new_width+'px';
				

			}


				});



			}

			function cancel_mail()
			{
				$('#overall_page').remove();
				//$('select').css({visibility: 'visible'});
				$('#main_panel').empty();
				$('#main_panel').remove();

			}

			function submit_mail()
			{
				$('#em_form').ajaxSubmit({ target:        '#main_panel'});
			}


			function hoverOn(message)
			{
				$('.help').empty();
				$('.help').html($('#'+message).html());
			//
			}

			function hoverOff()
			{
				$('.help').empty();

			}


function show_pic(top_0)
{
		if(document.getElementById(top_0).style.display == 'block')
		{
			document.getElementById(top_0).style.display = 'none';
		}
		else if(document.getElementById(top_0).style.display == 'none')
		{
			document.getElementById(top_0).style.display = 'block';
		}
}


function verif()
{
	x=document.getElementById('id_level').value;
	count = $('#userfile_count').val();
	var i;
	
	if(x==' ')
	{
		alert("campul nu este completat");
		$('#id_level').focus();
		return false;
		
	}
	for(i=2;i<count;i++)
	{
		if($('#userfile_'+i).val()=='')
		{
			alert('s');
			$('#userfile_'+i).focus();
			return false;
		}
	}
	return true;
}
	
	

	
	
	
