function checkContactForm(){
	var c1 = document.getElementById('rec_name').value;
	var c2 = document.getElementById('rec_mail').value;
	var c3 = document.getElementById('rec_message').value;
	if(c1 == ''){
		alert('Please enter your name.');
		return false;
	}
	if(c2 == ''){
		alert('Please enter your e-mail address.');
		return false;
	}
	if(!c2.match(/^(\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+)?$/)){
		alert('The e-mail address is invalid.');
		return false;
	}
	if(c3 == ''){
		alert('Please enter your message.');
		return false;
	}
	
	return true;
	
	
}


function hideFormElement(name){
	var a1 = document.getElementById(name + '_suport');
	var a2 = document.getElementById(name + '_spacer');
	
	if(a1) hidee(name + '_suport');
	if(a2) hidee(name + '_spacer');
}

function showFormElement(name){
	var a1 = document.getElementById(name + '_suport');
	var a2 = document.getElementById(name + '_spacer');
	
	if(a1) showw(name + '_suport');
	if(a2) showw(name + '_spacer');
}

function hideFormElements(names){
	var a = names.split(',');
	for(var i=0;i<a.length;i++){
		hideFormElement(a[i]);
	}
}

function showFormElements(names){
	var a = names.split(',');
	for(var i=0;i<a.length;i++){
		showFormElement(a[i]);
	}
}





function dateToi(a){
	var temp = a.split("-");
	var y = 0 + parseFloat(temp[0]);
	var m = 0 + parseFloat(temp[1]);
	var d = 0 + parseFloat(temp[2]);
	var ret = y.toString() + m.toString() + d.toString();
	//alert(ret);
	return ret;
}

function fitInWindow(button,target){
	var btn = document.getElementById(button);
	var tar = document.getElementById(target);
	
	var tar_w = tar.offsetWidth;
	var tar_h = tar.offsetHeight;
	var tar_x = getAbsoluteLeft(target);
	var tar_y = getAbsoluteTop(target);
	//alert(tar_x+'x'+tar_y+'-------'+tar_w+'x'+tar_h)
	var btn_w = btn.offsetWidth;
	var btn_h = btn.offsetHeight;
	var btn_x = getAbsoluteLeft(button);
	var btn_y = getAbsoluteTop(button);
	
	var winsize = getWindowSize();
	//alert(winsize);

	if(btn_w + btn_x + tar_w > winsize[0]){
		tar_x = winsize[0] - tar_w-5;
	}else{
		tar_x = btn_x + btn_w;
	}
	
	if(btn_h + btn_y +  + tar_h > winsize[1]){
		tar_y = winsize[1] - tar_h-5;
	}else{
		tar_y = btn_y;
	}
	
	tar.style.left = tar_x;
	tar.style.top = tar_y;
}

function autoResizeMe(me){
//	var daform = document.getElementById(me+'_suport');
//	var h = getElementHeight(me+'_suport');
//	alert(h);
	
	var content = document.getElementById('suport_pentru_resize_123');
	alert(content.offsetHeight);
	window.resizeTo(content.offsetWidth + 30, content.offsetHeight + 50);	
	
	
}

function getElementHeight(Elem) {
	
		
		
			var elem = document.getElementById(Elem);
		 
			xPos = elem.style.pixelHeight;
		
			//xPos = elem.offsetHeight;
		
		return xPos;
	
}



function getWindowSize(){
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winW = window.innerWidth;
	  winH = window.innerHeight;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth;
	  winH = document.body.offsetHeight;
	 }
	}
	return [winW,winH];
}





function FitPic() { 
 	var NS = (navigator.appName=="Netscape")?true:false; 	
   iWidth = (NS)?window.innerWidth:document.body.clientWidth; 
   iHeight = (NS)?window.innerHeight:document.body.clientHeight; 
   iWidth = document.images[0].width - iWidth; 
   iHeight = document.images[0].height - iHeight+53; 
   window.resizeBy(iWidth, iHeight); 
   self.focus(); 
} 

function changevar(varname,td){
	var obj = document.getElementById(varname);	
	var val = obj.value;
	if(val==0) td.className='selectorr_on';
	if(val==1) td.className='selectorr_off';
	obj.value=1-val;
}


function getComboValue(controlname){
	return document.getElementById(controlname).options[document.getElementById(controlname).selectedIndex].value;
}

function getAbsoluteLeft(objectId) {
	// Get an object left position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId)
	oLeft = o.offsetLeft            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent    // Get parent object reference
		oLeft += oParent.offsetLeft // Add parent left position
		o = oParent
	}
	// Return left postion
	return oLeft
}

function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId)
	oTop = o.offsetTop            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent  // Get parent object reference
		oTop += oParent.offsetTop // Add parent top position
		o = oParent
	}
	// Return top position
	return oTop
}

function getPositionTop(obj){
var el = obj;var pT = 0;
while(el){pT+=el.offsetTop;el=el.offsetParent;}
return pT
}
function getPositionLeft(obj){
var el = obj;var pL = 0;
while(el){pL+=el.offsetLeft;el=el.offsetParent;}
return pL
}

