function printPage(img_url, content)
{
	var options='scrollbars=yes, location=no, resizable=yes, width=610,height=700, left=0 ,top=0';
	
	var currentTime = new Date()
	var month = currentTime.getMonth() + 1
	var day = currentTime.getDate()
	var year = currentTime.getFullYear()
	var curr_date = day+ "/" + month + "/" + year;
	
	imgWin=window.open('about:blank','',options);
	
	
	var html = '<table cellspacing="0" cellpadding="0" border="0" class="th100" style="border: 1px solid #000000">';
		html += '<tr>';
		html += '	<td height="25">&nbsp;</td>';
		html += '</tr>';
		html += '<tr>';
		html += '	<td width="98%" height="100%" valign="top" style="padding:5px;padding-right: 5px;">';
		html += '		<div id="pr"></div>';
		html += '	</td>';
		html += '</tr>';
		html += '<tr>';
		html += '	<td height="20" class="site_text">';
		html += '		<hr class="print">';
		html += '		<div style="float:left;">';
		html += '			&nbsp;&nbsp;&nbsp;&copy; Copyright CVBook.com, <br />';
		html += '			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Business Club - Sofia University "St. Kliment ochridski"';
		html += '		</div>';
		html += '		<div style="float:right">' + curr_date +'&nbsp;</div>'
		html += '		<br style="clear: both;" />';
		html += '	</td>';
		html += '</tr>';
		html += '</table>';
	
	
	with (imgWin.document)
		{
			writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
			writeln('<html>\n<head>\n<title>Loading...<\/title><style type="text/css"> @import "../css/site.css"; </style>\n<style type="text/css">\n\t body { margin:0px; } \n<\/style>');
			writeln('<style type="text\css">');
			writeln('#prnt{ ');
			writeln('\t backrgound: #999 url('+ img_url +'print_back3.gif) no-repeat  ');
			writeln('\t margin: 10px; color: red;');
			writeln('}');
			writeln('</style>');
			writeln('<\/head>\n<body onload="self.focus(); print();" >');
			writeln('<div id="prnt" >');
			writeln('\t'+ content +'\n<\/div>'+ html +'<\/body>\n<\/html>');
			close();		
		}//end with
	
	//window.open('print.php','','width=610, height=700, top=50,left=50, scrollbars=yes,location=no');
}//end func

function sendToFriend(val){
	window.open('sendtofriend.php?url=' + val ,'new','width=400, height=200, scrollbars=no, status = no');
}



function checkFeedback(){
		Exp = /^[a-zA-Z0-9\._-]+@+[a-zA-Z0-9\._-]+\.+[a-zA-Z]{2,3}$/;
		if (!document.feedback.name.value){
			alert("Моля въведете име!");
			document.feedback.name.focus();
			return false;				
		}
		
		if (!document.feedback.email.value){
			alert("Моля въведете email!");
			document.feedback.email.focus();
			return false;				
		}
		else 
			if (!Exp.exec(document.feedback.email.value)){
				alert("Моля въведете валиден email!");
				document.feedback.email.focus();
				return false;	
			}

		if (!document.feedback.comment.value){
			alert("Моля въведете коментар!");
			document.feedback.comment.focus();
			return false;				
		}

		if (!document.getElementById('subscribe1').checked && !document.getElementById('subscribe2').checked){
			alert("Моля изберете дали да получавате информация от този сайт за напред!");
			document.feedback.subscribe.focus();
			return false;	
		}

		document.feedback.submit();


}//end func


function checkLogin(){
		
		if (!document.login.username.value){
			alert("Моля въведете потребителско име!");
			document.login.username.focus();
			return false;				
		}
		
		if (!document.login.password.value){
			alert("Моля въведете парола!");
			document.login.password.focus();
			return false;				
		}
		

		document.login.uname.value = document.login.username.value;
		document.login.upass.value = document.login.password.value;

		document.login.action = 'authorize.php';
		document.login.submit();


}//end func
function goLoginTop(){
		
		if (!document.login_top.u_name.value){
			alert("Моля въведете потребителско име!");
			document.login_top.u_name.focus();
			return false;				
		}
		
		if (!document.login_top.u_pass.value){
			alert("Моля въведете парола!");
			document.login_top.u_pass.focus();
			return false;				
		}
		

		document.login_top.uname.value = document.login_top.u_name.value;
		document.login_top.upass.value = document.login_top.u_pass.value;

		document.login_top.action = 'authorize.php';
		document.login_top.submit();


}//end func

function publish(){
	document.release.type.value = 1;
	document.release.sub.value = 1;

	
	document.release.submit();
}//end func

function unpublish(){
	document.release.type.value = 0;
	document.release.sub.value = 1;
	
	document.release.submit();
}//end func

function no(){
	window.location.href='cv.php';
	
}//end func


function changeCompanyDetails(){
			Exp1=/^[a-zA-Z0-9\._-]+@+[a-zA-Z0-9\._-]+\.+[a-zA-Z]{2,3}$/;
			Exp2=/^[0-9]+$/;


			if(document.details.company_name_bg.value == ''){
				alert('Моля въведете име на компания!');
				document.details.company_name_bg.focus();
				return false;
			}

			if(document.details.company_name_en.value == ''){
				alert('Моля въведете име на компанията на английски!');
				document.details.company_name_en.focus();
				return false;
			}

			if(document.details.person_name_bg.value == ''){
				alert('Моля въведете име на лицето за контакти!');
				document.details.person_name_bg.focus();
				return false;
			}

			if(document.details.person_name_en.value == ''){
				alert('Моля въведете име на лицето за контакти на английски!');
				document.details.person_name_en.focus();
				return false;
			}

			if(document.details.person_lastname_bg.value == ''){
				alert('Моля въведете фамилия на лицето за контакти!');
				document.details.person_lastname_bg.focus();
				return false;
			}

			if(document.details.person_lastname_en.value == ''){
				alert('Моля въведете фамилия на лицето за контакти на английски!');
				document.details.person_lastname_en.focus();
				return false;
			}
			
			if(document.details.person_email.value == ''){
				alert('Моля въведете email на лицето на контакти!');
				document.details.person_email.focus();
				return false;
			}
			else if( !(dd1=Exp1.exec(document.details.person_email.value)) ){
					alert('Моля въведете валиден email!');
					document.details.person_email.focus();
					return false;
			}

			
		
			document.details.sub.value = 1;
			document.details.submit();
	
}//end func


function delLogo(val){

	if (c = confirm("Сигурни ли сте че искате да изтриете логото на компанията?"))
	{
		document.details.del.value = val;
		document.details.submit();
	}
	
}//end func

function delImg(val){

	if (c = confirm("Сигурни ли сте че искате да изтриете снимката си?"))
	{
		document.cv.del.value = val;
		document.cv.submit();
	}
	
}//end func


function clearChosenCVs(){
	if (c=confirm("Сигурни ли сте че искате да изтриете целия списък?"))
	{
		window.location.href="clear_all_chosen_cvs.php";
	}
}//end func

function clearOneCV(val, file){
	if (c=confirm("Сигурни ли сте че искате да изтриете тази автобиография от своя списък?"))
	{
		window.location.href="remove_cv.php?cv=" + val + "&url=" + file;
	}
}



function addAnnouncement(){
			Exp=/^[0-9]+$/;

			odescription_bg.updateData(true);
			odescription_en.updateData(true);


			if(document.announcement.title_bg.value == ''){
				alert('Моля въведете заглавие!');
				document.announcement.title_bg.focus();
				return false;
			}

			if(document.announcement.title_en.value == ''){
				alert('Моля въведете заглавие на английски!');
				document.announcement.title_en.focus();
				return false;
			}

			if(document.announcement.description_bg.value == ''){
				alert('Моля въведете описание!');
				document.announcement.description_bg.focus();
				return false;
			}

			if (document.announcement.month.value && document.announcement.year.value){
				hour		= document.announcement.hour.value;
				hour_int	= parseInt(hour);
				min			= document.announcement.min.value;
				min_int		= parseInt(min);
				
				if (hour && hour!= '00' &&  (isNaN(hour) || !(hour_int>=1 && hour_int<=24))){
					alert('Моля въведете коректен час, той трябва да е число между 1 и 24!');
					document.announcement.hour.focus();
					return false;
				}
			
				if (min &&  min!= '00' && (isNaN(min) || !(min_int>=1 && min_int<=60))){
					alert('Моля въведете коректни минути,трябва да са число между 1 и 60!');
					document.announcement.min.focus();
					return false;
				}
				
			}//end if

			document.getElementById('num_chosen_langs').value	= num_langs_ids;
		
			document.announcement.sub.value = 1;
			document.announcement.submit();
	
}//end func


function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	
	return curtop;
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	
	return curleft;
}

function disableDiv(){

	div = document.getElementById('main_frame1');
	flag = document.getElementById('normal');

	if (!div) return;

	div1 = document.getElementById('none_print');

	if (div1){
		
		if (flag){
			div1.style.height = div.clientHeight;
		}
		else div1.style.height = div.clientHeight - 50;

		div1.style.width = div.clientWidth;

		div1.style.top = findPosY(div);
		div1.style.left = findPosX(div);
	}
}