function checkblank(vvalue)
{
	var er = /^\s*$/
	if ( er.test(vvalue) )
		return true;
	
	return false;
}

function checkEmail(email) 
{
	var er = /^[\w-\.]+@([\w-]{2,}\.){1,2}[a-zA-Z]{2,4}$/
	if ( er.test(email) )
		return true;
	
	return false;	
}

function checkpassword(password)
{
	var er =/^\w{6,}$/
	if ( er.test(password) )
		return true;
	
	return false;
}

function validatePhone(phone)
{
	var phone = phone.replace(/\s|-|\(|\)/g,'');
	
	var er = /^\d{7,}$/
	if ( er.test(phone) )
		return true;
	
	return false;
}

function formatPhone(phone)
{
	phone = phone.replace(/\s|-|\(|\)/g,'');
	xLen = phone.length;
	xFormat = "1";
	
	newPhone = phone;	
	if (xLen == 7)
		newPhone = phone.substring(0,3) + "-" + phone.substring(3,7);
	
	if (xLen == 9)
	{
		if (xFormat == "1")
			newPhone = "(0" + phone.substring(0,2) + ") " + phone.substring(2,5) + "-" + phone.substring(5,9);
		
		if (xFormat == "2")
			newPhone = "0" + phone.substring(0,2) + "." + phone.substring(2,5) + "." + phone.substring(5,9);
		
		if (xFormat == "3")
			newPhone = "0" + phone.substring(0,2) + "-" + phone.substring(2,5) + "-" + phone.substring(5,9);
	}

	if (xLen == 10)
	{
		if (xFormat == "1")
			newPhone = "(" + phone.substring(0,3) + ") " + phone.substring(3,6) + "-" + phone.substring(6,10);
		
		if (xFormat == "2")
			newPhone = phone.substring(0,3) + "." + phone.substring(3,6) + "." + phone.substring(6,10);
		
		if (xFormat == "3")
			newPhone = phone.substring(0,3) + "-" + phone.substring(3,6) + "-" + phone.substring(6,10);
	}

	if (xLen == 11)
	{
		if (xFormat == "1")
			newPhone = phone.substring(0,1) + "(" + phone.substring(1,4) + ") " + phone.substring(4,7) + "-" + phone.substring(7,11);
		
		if (xFormat == "2")
			newPhone = phone.substring(0,1) + "." + phone.substring(1,4) + "." + phone.substring(4,7) + "." + phone.substring(7,11);
		
		if (xFormat == "3")
			newPhone = phone.substring(0,1) + "-" + phone.substring(1,4) + "-" + phone.substring(4,7) + "-" + phone.substring(7,11);
	}
	
	return newPhone;
}

function loadXML(xml)
{
	var validxml = false;
	if(window.ActiveXObject)
	{
		var doc = new ActiveXObject('Microsoft.XMLDOM');
		doc.async = false;

		var loaded = doc.loadXML(xml);
		if (loaded)
		{
			validxml = doc; //true;
		}
		else
		{
			validxml = false;
		}
	}
	else
	{
		var domParser = new DOMParser();

		var doc = domParser.parseFromString(xml,'application/xml');
		var parseError = checkForParseError(doc);
		if (parseError.errorCode == 0)
		{
			validxml = doc; //true;
		}
		else
		{
			validxml = false;
		}
	}
	
	return validxml;
}

function checkForParseError(xmlDocument)
{
	var errorNamespace = 'http://www.mozilla.org/newlayout/xml/parsererror.xml';
	var documentElement = xmlDocument.documentElement;
	var parseError = { errorCode : 0 };
	if (documentElement.nodeName == 'parsererror' && documentElement.namespaceURI == errorNamespace)
	{
		parseError.errorCode = 1;
		var sourceText = documentElement.getElementsByTagNameNS(errorNamespace, 'sourcetext')[0];
		if (sourceText != null)
		{
			parseError.srcText = sourceText.firstChild.data
		}
		parseError.reason = documentElement.firstChild.data;
	}
	return parseError;
}

function disabledEnabled(element,flag)
{
	var selectLists = document.getElementsByTagName(element);
	
	for (var i=0; i<selectLists.length; i++)
	   	selectLists[i].style.visibility = flag;
		
	return false;
}

function detectBrowser()
{
	var er = /Microsoft/i
	browsername = navigator.appName;
			
	browseversion = '';
	if ( browsername.search(er) != -1 ) 
	{
		appversion = navigator.appVersion;
		if (appversion.search(/7.0/) == - 1) 
			return true;
	}
	return false;
}

/*function windowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  arrayWindowSize = new Array(myWidth, myHeight);
  
  return arrayWindowSize;
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
}*/

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		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
		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 = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function getPosition(position,element)
{
	elemWidth = parseInt(element.style.width);
	elemHeight = parseInt(element.style.height);
	
	if ( position == 'width' ) 
		center = (document.body.clientWidth) ? (document.body.clientWidth-elemWidth)/2 : 0;
	else
		center = (document.body.clientHeight) ? ( (screen.availHeight) / 2 ) : 0;
		
	return center;
}	

function replaceString(value)
{
	oString = value.replace(/\]\[/g,'|');
	oString = oString.replace(/\[/g,'');	
	oString = oString.replace(/\]/g,'');
	
	return oString;
}

function valChars(vchar)
{
	if(vchar == "-")
	{
		vchar = "";
	}
	
	return vchar;
}


