function checkemail(frm){
	var str=frm.email.value;
//	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	atpos = str.indexOf("@"); //5
	stoppos = str.lastIndexOf("."); //6

	
	if (stoppos > 0 && atpos > 0 && stoppos > atpos && stoppos - atpos > 1)
		ck=true
	else{
		alert("Please input a valid email address!")
		ck=false
	}
	return ck;
}

function check_join_campaign(frm){
	var fsub = true, err, ctr=0, fld_focus;
	var err = "The ff fields must not be empty/invalid: \n\n";

	if(frm.join_campaign_email.value.length < 1 || frm.join_campaign_email.value.indexOf('@') == -1){
		if(fsub == true) fld_focus = frm.join_campaign_email;
		fsub = false;
		err += ++ctr+". Email \n";
	}
	if(frm.join_campaign_zip.value.length < 1 || frm.join_campaign_zip.value == 'zip'){
		if(fsub == true) fld_focus = frm.join_campaign_zip;
		fsub = false;
		err += ++ctr+". Zip \n";
	}
	
	if(fsub == false){
		alert(err);
		fld_focus.focus();
	}
	return(fsub);
}

function check_post_comment(frm){
	var fsub = true, err, ctr=0, fld_focus;
	var err = "The ff fields must not be empty/invalid: \n\n";

	if(frm.comment_name.value.length < 1){
		if(fsub == true) fld_focus = frm.comment_name;
		fsub = false;
		err += ++ctr+". Name \n";
	}
	if(frm.comment_email.value.length < 1 || frm.comment_email.value.indexOf('@') == -1){
		if(fsub == true) fld_focus = frm.comment_email;
		fsub = false;
		err += ++ctr+". Email \n";
	}
	if(frm.comment_comment.value.length < 1){
		if(fsub == true) fld_focus = frm.comment_comment;
		fsub = false;
		err += ++ctr+". Comment \n";
	}
	
	if(fsub == false){
		alert(err);
		fld_focus.focus();
	}
	return(fsub);
}
//	alert('test');
//function check_employment(frm){
//	alert('test');
//}



function textAreaLimit(limitField, limitCount, limitNum) 
{
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} 
	else {
		limitCount.value = limitNum - limitField.value.length;
	}
//	alert(limitField.value.length+' > '+limitNum);
}

function check_not_empty(elem, frm){
	if(elem.value.length < 1){
		alert('You can\'t send empty content!');
		return false;
	}
	else if(elem.value.length < 3){
		alert('Your content is too short!');
		return false;
	}
	else{
		return true;
	}
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

//	document.getElementById(id).style.display = '';
	
    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
	
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	//alert(opacity);
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
	
	if(opacity == 0) document.getElementById(id).style.display = 'none';
	if(opacity > 0) document.getElementById(id).style.display = '';
}

function check_emailform(frm){

	var fsub = true, err, ctr=0, fld_focus;
	var err = "The ff are either empty or invalid: \n\n";
	
	if(frm.email_name_owner.value.length < 1){
		if(fsub == true) fld_focus = frm.email_name_owner;
		fsub = false;
		err += ++ctr+". Your Name \n";
	}
	if(frm.email_owner.value.length < 1){
		if(fsub == true) fld_focus = frm.email_owner;
		fsub = false;
		err += ++ctr+". Your Email \n";
	}
	if(frm.email_name.value.length < 1){
		if(fsub == true) fld_focus = frm.email_name;
		fsub = false;
		err += ++ctr+". Friend's Name \n";
	}
	if(frm.email_email.value.length < 1 || frm.email_email.value.indexOf('@') == -1 || frm.email_email.value.indexOf('.') == -1){
		if(fsub == true) fld_focus = frm.email_email;
		fsub = false;
		err += ++ctr+". Friend's Email \n";
	}
	if(frm.email_comment.value.length < 1){
		if(fsub == true) fld_focus = frm.email_comment;
		fsub = false;
		err += ++ctr+". Message \n";
	}

	if(fsub == false){
		alert(err);
		fld_focus.focus();
	}
	return(fsub);

}

function image_view(url, width, height){
	img = window.open (url, "mywindow","menubar=1,resizable=1,screenX=100,screenY=100,width="+width+",height="+height);
	img.focus();	
}
function url_view(url, width, height){
	img = window.open (url, "mywindow","menubar=1,resizable=1,screenX=100,screenY=100,width="+width+",height="+height);
	img.focus();	
}

function getWinHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
	return(myHeight);
}

function adjust_centro2_height(){
	
	var win_height = getWinHeight();
	var excess_height = 388;

	var centro2_height = win_height - excess_height;
	
	//alert('win_height = '+win_height+"\n"+'excess_height = '+excess_height+"\n"+'adj to centro2_height = '+centro2_height);
	
	document.getElementById('centro2').style.minHeight = centro2_height+'px';
	
	/*if(centro2_height > document.getElementById('centro2').height){
		document.getElementById('centro2').height = centro2_height+'px';
	}*/

}
