// you will find all common javascript functions in this file

function $(id)
{		
	return document.getElementById(id);	
}

//FUNCTION :: SHOW VALIDATION ALERT MESSAGE
function showMsg(elmt_id, msg, empty)
{
	alert(msg);
	if(empty) $(elmt_id).value="";
	$(elmt_id).focus();	

}

//FUNCTION 1::TRIMMING A STRING (LEADING AND TRAILING SPACES ONLY)

function trimA(sString)
{
	if(sString && sString.length > 0)
	{
		while (sString.substring(0,1) == ' ')
		{
			sString = sString.substring(1, sString.length);
		}
		while (sString.substring(sString.length-1, sString.length) == ' ')
		{
			sString = sString.substring(0,sString.length-1);
		}
	}
	return sString;
}


//COUNTING THE INSTANCES OR REPITITION OF A SEARCH STRING OR CHARACTER IN THE GIVEN MAIN STRING

function countInstances(mainStr, srchStr) 
{
	var charCount = 0;
	var offset = 0;
	do {
		offset = mainStr.indexOf(srchStr, offset);
		charCount += (offset != -1) ? 1 : 0;
	} while (offset++ != -1)
	return charCount
}

//INNERTTRIM :: REPLACE MULTIPLE SPACES WITH A SINGLE SPACE
function innerTrim(str)
{
	return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
}

//REPLACE ONE OR MORE CHARACTERS/STRINGS WITH THE GIVEN REPLACEMENT STRING IN A STRING
//CAN BE USED TO REMOVE ALL SPACED IN A STRING
function replaceCharacters(conversionString,searchStr,replaceWith)
{
	
	  var convertedString = conversionString.split(searchStr);
	  convertedString = convertedString.join(replaceWith);
	  return convertedString;
	
}

function getShippingCarrierTrackingNoPattern(shippingCarrier, trk_no_len)
{
				
	var regex_pattern1=null;
	switch(shippingCarrier)
	{
		case "UPS"	 :
			
			if(trk_no_len && trk_no_len==18)
				regex_pattern1=/^(((1Z)((\s(\d{2}|[A-Z]{2})\d{1}\s\d{3}\s\d{2}\s\d{4}\s\d{3}\s\d{1})|(-(\d{2}|[A-Z]{2})\d{1}-\d{3}-\d{2}-\d{4}-\d{3}-\d{1})|([A-Z]{2}\d{14}))))$/; 
			//lengths withour space or - : 11, 12, 18
			//1Z-AC4-226-22-2222-222-2 OR 1Z-344-226-22-2222-222-2
			//1ZAC42262222222222 OR 1Z3442262222222222
			//1Z AC4 226 22 2222 222 2 OR 1Z 344 226 22 2222 222 2
			else if(trk_no_len && trk_no_len==12)
				regex_pattern1=/^(\d{4}\s\d{4}\s\d{4})|(\d{4}-\d{4}-\d{4})|\d{12}$/; 	//9999 9999 9999 or XXXXXXXXXXXX OR XXXX-XXXX-XXXX				
			else if(trk_no_len && trk_no_len==11)
				regex_pattern1=/^([A-Z]{1})((\d{3}\s\d{4}\s\d{3})|(\d{3}-\d{4}-\d{3})|\d{10})$/; //T999 9999 999, MXXXXXXXXXX or MXXX-XXXX-XXX
			
			break;
			
		case "USPS"	 :
			regex_pattern1=/^((\d{18}|\d{20})|((\d{2}|\d{4})(((\s\d{4}\s\d{4}\s\d{4}\s\d{4}))|((-\d{4}-\d{4}-\d{4}-\d{4})))))$/;
			//lengths withour space or - : 18, 20
			//0107 0000 0000 0000 0000
			//0207 0000 0000 0000 0000
			//91 0000 0000 0000 0000
			
			break;
		case "Fed Ex":
			regex_pattern1=/^((\d{10,12})|(\d{4}\s\d{4}\s(\d{4}|\d{2}))|(\d{4}-\d{4}-(\d{4}|\d{2})))$/;
			//lengths withour space or - : 10, 12
			//1234 5678 90
			//1234 5678 9012
			//1234-5678-9012
			//1234-5678-90
			//1234567890
			//123456789012
			break;
		case "DHL"	 :
			//regex_pattern1=/(([A-Z]{3})-[A-Z]{2}-(\d{7})|((([A-Z]{3}\s[A-Z]{2}\s)|[A-Z]{5})\d{7})|\d{10})/; 
			regex_pattern1=/^(([A-Z]{3})-[A-Z]{2}-(\d{7})|((([A-Z]{3}\s[A-Z]{2}\s)|([A-Z]{5}))\d{7})|\d{10}|(\d{3}((\s\d{3}\s\d{4})|(-\d{3}-\d{4}))))$/;
			//lengths withour space or - : 10, 12
			//FLR-EC-0071043
			//FLREC0071043
			//FLR EC 0071043
			//5556554545
			//343 343 3333
			//343-343-3333
			//3433433333
			break;
		
	}
	return regex_pattern1;
}

function RegExMatch(testString, pattern)
{
	var re = pattern;
	var result = testString.match(re);
	return result;
	
}	


//VALIDATE DATE

function checkDate(date_value) {
    var mo, day, yr;
   
    var re = /\b\d{1,2}[\/-]\d{1,2}[\/-]\d{4}\b/;
    if (re.test(date_value)) {
        var delimChar = (date_value.indexOf("/") != -1) ? "/" : "-";
        var delim1 = date_value.indexOf(delimChar);
        var delim2 = date_value.lastIndexOf(delimChar);
        mo = parseInt(date_value.substring(0, delim1), 10);
        day = parseInt(date_value.substring(delim1+1, delim2), 10);
        yr = parseInt(date_value.substring(delim2+1), 10);
        var testDate = new Date(yr, mo-1, day);
        //alert(testDate)
        if (testDate.getDate() == day) {
            if (testDate.getMonth() + 1 == mo) {
                if (testDate.getFullYear() == yr) {
                    return true;
                } else {
                    alert("There is a problem with the year entry.");
                }
            } else {
                alert("There is a problem with the month entry.");
            }
        } else {
            alert("There is a problem with the date entry.");
        }
    } else {
        alert("Incorrect date format. Enter as mm/dd/yyyy.");
    }
    return false;
}



 //==== EMAIL VALIDATION ============
 
function echeck(str) {
	var at = "@";
	var dot = ".";
	var lat = str.indexOf(at);
	var lstr = str.length;
	var ldot = str.indexOf(dot);
	
	if (str.indexOf(at) == -1){ return false; }
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ return false; }
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ return false; }
	if (str.indexOf(at,(lat+1))!=-1){ return false; }
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ return false; }
	if (str.indexOf(dot,(lat+2))==-1){ return false; }
	if (str.indexOf(" ")!=-1){ return false; }
	return true;					
}


// ANOTHER FUNCTION FOR VALIDATING EMAIL ADDRESS (USING REGULAR EXPRESSION)
function isEmail(str) {
    
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
        return false;
    } else {
        return true;
    }
}


//FIND THE DIFFERENCE BETWEEN TWO DATES IN DAYS (FINDS THE NUO OF DAYS BETWEEN TWO DATES)

function daysBetween(date1, date2) {
	if(!date2 || date2 == null) date2 = date1;
    var DSTAdjust = 0;
    oneMinute = 1000 * 60;// constants used for our calculations below
    var oneDay = oneMinute * 60 * 24;
    // equalize times in case date objects have them
    date1.setHours(0);
    date1.setMinutes(0);
    date1.setSeconds(0);
    date2.setHours(0);
    date2.setMinutes(0);
    date2.setSeconds(0);
    // take care of spans across Daylight Saving Time changes
    if (date2 > date1) {
        DSTAdjust = 
            (date2.getTimezoneOffset( ) - date1.getTimezoneOffset( )) * oneMinute;
    } else {
        DSTAdjust = 
            (date1.getTimezoneOffset( ) - date2.getTimezoneOffset( )) * oneMinute;    
    }
    //var diff = Math.abs(date2.getTime( ) - date1.getTime( )) - DSTAdjust;
	var diff = (date2.getTime( ) - date1.getTime( )) - DSTAdjust;
    return Math.ceil(diff/oneDay);
}


//CHECKS THE GIVEN DATE IF IT IS IN THE FUTURE AS COMPARED TO TODAY'S DATE
function checkDateIfinFuture(datePara)
{
	var today=new Date();
	var today_dd=today.getDate();
	var today_mm=today.getMonth();
	var today_yyyy=today.getFullYear();
	
	var checkDate_dd=datePara.getDate();
	var checkDate_mm=datePara.getMonth();
	var checkDate_yyyy=datePara.getFullYear();
	
	if(checkDate_yyyy>today_yyyy)
	{
		return false;
	}
	else if(checkDate_yyyy==today_yyyy && checkDate_mm>today_mm)
	{
		return false;
	}
	else if(checkDate_yyyy==today_yyyy && checkDate_mm==today_mm && checkDate_dd>today_dd)
	{
		return false;
	}
	else 
	{
		return true;
	}
}



//OPENING A POP-UP WINDOW FOR WITH THE GIVEN PAGE AND DIMENSIONS AND OTHER PARAMETERS
//OPEN A CENTERED WINDOW

var myWindow;
function openCenteredWindow(pageurl, width, height, title, scrollbar, menubar, toolbar, status, resizable) {
    
    var left = parseInt((screen.availWidth - width)/2);
    var top = parseInt((screen.availHeight - height)/2);
    var windowFeatures = "width=" + width + ", height=" + height + ", left=" + left + ",top=" + top + 
        ", screenX=" + left + ", screenY=" + top;
	
	if(scrollbar && scrollbar != null )
		windowFeatures += ", scrollbars=" + scrollbar;
		
	if(menubar && menubar != null )
		windowFeatures += ", menubar=" + menubar;
		
	if(toolbar && toolbar != null )
		windowFeatures += ", toolbar=" + toolbar;
	
	if(status && status != null)
		windowFeatures += ", status";
		
	if(resizable && resizable != null)
		windowFeatures += ", resizable,";
	
	title=replaceCharacters(title, ' ', '');
    myWindow = window.open(pageurl, title, windowFeatures);
}


//FORMATTING NUMBER IN THE FORMAT NUMBBER.DECIMAL

function formatNumber (num, decplaces) {
	// convert in case it arrives as a string value
   	num = parseFloat(num);
    // make sure it passes conversion
    if (!isNaN(num)) 
	{
		// multiply value by 10 to the decplaces power;
		// round the result to the nearest integer;
		// convert the result to a string
		var str = "" + Math.round (eval(num) * Math.pow(10,decplaces));
		// exponent means value is too big or small for this routine
		if (str.indexOf("e") != -1) {
			return "Out of Range";
		}
       	// if needed for small values, pad zeros to the left of the number
       	while (str.length <= decplaces) {
        	str = "0" + str;
       	}
       	// calculate decimal point position
       	var decpoint = str.length - decplaces;
       	// assemble final result from: (a) the string up to the position of the decimal point; 
       	// (b) the decimal point; and (c) the balance of the string. Return finished product.
       	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
    } 
	else 
	{
       	return "NaN";
    }
}




//DISPLAY AJAX POP UP WITH THE FOLLOWING FUNCTION WHICH HAS A MINIMIZE, CLOSE, RESTORE, STATUS BAR AND WINDOW MOVE FEATURES
//Required files:: 
// js:: dhtmlwindow.js
// images:: minimize.gif, close.gif, maximize.gif

function showInline(innerContent, title, width, height, left, top)
{	
	
	if(!width || width == null) width='390';
	if(!height || height == null) height='90';
	if(!left || left == null) left='310';
	if(!top || top == null) top='250';
	if(!title || title == null) title='';
	
	var inlinewin = dhtmlwindow.open("broadcastbox", "inline", innerContent, title, "width="+width+"px, height="+height+"px, left="+left+"px, top="+top+"px, resize=0, scrolling=0", "recal");
	inlinewin.show();

}



//GO TO THE SPECIFIED URL APPENDING THE REQUIRED(SUPPLIED) QUERYSTRING
//REPLACE ProjectID AND CampaignID WITH THE REQUIRED PARAMETERS

function goToUrl(url, qstring)
{
	var gotourl = arguments[0] + '.php';
	if(arguments[1] != ""){
		gotourl += '?ProjectID=' + arguments[1];	
	}
	if(arguments[2] != ""){
		gotourl += '&CampaignID=' + arguments[2];
	}
	document.location.href = gotourl;
}

//CONFIRM RECORD DELETE
function Do_Confirm(str){
	if(confirm(str))
		return true;
	else
		return false;
}



//FUNCTION FOR NULL CLICK: RETURN NULL
function NullClick(){
	return void(null);	
}


//TOGGLING THE CONTROL VIEW:: SHOW-HIDE
function ToggleView(obj,obj1) {
	var el = document.getElementById(obj);
	var key = document.getElementById(obj1);
	if(el.style.display != 'none'){
		el.style.display = 'none';
		key.innerHTML = "+";
	}
	else{
		el.style.display = '';
		key.innerHTML = "–";
	}
}


//FUNCTION TO RETRIVE THE QUERYSTRING FROM URL
function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for(var i = 0; i < vars.length; i++) {
		var pair = vars[i].split("=");
		if(pair[0] == variable){
			return pair[1];
		}
	} 
	alert('Query Variable ' + variable + ' not found');
}


//FUNCTION FOR GETTING COOKIES
//eg usage:: var styleCookie = getCookie("fontSize");
function getCookie(name){
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ';', len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}


//FUNCTION FOR SETTING COOKIES
//EG usage::setCookie("fontSize", 2, getExpDate(180, 0, 0));

function setCookie(name, value, expires, path, domain, secure ){
	var today = new Date();
	today.setTime( today.getTime() );
	if(expires){
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
		((expires) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
		((path) ? ';path=' + path : '' ) +
		((domain) ? ';domain=' + domain : '' ) +
		((secure) ? ';secure' : '' );
}


//FUNCTION FOR DELETING COOKIES
function deleteCookie(name, path, domain){
	if(getCookie(name))
		document.cookie = name + '=' + ((path) ? ';path=' + path : '') +
			((domain) ? ';domain=' + domain : '' ) + ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}


// utility function to retrieve an expiration date in proper format; pass three integer parameters 
// for the number of days, hours, and minutes from now you want the cookie to expire (or negative
// values for a past date); all three parameters are required, so use zeros where appropriate
function getExpDate(days, hours, minutes) {
    var expDate = new Date( );
    if (typeof days == "number" && typeof hours == "number" && 
        typeof hours == "number") {
        expDate.setDate(expDate.getDate( ) + parseInt(days));
        expDate.setHours(expDate.getHours( ) + parseInt(hours));
        expDate.setMinutes(expDate.getMinutes( ) + parseInt(minutes));
        return expDate.toGMTString( );
    }
}




//FORMAT A NUMBER WITH COMMAS
//inserts commas in the appropriate places, regardless of the size of the number (in plain, nonscientific notation)
function formatCommas(numString) {
    var re = /(-?\d+)(\d{3})/;
    while (re.test(numString)) {
        numString = numString.replace(re, "$1,$2");
    }
    return numString;
}


//STRIP COMMAS FROM A NUMBER STRING
function stripCommas(numString) {
    var re = /,/g;
    return numString.replace(re,"");
}




//CLEAR ALL THE TEXTBOXES
function clearTextBoxes( ) {
    var allInputs = document.getElementsByTagName("input");
    for (var i = 0; i < allInputs.length; i++) {
        if (allInputs[i].type == "text") {
            allInputs[i].value = "";
        }
    }
}


//COMPARING TWO DATES
function compareDates(a, b) {
    var dateA = new Date(a.year, a.month, a.date);
    var dateB = new Date(b.year, b.month, b.date);
    return dateA - dateB;
}


//COMPARING STRINGS

function compareNames(a, b) {
    var nameA = a.lastName.toLowerCase( );
    var nameB = b.lastName.toLowerCase( );
    if (nameA < nameB) {return -1}
    if (nameA > nameB) {return 1}
    return 0;
}



//CLEARING THE ROWS FROM A TABLE
//invoke the clear( ) method of any table element object to let it remove all of its rows: 
//USAGE::document.getElementById("myTable").clear( );
function clearTbody( ) {
    var tbodies = this.getElementsByTagName("tbody");
    for (var i = 0; i < tbodies.length; i++) {
        while (tbodies[i].rows.length > 0) {
            tbodies[i].deleteRow(0);
        }
    }
}



//FINDING DAY PART
function dayPart( ) {
    var oneDate = new Date( );
    var theHour = oneDate.getHours( );
    if (theHour < 12) {
        return "morning";
    } else if (theHour < 18) {
        return "afternoon";
    } else {
        return "evening";
    }
}


//DETECTING BROWSER BRAND
//parameter brand:: Netscapde OR Microsoft Internet Explorer OR Opera
function detectBrowserBrand()
{
	//Netscape Navigator and Mozilla always return the string "Netscape", while Internet Explorer returns "Microsoft Internet Explorer". These strings and the equivalency operator are case-sensitive. 
	var isNav = (navigator.appName == "Netscape");
	var isIE = (navigator.appName == "Microsoft Internet Explorer");
	var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
	if(isNav)
		return "Netscape";
	else if(isIE)
		return "IE";
	else if(isOpera)
		return "Opera";
		

}

//Detecting an Early Browser Version

function detectBrowserVersion()
{
	return parseInt(navigator.appVersion);
}



//GET IE VERSION NUMBER
function getIEVersionNumber( ) {
    var ua = navigator.userAgent;
    var MSIEOffset = ua.indexOf("MSIE ");
    if (MSIEOffset == -1) {
        return 0;
    } else {
        return parseFloat(ua.substring(MSIEOffset + 5, ua.indexOf(";", MSIEOffset)));
    }
}


//DETECTING CLIENT OS
function detectClientOS()
{
	var isWin = (navigator.userAgent.indexOf("Win") != -1);
	var isMac = (navigator.userAgent.indexOf("Mac") != -1);
	var isUnix = (navigator.userAgent.indexOf("X11") != -1);
	if(isWin) return "Win";
	else if(isMac) return "Mac";
	else if(isUnix) return "Unix";
}



//Detecting the Netscape Navigator Version
function getNNVersionNumber( ) {
    if (navigator.appName == "Netscape") {
        var appVer = parseFloat(navigator.appVersion);
        if (appVer < 5) {
            return appVer;
        } else {
            if (typeof navigator.vendorSub != "undefined") {
                return parseFloat(navigator.vendorSub);
            }
        }
    }
    return 0;
}


// VERIFY BROWSER LANGUAGE
// usage:location.href = (getLang("de")) ? "de/home.html" : "en/home.html";
function getLang(type) {
    var lang;
    if (typeof navigator.userLanguage != "undefined") {
        lang = navigator.userLanguage.toUpperCase( );
    } else if (typeof navigator.language != "undefined") {
        lang = navigator.language.toUpperCase( );
    }
    return (lang && lang.indexOf(type.toUpperCase( )) == 0)
}

//CHECK IF COOKIE IS ENALBLED
function checkCookieEnabled()
{
	if (navigator.cookieEnabled) {
		return true;
    	// invoke cookie statements here
	}
	return false;
}

function isPhone(str){
	
	for(i = 0; i < str.length; i++){
		mychar = str.charAt(i);
		if((mychar >= "0" && mychar <= "9") || mychar == "-" || mychar == "+" ){
			if(mychar == "+" && i!=0)
			{
				return false;
			}
				
			if(mychar == "-" && i==0)
			{
				return false;
			}
		} 
		else
		{
			return false; 
		}
	}
	return true;
}



//FUNCTION1:: VALIDATE PHONE NUMBER

function ValidatePhoneNumber(phonenum) 
{ 
	var CleanedString=""; 
	var index = 0; 
	var LimitCheck; 
	var InitialString = phonenum.value;

 	//Get the length of the inputted string, to know how many characters to check
	LimitCheck = InitialString.length;
 
	//Walk through the inputted string and collect only number characters, appending them to CleanedString
	while (index != LimitCheck) { 
		if (isNaN(parseInt(InitialString.charAt(index)))) { } 
		else { CleanedString = CleanedString + InitialString.charAt(index); } 
		index = index + 1; 
	}
 
	//If CleanedString is exactly 10 digits long, then format it and allow form submission
	if (CleanedString.length == 10) { 
		phonenum.value= "(" + CleanedString.substring(0,3) + ") " + CleanedString.substring(3,6) + "-" + CleanedString.substring(6,10); 
	}
 
	//If CleanedString is not 10 digits longs, show an alert and cancel form submission
	else{ 
		CleanedString = InitialString; 
		alert("Phone numbers must have exactly ten digits.");
		return false
	} 
} 





//FUNCTION 2:: INTERNATIONAL PHONE NUMBER VALIDATION

/** DHTML phone number validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) **/

var digits = "0123456789";
var phoneNumberDelimiters = "()- ";// non-digit characters which are allowed in phone numbers
var validWorldPhoneChars = phoneNumberDelimiters + "+";// characters which are allowed in international phone numbers (a leading + is OK)
var minDigitsInIPhoneNumber = 10;// Minimum no of digits in an international phone no.

function isInteger(s)
{   
	var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    return true;
}

function stripCharsInBag(s, bag)
{   
	var i;
    var returnString = "";
    // Search through string's characters one by one. If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

//CALL THIS FUNCTION FOR USAGE
function checkInternationalPhone(strPhone)
{
	s=stripCharsInBag(strPhone,validWorldPhoneChars);
	return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
//END:: INTERNATIONAL PHONE NUMBER VALIDATION

//REGULAR EXPRESSION MATCHING FUNCTION
//SAMPLE USAGE::
	//testStr = "1z 999 999 99 9999 999 9";
	//var result=RegExMatch(testStr, /^(1[Z])\s\d{3}\s\d{3}\s\d{2}\s\d{4}\s\d{3}\s\d{1}$/)
	//(result)?alert('Done'):alert('NOt Done');
	
	
	
function isWebUrl(url)
{
		
	var pattern= /^http:\/\/[A-Za-z0-9\.-]{3,}(\.[A-Za-z]{1,3}(.[A-Za-z]{2, 3})?)$/
	if (url.match(pattern))
	{		
		return true;
	}
	else
	{
		return false; 
	}
}

function relativeImageSizeRatio(width, height, max_width, max_height)
{
	var x_ratio = max_width / width;
	var y_ratio = max_height / height;

	if( (width <= max_width) && (height <= max_height) ){
		tn_width = width;
		tn_height = height;
	}
	else if ((x_ratio * height) < max_height){
		tn_height = ceil(x_ratio * height);
		tn_width = max_width;
	}
	else{
		tn_width = ceil(y_ratio * width);
		tn_height = max_height;
	}
	return tn_width+'|'+tn_height;
	
}
/*-------------------------------------------------------------------------------
|| Name: createRequestObject													||
|| Purpose: create ajax object 													||
|| Applies to : create_group.php,edit_group                                     ||
|| Parameters : 																
|| Modified: 05/25/2009															||
--------------------------------------------------------------------------------*/	
function createRequestObject(){
   var req;
   if(window.XMLHttpRequest){
      // Firefox, Safari, Opera...
      req = new XMLHttpRequest();
   } else if(window.ActiveXObject){
      // Internet Explorer 5+
      req = new ActiveXObject("Microsoft.XMLHTTP");
   } else {
      // There is an error creating the object,
      // just as an old browser is being used.
      alert('Problem creating the XMLHttpRequest object');
   }
   return req;
}