function change_class(id, class_name) {

	x = document.getElementById(id);
	x.className = class_name;
	
}

function goto_page(page) {
	document.location.href = page;
}

function validate_newsletter() {
	var submit_ok = new Boolean;
	submit_ok = true;
	
	var y = document.getElementById('email');
	var email_test = /^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i
	if (!email_test.test(y.value)) {
		alert('Input must be a valid email adrress');
		submit_ok = false;
	}
	
	var x = document.getElementById('acord');
	if (!x.checked) {
		alert('Trebuie sa fiti de acord sa primiti newsletter');
		submit_ok = false;
	}
	
	if (submit_ok) {
		document.getElementById('newsletter_form').submit();
	}
}

function validate_contact() {
	var submit_ok = new Boolean;
	submit_ok = true;
	
	var x = document.getElementById('contact_name');
	if (x.value=="") {
		alert('Va rog introduceti numele dvs!');
		submit_ok = false;
	}
	
	var z = document.getElementById('contact_tel');
	var tel_test = /^((\d{4}(-| )?\(?\d\)?(-| )?\d{1,6})|(\(?\d{2,6}\)?))(-| )?(\d{3})(-| )?(\d{3})(( x| ext)\d{1,5}){0,1}$/
	if (!tel_test.test(z.value)) {
		alert('Numarul de telefon introdus nu este valid!');
		submit_ok = false;
	}
	
	var y = document.getElementById('contact_email');
	var email_test = /^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i
	if (!email_test.test(y.value)) {
		alert('Input must be a valid email adrress');
		submit_ok = false;
	}
	
	if (submit_ok) {
		document.getElementById('contact_form').submit();
	}
}

function highlight(id, on_off) {
		var x = document.getElementById(id);
		if (on_off==1) {
			x.style.borderColor = "#be323c";
			x.style.textDecoration = "underline";
			/*if (document.all) {
				var z = x.getElementsByTagName('a')[0];
				if (z.style) {
					z.style.textDecoration = "underline";
				}
			}*/
		} else {
			x.style.borderColor = "#c2c1c1";
			x.style.textDecoration = "none";
			/*if (document.all) {
				var z = x.getElementsByTagName('a')[0];
				if (z.style) {
					z.style.textDecoration = "none";
				}
			}*/
		}	
}

function highlight_invers(id, on_off) {
		var x = document.getElementById(id);
		if (on_off==1) {
			x.style.borderColor = "#c2c1c1";
			x.style.backgroundColor = "#c2c1c1";
			x.style.textDecoration = "none";
			id_a = id+'_a';
			var z = document.getElementById(id_a);
			z.className = 'white_link_hover';
		} else {
			x.style.borderColor = "#be323c";
			x.style.backgroundColor = "#be323c";
			x.style.textDecoration = "none";
			id_a = id+'_a';
			var z = document.getElementById(id_a);
			z.className = 'white_link';
		}	
}

function open_pic(imgSrc, url) {
	window.open( url+"/popup.htm?"+imgSrc, "", "resizable=1,HEIGHT=200,WIDTH=200");
}

function opt_click(id, total, index, on_off) {
	if (id=="**ALL**") {
		for (var i=0; i<total; i++) {
			var temp_id = "opt_"+i;
			var temp_id_link = temp_id+"_link";
			var x=document.getElementById(temp_id);
			var y=document.getElementById(temp_id_link);
			if (on_off==1) {
				x.style.display='block';
				y.title='close';
			} else {
				x.style.display='none';
				y.title='open';
			}
		}
	} else {
		var id_link = id+"_link";
		var x=document.getElementById(id);
		var y=document.getElementById(id_link);
		if (y.title=="open") {
			x.style.display='block';
			y.title='close';
		} else {
			x.style.display='none';
			y.title='open';
		}
	}
	
	var bal_height_temp = document.getElementById('prod_pdf').offsetHeight + document.getElementById('prod_leiras').offsetHeight;
	var bal_height = bal_height_temp + document.getElementById('prod_car_text').offsetHeight;
	var jobb_height = document.getElementById('prod_pic').offsetHeight;
	
	var closed = true;
	for (var i=0; i<total; i++) {
		var temp_id = "opt_"+i;
		//var temp_li_id = "opt_li_"+i;
		var temp_id_link = temp_id+"_link";
		var x=document.getElementById(temp_id);
		//var z=document.getElementById(temp_li_id);
		var y=document.getElementById(temp_id_link);
		var w=x.getElementsByTagName('li');
		bal_height += y.offsetHeight;
		for (var j=0; j<w.length; j++) {
			if (y.title=='close') {
				closed = false;
				temp = w[j].offsetHeight;
				bal_height += temp;
				if (bal_height>jobb_height) {
					w[j].style.width='678px';
					bal_height -= temp;
					bal_height += w[j].offsetHeight;
				} else {
					w[j].style.width='315px';
				}
			}
		}
	}

	var opera = navigator.userAgent.indexOf("Opera")!='-1'?true:false;
	if (document.all && !opera) {
		var x2 = document.getElementById('prod_car');
		var w2 = document.getElementById('prod_car_text');
		var z2 = document.getElementById('prod_car_list');
		if ((bal_height>jobb_height) && (!closed)) {
			//var minus = jobb_height-bal_height_temp-8;
			x2.style.position="relative";
			w2.style.position="absolute";
			z2.style.position="absolute";
			w2.style.top=25;
			z2.style.top=103;
			x2.style.height = w2.offsetHeight + z2.offsetHeight;
		} else {
			x2.style.position="static";
			w2.style.position="static";
			z2.style.position="static";
			x2.style.height = w2.offsetHeight + z2.offsetHeight;
		}
	}
}