function openArchive(nr){
	window.open('index.php?idziar='+nr);
}
function sendComment() {
	var title = document.getElementById('title');
	var name = document.getElementById('name');
	var email = document.getElementById('email2');
	var comment = document.getElementById('comment');
	
	var err = false;
	var msg = '';
	if (title.value == '') {
		msg = msg + 'Trebuie sa adaugati titlu!\n';
		err =  true;
	}
	if (name.value == '') {
		msg = msg + 'Trebuie sa adaugati numele!\n';
		err =  true;
	}
	
	if (email.value == '') {
		msg = msg + 'Trebuie sa adaugati adresa e-mail!\n';
		err =  true;
	} else if (!echeck(email.value)) {
		msg = msg + 'Trebuie sa adaugati adresa e-mail!\n';
	}

	if (comment.value == '') {
		msg = msg + 'Trebuie sa adaugati comentariul!\n';
		err =  true;
	}
	frm = document.form2;
	if (err) {
		alert('Comentariul nu poate fi adaugat:\n' + msg);
		return false;
	} else frm.submit();

}

	
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 Address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		 //  alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		 //   alert("Invalid E-mail Address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   // alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   // alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		  // alert("Invalid E-mail Address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		   //// alert("Invalid E-mail Address")
		    return false
		 }

 		 return true					
	}
function validateNewsletter() {
		var err = false;
		var e = document.getElementById('email2').value;
		if (e=='') { alert ('You have to provide an email address');return false;}
		else if (!echeck(e)) err = true;
		
		if (!err) {
			var frm =document.form2;
			frm.submit();
		}
		
	}
function validateUnsubscribe() {
	var email = document.getElementById('email2').value;
	if (echeck(email)) {
		frm = document.getElementById('form2');
		frm.submit();
	}
}

function validateSubscription() {
	var fname = document.getElementById('fname');
	var lname = document.getElementById('lname');
//	var username = document.getElementById('username');
//	var password = document.getElementById('password');
	var email = document.getElementById('email2');
	var phone = document.getElementById('phone');
	var address = document.getElementById('address');
	var date =  document.getElementById('startDate');
	
	var msg = "";
	var err = false;
	
	if (fname.value == "") {
		msg = msg + " You have to provide the First Name \n";
		err = true;
	}
	if (lname.value == "") {
		msg = msg + " You have to provide the Last Name \n";
		err = true;
	}
//	if (username.value == "") {
//		msg = msg + " You have to provide the Username \n";
//		err = true;
//	}
//	if (password.value == "") {
//		msg = msg + " You have to provide the Password \n";
//		err = true;
//	}
	if (email.value == "") {
		msg = msg + " You have to provide the Email \n";
		err = true;
	} else {
		if (!echeck(email.value)) err = true;
	}
	
	if (phone.value == "") {
		msg = msg + " You have to provide the Phone \n";
		err = true;
	}
	if (address.value == "") {
		msg = msg + " You have to provide the Address \n";
		err = true;
	}
	if (date.value == "") {
		msg = msg + " You have to provide the Starting Date for the Subscription\n";
		err = true;
	}
	
	if (err) {if (msg != "") alert (msg);}
	else {
		frm = document.getElementById('form2');
		frm.submit();
	}
}	

function showFullSizeH(poza){ 

	openPictureWindow('uploaded_images/'+poza, 450, 350, 'Full Size Image'); 

} 

function openPictureWindow(imageName,imageWidth,imageHeight,alt) 

{ 

x=screen.availWidth

y=screen.availHeight

	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+',top='+(y-358)/2 +',left='+(x-400)/2); 

	newWindow.document.open(); 

	newWindow.document.write('<HTML><HEAD><LINK href="styles/all.css" type=text/css rel=stylesheet><TITLE>'+alt+'</TITLE>');



newWindow.document.write('</head>');

	newWindow.document.write('<BODY bgcolor="#FFFFFF" LEFTMARGIN="0" TOPMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0" onBlur="self.focus()">'); 

	

	

	newWindow.document.write('<table width="100%" border="0" align="center" cellspacing="0" cellpadding="0" height="350">');

	//newWindow.document.write('<tr>');

  // 	newWindow.document.write('<td bgcolor="#38406B" height="28" align="right"><img src="images/top_popup.jpg" width="200"  height="30"></td></tr>');

	newWindow.document.write('<tr>');

	newWindow.document.write('<td colspan="2" height="300" align="center">');

	

		newWindow.document.write('<IMG SRC='+imageName+' WIDTH=400 HEIGHT=300 ALT="'+alt+'"></td>');



	

	newWindow.document.write('</tr>');

	newWindow.document.write('<tr bgcolor="#7383BB">');

    newWindow.document.write('<td colspan="2" height="35" align="center" valign="middle" ><img src="images/transparent.gif" width="4" height="20"><a href="javascript:window.close();"><font color="white">close</font></a></td>');

	newWindow.document.write('</tr>');

	newWindow.document.write('</table>');

	

	

	

	newWindow.document.write('</BODY></HTML>'); 

	newWindow.document.close(); 

	newWindow.focus(); 

} 

function showFullSizeV(poza){ 

	openPictureWindowV('uploaded_images/'+ poza, 255, 394, 'Full Size Image'); 

} 

function openPictureWindowV(imageNameV,imageWidthV,imageHeightV,altV) 

{ 

x=screen.availWidth

y=screen.availHeight

	newWindow = window.open("","newWindow","width="+imageWidthV+",height="+imageHeightV+',top='+(y-358)/2 +',left='+(x-520)/2); 

	newWindow.document.open(); 

	newWindow.document.write('<HTML><HEAD><TITLE>'+altV+'</TITLE>');



newWindow.document.write('</head>');

	newWindow.document.write('<BODY bgcolor="#FFFFFF" LEFTMARGIN="0" TOPMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0" onBlur="self.focus()">'); 

	

	

	newWindow.document.write('<table width="255" border="0" cellspacing="0" cellpadding="0" height="390">');

	newWindow.document.write('<tr>');

   	newWindow.document.write('<td bgcolor="#38406B" height="28" align="right"><img src="images/top_popup.jpg" width="200"  height="30"></td></tr>');

	newWindow.document.write('<tr>');

	newWindow.document.write('<td colspan="2" height="340">');

	

		newWindow.document.write('<IMG SRC='+imageNameV+' WIDTH=255 HEIGHT=340 ALT="'+altV+'"></td>');



	

	newWindow.document.write('</tr>');

	newWindow.document.write('<tr bgcolor="#38406B">');

    newWindow.document.write('<td colspan="2" height="18" align="right" valign="middle" ><img src="images/spacer_albastru.jpg" width="4" height="20"><a href="javascript:window.close();"><font color="white">close</font></a></td>');

	newWindow.document.write('</tr>');

	newWindow.document.write('</table>');

	

	

	

	newWindow.document.write('</BODY></HTML>'); 

	newWindow.document.close(); 

	newWindow.focus(); 

} 

// end dHTML SlideShow Script

function viewPicture2(id,width, height) {
	window.open('viewPicture2.php?idpicture=' + id,'','width='+ width+',height='+ height +',scrollbars=yes');
}

function addMonth() {
	var type = document.getElementById('status');
	var period = document.getElementById('period');
	
	period.length = 0;
	var start = 0;
	if (type.options[type.selectedIndex].value==1) {
		period.options[0] = new Option ('1 Month',1,false,false);
		start = 1;
	}
	period.options[start] = new Option ('3 Months',2,false,false);
	period.options[start+1] = new Option ('6 Months',3,false,false);
	period.options[start+2] = new Option ('12 Months',4,false,false);
}

/*parameter: po_object = select object*/

function opt_disabled()
{
	
	var po_object = document.getElementById('category');
	try
	{
		var li_selIndex = po_object.selectedIndex; 
	
	if(po_object.options[li_selIndex].disabled)
	{
		//po_object.options[li_selIndex].style.color = 'graytext';

		if(!po_object.previousIndex)
		{
			po_object.previousIndex =0;
		} 
	
	if(po_object.previousIndex > li_selIndex)
	{
		li_selIndex-=1;
	}
	else
	{
		li_selIndex+=1;
	} 
	
	if(po_object.options[li_selIndex]!=null)
	{
		po_object.selectedIndex=li_selIndex;
	}
	else
	{
		po_object.selectedIndex = 0;
	}
		po_object.previousIndex = po_object.selectedIndex;
	}
	return true;
	}
		catch(e){alert(e.description)}
	} 


