function CheckEmail(sEmail){
	str = document.getElementById(sEmail).value;
	var Errors = false;
	var Emailerrors = false;
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if(str == ""){
		Emailerrors = true;	
	}
	if (str.indexOf(at)==-1){
	  Emailerrors = true;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   Emailerrors = true;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		Emailerrors = true;
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		Emailerrors = true;
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		Emailerrors = true;
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		Emailerrors = true;
	 }
	
	 if (str.indexOf(" ")!=-1){
		Emailerrors = true;
	 }
	 if(Emailerrors){
		//alert("Sorry, your email address is invalid!");
		alert("Sorry, your email address is invalid!");
		//Errors = true;
		return false;
	 }else{
		return true;	 
	 }
}
function CheckFields(sFields){
	var errors = false;
	var ErrorMsg = "Please enter your:\n\n";
	var temp = 0;
	ElementArr = sFields.split("|");
	for(i=0; i<ElementArr.length; i++){
		if(!document.getElementById(ElementArr[i]).value){
			ErrorMsg += ElementArr[i] + "\n";
			errors = true;
		}
	}
	if(errors == true){
		alert(ErrorMsg);
		//FieldFocus("UserName");
		//document.getElementById("CheckMark").style.display = 'none';
		return false;
	}else{
		if(sFields.indexOf("Email") != -1){
			var validEmail = CheckEmail("Email");
			if(!validEmail){
				return false;	
			}else{
				return true;	
			}
		}else{	
			return true;
		}
	}
}
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}

	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}
function removeElement(parentID,elementID){
	var parent = document.getElementById(parentID);
	var child = document.getElementById(elementID);
	
	parent.removeChild(child);
}
function addElement(parentID,elementID,elementType){
	var newElement = document.createElement(elementType);
	newElement.setAttribute('id',elementID);
	var parent = document.getElementById(parentID);
	
	parent.appendChild(newElement);
}
function showHide(element){
	var div = document.getElementById(element);
	var divStyle = div.style;
	
	if(divStyle.display == 'none'){
		divStyle.display = 'block';
	}else{
		divStyle.display = 'none';
	}
}
var newWin;
function tmt_winOpen(u,id,f,df){
	if(eval(id)==null||eval(id+".closed")){
	eval(id+"=window.open('"+u+"','"+id+"','"+f+"')");eval(id+".focus()");}
	else if(df){eval(id+".focus()");}
	else{eval(id+"=window.open('"+u+"','"+id+"','"+f+"')");eval(id+".focus()");}
}
