function search_submit(base_url)
{

	var keyword = document.getElementById('keyword_1').value;
	var section = document.getElementById('section').value;
	var edition = document.getElementById('editie').value;
	var tags = document.getElementById('tags_1').checked;
		
	
	if(keyword=='')keyword='0';
	if(section==''||section=='all')section='0';
	if(edition=='')	edition='0';
	
	if(tags) tags='1'; else tags='0';
	document.location=base_url+'search/index/'+ keyword+'/'+section+'/'+edition+'/'+tags;
}
function set_valid(base_url,id)
{
	$('#valid_'+id).html('<img style="height:11px;" src="/images/loading.gif"/>');
	$('#valid_'+id).load(base_url+'admin/users/validate_user/'+id);
}
function change_picture(url,base_url)
{
	$('#pic').html('<img src="/images/loading.gif"/>');
	$('#pic').load(base_url+'change_pic',{picture_url:url});
}
function download(base_url,url,pic_name)
{
	$('#download').load(base_url+'download',{file:url,file_name:pic_name});
}
function popitup(url) {
	newwindow=window.open(url,'name','height=550,width=500');
	if (window.focus) {newwindow.focus()}
	return false;
}

function validation_cariera()
{
	var ok=false;
	if($('#nume').val()=='')
	{
		alert('Va rugam introduceti numele!');
		ok=true;
	}else
	if($('#prenume').val()=='')
	{
		alert('Va rugam introduceti prenumele!');
		ok=true;
	}else
	if($('#email').val()=='')
	{

		alert('Va rugam introduceti email-ul!');
		ok=true;
	}else
	if($('#telefon').val()=='')
	{
		alert('Va rugam introduceti telefonul!');
		ok=true;
	}else
	if($('#mesaj').val()=='')
	{
		alert('Va rugam introduceti mesajul!');
		ok=true;
	}else
	if(!echeck($('#email').val()))
	{
		
		ok=true;
	}
	if(ok)
	{
		return false;
	}
	else return true;
}


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;
}
	
	
	
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

var t=0
function add_soft_()
{
	k4=$('#s').val();
	k4++;
	$('#s').val(k4);
	txt = '<br/><input type="file" name="s_soft_exe_'+t+'"  id="soft_exe_'+t+'" />';
	$('#upload_soft').append(txt);
	t++;
}	

var nr=0;
function add_softt_()
{
	k5=$('#s').val();
	k5++;
	$('#s').val(k5);
	txt = '<br/><input type="file" name="s_soft_exe_'+nr+'"  id="soft_exe_'+nr+'" />';
	$('#upload_softt').append(txt);
	nr++;
}	

function pass_show()
{
	$('#password').show();
	$('#div_login').hide();
}

function login_show()
{
	$('#password').hide();
	$('#div_login').show();
}
	
	
