//
function is_email( Email )
{
	var i;
	var j;
	var StringLength;
	
	var FindDot;
	
	if ( Email == "" )
	{

		return false
	}
	
	

	i = Email.search("@");
	j = -1
	StringLength = Email.length;

	for ( n= i + 2 ; n <= StringLength - 2 ; n++)
	{
		FindDot = Email.substr( n , 1 )
		if (FindDot == "." )
			j = n
	}			
			
	if ( i == -1 || j == -1)
	{

		return false;
	}

	return true
}

function popup( url, options )
{

	popup_window = window.open( url,'popup_window', options )
	popup_window.focus()
}

function checkObj(name)
{
	if (document.getElementById)
  	{ 	
  		if ( document.getElementById(name) != undefined )
  			return true
		
  	}
  	else if (document.all)
  	{
		if( document.all[name] != undefined )
			return true
  	}
  	else if (document.layers)
  	{
  		if( document.layers[name] != undefined )
			return true
  	}
  	
  	return false
}

function getObj(name)
{
	if (document.getElementById)
  	{ 	
  		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
  	}
  	else if (document.all)
  	{
		this.obj = document.all[name];
		this.style = document.all[name].style;
  	}
  	else if (document.layers)
  	{
   		this.obj = document.layers[name];
   		this.style = document.layers[name];
  	}
}

//thanks to apple http://developer.apple.com/internet/webcontent/xmlhttpreq.html for these scripts

var isIE = false;

function getElementTextNS(prefix, local, parentElem, index) {
    var result = "";

    if (window.ActiveXObject) {
        isIE = true;
    }	

    if (prefix && isIE) {
        // IE/Windows way of handling namespaces
        result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
    } else {
        // the namespace versions of this method 
        // (getElementsByTagNameNS()) operate
        // differently in Safari and Mozilla, but both
        // return value with just local name, provided 
        // there aren't conflicts with non-namespace element
        // names
        result = parentElem.getElementsByTagName(local)[index];
    }
    if (result) {
        // get text, accounting for possible
        // whitespace (carriage return) text nodes 
        if (result.childNodes.length > 1) {
            return result.childNodes[1].nodeValue;
        } else {
            return result.firstChild.nodeValue;    		
        }
    } else {
        return "n/a";
    }
}

function getXMLObj() {

     var req

	req = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest) 
    {
    	try {
		req = new XMLHttpRequest();
       	} catch(e) {
			req = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
	}
    }

    return req	
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function autoResize(id){
    var newheight;
    var newwidth;

    if(document.getElementById){
        newheight=document.getElementById(id).contentWindow.document .body.scrollHeight;
        newwidth=document.getElementById(id).contentWindow.document .body.scrollWidth;
    }

    document.getElementById(id).height= (newheight) + "px";
    document.getElementById(id).width= (newwidth) + "px";
    
    return newheight;
}

function addslashes(str) {
str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\0/g,'\\0');
return str;
}
function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\\\/g,'\\');
str=str.replace(/\\0/g,'\0');
return str;
}

if ( !window.set_date )
{

	function set_date( o, funct )
	{
		obj_focus = o
	
		popup('/include/calendar-insert.php?month=' + o[1][ o[1].selectedIndex ].value + '&year=' + o[2][ o[2].selectedIndex ].value, 'width=200,height=230');

		call_funct = funct

	}
}

function insert_date()
{
	var argv = insert_date.arguments;

	for( k=0; k<=2; k++ )
	{

		for( i=0; i<obj_focus[k].length; i++ )
		{
			if ( Number(obj_focus[k][i].value) == argv[k] )
			{
				obj_focus[k].selectedIndex = i
				break;
			}
		}
	}

	if ( call_funct != '' )
	{
		eval( call_funct )
	}
}

function getWidth()
{
	return document.body.clientWidth;
}

function getHeight()
{
	if (document.all)
	{
		return document.body.offsetHeight.toString();
	}
	else
	{
		return document.documentElement.offsetHeight.toString();
	}
}




