function checkShareThis(){
	if( !isEmail(document.getElementById('txtEmail').value) ){
		//document.getElementById('txtEmail').className = 'error';
		document.getElementById('div_error_share').className = 'div_error_share_display';
		return false;
	}else{
		document.getElementById('div_error_share').className = 'div_error_share_none';
	}
	
	document.fromShareThis.submit();
	return true;
}

function checkMailingList(){
	if( !isEmail(document.getElementById('txtMailingList').value) ){
		document.getElementById('div_error').className = 'div_error_display';
		document.getElementById('imgValid').src = 'images/none.jpg';

		return false;
	}else{
		document.getElementById('div_error').className = 'div_error_none';
		document.getElementById('imgValid').src = 'images/valid.jpg';
	}
	
	document.fromMailingList.submit();
	return true;
}

function setThankYou(){
	document.getElementById('div_thankyou').innerHTML = '';
}

function setText(obj, value){
	document.getElementById('imgValid').src = 'images/valid.jpg';
	document.getElementById('div_error').className = 'div_error_none';
	document.getElementById('txtMailingList').className = 'normal';	
	
	if(value == '1'){
		if(obj.value=='') {
			obj.value='Enter your e-mail address';
			document.getElementById('txtMailingList').className = 'default';
		}// end if
	}
	else{
		if(obj.value=='Enter your e-mail address' || obj.value=='THANK YOU') {
			obj.value='';
		}// end if
	} // end if
	
}// end funciton

function show_email_popup(popup_id)
{
	
	
	var popup_obj = document.getElementById(popup_id);
	if(popup_obj.className == 'popup_hidden')
	{
		showAlertLayer();
		popup_obj.className = 'popup';
		document.getElementById('txtContent').value = content_sharethis;
		document.getElementById('txtEmail').value = '';
		document.getElementById('div_error_share').className = 'div_error_share_none';
	}
	else
	{
		hideAlertLayer();
		popup_obj.className = 'popup_hidden';
		document.getElementById('div_thankyou').innerHTML = '';
	}
}
function getPageSize()
{
	var body_width = document.getElementById('container_id').offsetWidth+35;
	arrayPageSize = new Array(body_width,document.body.clientHeight+document.body.scrollTop+140) 
	return arrayPageSize;
}
function showAlertLayer()
{
	var arrayPageSize = getPageSize();

	// setup the dividers
	var BodyObject = document.getElementsByTagName("body").item(0);	

	// setup bg alert layer	
	var OverlayObject = document.getElementById('da_overlay');
	if (!OverlayObject)
		OverlayObject = document.createElement("div");
	obj_div_over = OverlayObject;
	OverlayObject.setAttribute('id','da_overlay');
	OverlayObject.style.width = arrayPageSize[0] + "px";
	OverlayObject.style.height = (arrayPageSize[1]) + 'px';
	OverlayObject.style.left = '0px';
	OverlayObject.style.top = '0px';
	OverlayObject.style.position = "absolute";
	OverlayObject.style.backgroundColor = "#ffffff";
	//OverlayObject.style.backgroundColor = "#000000";
	OverlayObject.style.zIndex = 100;
	OverlayObject.onclick = closePopupShare;
	OverlayObject.style.filter = "alpha(opacity=65)";
	OverlayObject.style.mozOpacity = ".65";
	OverlayObject.style.opacity = ".65";
	OverlayObject.style.display = "block";

	// setup content alert layer
	
	BodyObject.appendChild(OverlayObject);
	
}		

function closePopupShare(){
	show_email_popup('popup')
}

function hideAlertLayer()
{
	var OverlayObject = document.getElementById('da_overlay');
	if(OverlayObject)
	{
		OverlayObject.style.width = "0px";
		OverlayObject.style.height = "0px";
		OverlayObject.style.left = '0px';
		OverlayObject.style.top = '0px';
		OverlayObject.style.backgroundColor = "#000000";
		OverlayObject.style.zindex = "0";
		OverlayObject.style.filter = "alpha(opacity=0)";
		OverlayObject.style.mozOpacity = ".0";
		OverlayObject.style.opacity = ".0";
		OverlayObject.style.display = "none";
	}
}
function isEmail(s)
{   
	s=s.toLowerCase();
	if (s=="") return false;
	if(s.indexOf(" ")>0) return false;
	if(s.indexOf(".")==0) return false;
	if(s.indexOf("@")==0) return false;
	if(s.indexOf("@")==-1) return false;
	if (s.indexOf(".")==-1) return false;
	if (s.indexOf("..")!=-1) return false;
	if (s.charAt(s.indexOf("@")-1)=='.' ) return false;
	if (s.indexOf("@")!=s.lastIndexOf("@")) return false;
	if (s.indexOf("@") == s.length-1) return false;
	if (s.lastIndexOf(".")==s.length-1) return false;
	var str="abcdefghikjlmnopqrstuvwxyz-@._0123456789"; 
	for(var i=0;i<s.length;i++)
		if(str.indexOf(s.charAt(i))==-1)
			return false;
	return true;
}