//////////////////////////////////////////////////////////
// Browser Types
/*
ns4=(_d.layers)?true:false
ns6=(navigator.userAgent.indexOf("Gecko")!=-1)?true:false
mac=(navigator.appVersion.indexOf("Mac")!=-1)?true:false
mac45=(navigator.appVersion.indexOf("MSIE 4.5")!=-1)?true:false
if(ns6||ns4)mac=false
opera=(navigator.userAgent.indexOf("Opera")!=-1)?true:false
ns61=(parseInt(navigator.productSub)>=20010726)?true:false
ie4=(!_d.getElementById&&_d.all)?true:false;
konq=(navigator.userAgent.indexOf("Konqueror")!=-1)?true:false
*/

//////////////////////////////////////////////////////////
// variables
var ns = (!document.all && document.getElementById);
var ie = (document.all && document.getElementById);
var userAgent = navigator.userAgent.toLowerCase();
var userApp = navigator.appName.toLowerCase();
var userVersion = parseFloat(navigator.appVersion);
var userAppVersion = navigator.appVersion.toLowerCase();
var isNetscape6 = false;
if (navigator.userAgent.indexOf('Netscape6') != -1) isNetscape6 = true ;

function isNet4x() {
	if (document.getElementById)
		return false;
	return true;
}

//OS
var OSName="Unknown OS";
var isMac = false;
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
if (navigator.appVersion.indexOf("Mac")!=-1)
{ 
	OSName="MacOS";
	isMac = true;
}

//defined
function isDefined(variable)
{
    return (typeof(window[variable]) == "undefined")?  false: true;
}

function isObjectDefined(object, variable)
{
	return (typeof(eval(object)[variable]) != "undefined");
}


//////////////////////////////////////////////////////////
// Window Management
function fncPopWindow(strUrl,strWindowName,strFeatures){
	if(strWindowName == ""){
		strWindowName = "wndSecondary";
	}
	if(strFeatures == ""){
		strFeatures = "width=500,height=350,resizable=yes,scrollbars=yes,top=200px,dependent=yes"
	}
	var wndPop = window.open(strUrl,strWindowName,strFeatures);
	wndPop.document.close();
	wndPop.focus();
}

function fncCloseThisWindow(){
	window.close();
}

/////////////////////////////////////////////////////
// Layer Management
function fncShowHideById(strElementID)
{
	if(document.getElementById(strElementID).style.display == "none")
    {
        document.getElementById(strElementID).style.display = "";
    }
    else
    {
        document.getElementById(strElementID).style.display = "none";
    }
}

function fncShowHideById2(strElementID,blnShow)
{
    if(!blnShow)
    {
        document.getElementById(strElementID).style.display = "none";
    }
    else
    {
        document.getElementById(strElementID).style.display = "";
    }
}

function fncAddPaddingBottom(strElementID, intPadding)
{
    var intExistingPadding = 0;
    var intDivTop = 0;
	//if(document.getElementById(strElementID))
	//{
    intExistingPadding = document.getElementById(strElementID).style.paddingBottom;
	
    if(intExistingPadding == "" || intExistingPadding == null)
    {
        intExistingPadding = 0;
    }
    intExistingPadding = intExistingPadding.toString();
    if(intExistingPadding.indexOf("px") != -1)
    {
        var intLength = 0;
        intLength = intExistingPadding.length - 2;
        intExistingPadding = intExistingPadding.substr(0,intLength);
    }
	intExistingPadding = parseInt(intExistingPadding) + parseInt(intPadding);
    document.getElementById(strElementID).style.paddingBottom = intExistingPadding;
	//}
}

//////////////////////////////////////////////////////////
// Mouse Events
function fncOnMouseOverCursor(strID)
{
    document.getElementById(strID).style.cursor = "pointer";
}

function fncOnMouseOutCursor(strID)
{
    document.getElementById(strID).style.cursor = "default";
}


//////////////////////////////////////////////////////////
// String Validation
function fncReplaceChar(str, chr, newchr)
{
	for(var i=0;i<str.length;i++)
	{
		str = str.replace(chr,newchr);		
	}
	if(str.length == 1)
	{
		if(str == chr)
		{
			str = newchr;
		}
	}
	return str;
}

function replaceChar(str, chr){
	for(var i = 0; i < str.length; i++)
	{
		str = str.replace(chr,"");
	}
	if(str.length == 1)
	{
		if(str == chr)
		{
			str = "";
		}
	}
	return str;
}

function rep_leading_blanks(inString)
{
	var i, j = inString.length, retString = inString;
	for (var i = 0; i < j ; i++) 
	{
		if (inString.charAt(i) == ' ')
			retString = inString.substr(i+1,j-i-1);
		else
			return(retString);
	}
	return(retString);
}

function rep_trailing_blanks(inString){
	var i, j = inString.length, retString = inString;
	
	for (var i=j;i>0;i--) {
		if (inString.charAt(i-1)==' ')
			retString=inString.substr(0,i-1);
		else
		return(retString);
	}	
	return(retString);
}

function fncRemoveExtraBlanks(obj){
	obj = rep_leading_blanks(obj);
	obj = rep_trailing_blanks(obj);
	return obj;
}

function fncRemoveExtraBlanksString(str){
	str = rep_leading_blanks(str);
	str = rep_trailing_blanks(str);
	return str;
}

function mask (InString, Mask)  {
	var LenStr = InString.length, LenMsk = Mask.length;
	
	if ((LenStr==0) || (LenMsk==0))	return(0);
	if (LenStr!=LenMsk)	return(0);

	for(var Count=0; Count<=InString.length; Count++) {
		StrChar = InString.substring(Count, Count+1);
		MskChar = Mask.substring(Count, Count+1);
		if (MskChar=='#') {
			if(!isNumberChar(StrChar)) return(0);
		} else if (MskChar=='?') {
			if(!isAlphabeticChar(StrChar)) return(0);
		} else if (MskChar=='!') {
			if(!isNumOrChar(StrChar)) return(0);
		} else if (MskChar=='*') {
		} else {
			if (MskChar!=StrChar) return(0);
		}
	}
	return (1);
}

function isNumberChar (InString)  {
	var RefString="1234567890";

	if(InString.length!=1) return false;
	if(RefString.indexOf (InString, 0)==-1) return false;
	
	return true;
}

function isAlphabeticChar (InString)  {
	var	RefString="abcdefghijklmnopqrstuvwxyz";
	
	if(InString.length != 1) return false;	
	InString=InString.toLowerCase ()
	if (RefString.indexOf (InString, 0)==-1) return false;
	
	return true;
}

function isNumOrChar (InString)  {
	var RefString="1234567890abcdefghijklmnopqrstuvwxyz";

	if(InString.length!=1) return false;
	InString=InString.toLowerCase();
	if (RefString.indexOf (InString, 0)==-1) return false;

	return true;
}


var aryCommonJsNumbers = new Array("0","1","2","3","4","5","6","7","8","9");
var aryCommonJsLetters = new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
var aryCommonJsOtherChar = new Array(",",".","<",">","/","\\","|","{","}","[","]","`","~","!","@","#","$","%","^","&","*","(",")","-","_","+","=",";",":","?","'","\"");

var aryNameCharacters = new Array(",",".","-","'");
var aryPhoneCharacters = new Array(".","(",")","-");
var aryAddressCharacters = new Array(",",".","#","-","'");
var aryGeneralCharacters = new Array(",",".","-","'","!","&","$");
var aryEmailCharacters = new Array(".","@","-","_","+");
var aryZipCharacters = new Array("-");

//Replaces unwanted characters with ""	
function fncCleanInput(str,type)
{
	type = type.toLowerCase();
	if(type == "phone" || type == "number" || type == "zip")
	{
		//remove letters
		for(var i = 0; i < aryCommonJsLetters.length; i++)
		{
			if(str.indexOf(aryCommonJsLetters[i]) > -1)
			{
				str = replaceChar(str, aryCommonJsLetters[i]);
			}
		}
		if(type == "phone")
		{
			//remove all characters except phone related ()-.
			for(var i = 0; i < aryCommonJsOtherChar.length; i++)
			{
				var isamatch = false;
				if(str.indexOf(aryCommonJsOtherChar[i]) > -1)
				{	//found character in general list
					for(var j = 0; j < aryPhoneCharacters.length; j++)
					{
						if(aryCommonJsOtherChar[i] == aryPhoneCharacters[j])
						{	//character is permitted 
							isamatch = true;
							break;
						}
					}
					if(!isamatch)
					{
						str = replaceChar(str, aryCommonJsOtherChar[i]);
					}
				}
			}
		}
		else if(type == "zip")
		{
			//remove all characters except zip related -
			for(var i = 0; i < aryCommonJsOtherChar.length; i++)
			{
				var isamatch = false;
				if(str.indexOf(aryCommonJsOtherChar[i]) > -1)
				{	//found character in general list
					for(var j = 0; j < aryZipCharacters.length; j++)
					{
						if(aryCommonJsOtherChar[i] == aryZipCharacters[j])
						{	//character is permitted 
							isamatch = true;
							break;
						}
					}
					if(!isamatch)
					{
						str = replaceChar(str, aryCommonJsOtherChar[i]);
					}
				}
			}
		}
	}
	else if(type == "name")
	{
		//remove all characters except name related ,-.'
		for(var i = 0; i < aryCommonJsOtherChar.length; i++)
		{
			if(str.indexOf(aryCommonJsOtherChar[i]) > -1)
			{	//found character in general list
				var isamatch = false;
				for(var j = 0; j < aryNameCharacters.length; j++)
				{
					if(aryCommonJsOtherChar[i] == aryNameCharacters[j])
					{	//character is permitted 
						isamatch = true;
						break;
					}
				}
				if(!isamatch)
				{
					str = replaceChar(str, aryCommonJsOtherChar[i]);
				}
			}
		}
	}
	else if(type == "address")
	{
		//remove all characters except name related ,-.'
		for(var i = 0; i < aryCommonJsOtherChar.length; i++)
		{
			if(str.indexOf(aryCommonJsOtherChar[i]) > -1)
			{	//found character in general list
				var isamatch = false;
				for(var j = 0; j < aryAddressCharacters.length; j++)
				{
					if(aryCommonJsOtherChar[i] == aryAddressCharacters[j])
					{	//character is permitted 
						isamatch = true;
						break;
					}
				}
				if(!isamatch)
				{
					str = replaceChar(str, aryCommonJsOtherChar[i]);
				}
			}
		}
	}
	else if(type == "email")
	{
		//remove all characters except name related ,-.'
		for(var i = 0; i < aryCommonJsOtherChar.length; i++)
		{
			if(str.indexOf(aryCommonJsOtherChar[i]) > -1)
			{	//found character in general list
				var isamatch = false;
				for(var j = 0; j < aryEmailCharacters.length; j++)
				{
					if(aryCommonJsOtherChar[i] == aryEmailCharacters[j])
					{	//character is permitted
						isamatch = true;
						break;
					}
				}
				if(!isamatch)
				{
					str = replaceChar(str, aryCommonJsOtherChar[i]);
				}
			}
		}
	}
	else if(type == "text")
	{
		//remove all characters except name related ,-.'
		for(var i = 0; i < aryCommonJsOtherChar.length; i++)
		{
			if(str.indexOf(aryCommonJsOtherChar[i]) > -1)
			{	//found character in general list
				var isamatch = false;
				for(var j = 0; j < aryGeneralCharacters.length; j++)
				{
					if(aryCommonJsOtherChar[i] == aryGeneralCharacters[j])
					{	//character is permitted 
						isamatch = true;
						break;
					}
				}
				if(!isamatch)
				{
					str = replaceChar(str, aryCommonJsOtherChar[i]);
				}
			}
		}
	}
	else	//general
	{
		//remove all characters except name related ,-.'
		for(var i = 0; i < aryCommonJsOtherChar.length; i++)
		{
			if(str.indexOf(aryCommonJsOtherChar[i]) > -1)
			{	//found character in general list
				var isamatch = false;
				for(var j = 0; j < aryGeneralCharacters.length; j++)
				{
					if(aryCommonJsOtherChar[i] == aryGeneralCharacters[j])
					{	//character is permitted 
						isamatch = true;
						break;
					}
				}
				if(!isamatch)
				{
					str = replaceChar(str, aryCommonJsOtherChar[i]);
				}
			}
		}
	}
	return str;
}


//Verifies character based strings
function fncCharStringVerification(strValue,type)  {
	var allowNumbers = "no";
	if(type == "Name" || type == "Street Address" || type == "State License" || type == "Email Body"){
		allowNumbers = "yes";
	}
	
	var foundNumber = "no";
	if(allowNumbers == "no"){
		for(var x = 0; x < aryCommonJsNumbers.length; x++){
			if(strValue.indexOf(aryCommonJsLetters[x]) > -1){
				foundNumber = "yes";
				//alert("Please do not enter numbers in the " + type + " filed.");
				return false;
				break;
			}
		}
	}
	
	if(foundNumber == "no"){
		for(var y = 0; y < aryCommonJsOtherChar.length; y++){
			if(strValue.indexOf(aryCommonJsOtherChar[y]) > -1){
				if(type == "Name"){	//allow periods, dashes, and commas in name fields
					if((aryCommonJsOtherChar[y] != ".") && (aryCommonJsOtherChar[y] != "-") && (aryCommonJsOtherChar[y] != ",")){
						return false;
						break;
					}
				}else if(type == "Street Address"){	//allow periods, dashes, and commas in street address fields
					if((aryCommonJsOtherChar[y] != ".") && (aryCommonJsOtherChar[y] != "-") && (aryCommonJsOtherChar[y] != "#")){
						return false;
						break;
					}
				}else if(type == "State License"){	//allow dashes in state license
					if((aryCommonJsOtherChar[y] != "-")){
						return false;
						break;
					}
				}else if(type == "Email Body"){
					if((aryCommonJsOtherChar[y] != ".") && (aryCommonJsOtherChar[y] != "-") && (aryCommonJsOtherChar[y] != "#") && (aryCommonJsOtherChar[y] != "'") && (aryCommonJsOtherChar[y] != ",")){
						return false;
						break;
					}
				}else if(type == "APN"){
					if((aryCommonJsOtherChar[y] != "-")){
						return false;
						break;
					}
				}else{
					return false;
					break;
				}
			}
		}
	}
}

//Checks to verify string is a number
function fncCleanNumbers(strValue,type){
	var foundLetter = "no";
	for(var x = 0; x < aryCommonJsLetters.length; x++){
		if(strValue.indexOf(aryCommonJsLetters[x]) > -1){
			foundLetter = "yes";
			//alert("Please enter only numbers and commas in the " + type + " fields.");
			return false;
			break;
		}
	}
	
	if(foundLetter == "no"){
		for(var y = 0; y < aryCommonJsOtherChar.length; y++){
			if(strValue.indexOf(aryCommonJsOtherChar[y]) > -1){
				if(type == "Phone"){
					if(aryCommonJsOtherChar[y] != "-" && aryCommonJsOtherChar[y] != "(" && aryCommonJsOtherChar[y] != ")"){
						return false;
						break;
					}
				}else if(type == "Date"){
					if(aryCommonJsOtherChar[y] != "/"){
						return false;
						break;
					}
				}else if(type == "ZipLong"){
					if(aryCommonJsOtherChar[y] != "-"){
						return false;
						break;
					}
				}else if(type == "Zip" || type == "Pure" || type == "Meter"){
					return false;
					break;
				}else if(type == "Dollar"){
					if(aryCommonJsOtherChar[y] != "," && aryCommonJsOtherChar[y] != ".")
					{
						return false;
						break
					}
				}else if(type == "Pure"){
					return false;
					break
				}else{
					if(aryCommonJsOtherChar[y] != ","){	//allow commas, except for rates
						//alert("Please enter only numbers and commas in the " + type + " fields.");
						return false;
						break;
					}
				}
			}
		}
	}
}

//Email Check
function fncCommonCheckEmail(frmEmail){
	if (frmEmail.value == ""){
		alert("Enter a value for the \"Email Address\" field.");
		frmEmail.focus();
		return false;
	}
	
	var checkOK = "|&;()<>\'\"*?\\[]$!#`{}";
	var checkStr = frmEmail.value;
	var allValid = true;
	
	for (var i = 0;  i < checkOK.length;  i++){
		var ch = checkOK.charAt(i);
		if (checkStr.indexOf(ch,0) != -1){
			allValid = false;
			break;
		}
	}
	
	if (!allValid){
		alert("Enter only valid characters in \"Email Address\" field.");
		frmEmail.focus();
		return false;
	}
	
	if (frmEmail.value.length < 6){
		//alert("Enter at least 6 characters in the \"Email Address\" field.");
		alert("Enter a valid email address.");
		frmEmail.focus();
		return false;
	}
	
	//Contains @
	if (frmEmail.value.indexOf('@',0)==-1){
		//alert("Enter a @ character in the \"Email Address\" field.");
		alert("Enter a valid email address.");
		frmEmail.focus();
		return false;
	}
	
	//@ is not the first character
	if (frmEmail.value.indexOf('@',0)==0){
		alert("Enter a valid email Address.");
		frmEmail.focus();
		return false;
	}
	
	// Get length of email address
	var strLength = frmEmail.value.length;
	var strEmail = frmEmail.value;
	var result = strEmail.lastIndexOf(".");
	var atSign = strEmail.lastIndexOf("@");
	
	//there cannot be fewer than 5 characters after the @ sign
	if (strLength - atSign < 5){
		alert("Enter a valid email Address.");
		frmEmail.focus(); 	
		return false;
	}
	
	//the period cannot be in the first position
	if (frmEmail.value.indexOf('.',0)==-1){
		alert("Enter a valid email Address.");
		frmEmail.focus();
		return false;
	}
	
	// Must have 2 characters after the period
	if (strLength - result < 3){
		alert("Enter a valid email Address.");
		frmEmail.focus(); 	
		return false;
	}
	
	//No blanks in the email
	if (frmEmail.value.indexOf(' ',0)!=-1){
		//alert("Don't enter a blank character in the \"EmailAddress\" field.");
		alert("Enter a valid email Address.");
		frmEmail.focus();
		return false;
	}
}

//////////////////////////////////////////////////////////
//States
var aryStateAbbr = new Array("AL","AK","AZ","AR","CA","CO","CT","DC","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY");
var aryStateNames = new Array("Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","DC","Delaware","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming");

function fncStateDropDown(objSelectBox,strType,strFirstValue,strSelected){
	var cnt = 0;
	if(strFirstValue > ""){
		objSelectBox.options[cnt] = new Option(strFirstValue,"");
		cnt = 1;
	}
	
	if(strType == "Full"){
		for(i = 0; i < aryStateAbbr.length; i++){
			objSelectBox.options[i+cnt] = new Option(aryStateNames[i],aryStateAbbr[i]);
		}
	}else{
		for(i = 0; i < aryStateAbbr.length; i++){
			objSelectBox.options[i+cnt] = new Option(aryStateAbbr[i],aryStateAbbr[i]);
		}
	}
	
	if(strSelected > ""){
		for(var j = 0; j < objSelectBox.length; j++){
			if(objSelectBox.options[j].value == strSelected){
				objSelectBox.options[j].selected = true;
			}
		}
	}
}

//State Drop Downs Loaded from Data Base
function fncSetState( strState, objDropDown ){
	for(var i = 0; i < objDropDown.length; i++){
		if(objDropDown[i].text == strState){
			objDropDown[i].selected = true;
		}
	}
}

function fncSetHdnState(objDropDown,objHidden){
	objHidden.value = objDropDown.options[objDropDown.selectedIndex].text;
}

function fncGetState(objHidden,objDropDown){
	if(objHidden.value < " "){
		fncSetState( "CA", objDropDown );
	}else{
		fncSetState( objHidden.value, objDropDown );
	}
}

//////////////////////////////////////////////////////////
// form management
// disable submit button
function fncDisableButton() {
	document.frm.submit();
	window.setTimeout("fncDisableButton('" + window.event.srcElement.id + "')", 0);
}

function fncDisableButtonForm(frm) {
	frm.submit();
	window.setTimeout("fncDisableButton('" + window.event.srcElement.id + "')", 0);
}

function fncDisableButtonFormBtn(frm,btn) {
	frm.submit();
	window.setTimeout("fncDisableButton('" + btn + "')", 0);
}

function fncDisableButton(buttonID) {
	document.getElementById(buttonID).disabled=true;
}

//////////////////////////////////////////////////////////
//Click Paths
var strClickHome = "http://www.ci.fullerton.ca.us/";
var strClickDepartments = "/departments/departments.html";
//Police
var strClickPolice = "/departments/police";

//////////////////////////////////////////////////////////
//User Details
//User Name
function fncParseName(PropertyNames, PropertyValues)
{
	//Catherine Carter
	//FirstName:S:0:9:LastName:S:9:6:
	
	var aryNameProperties = new Array();
	aryNameProperties = PropertyNames.split(":");
	
	var strFirstName = PropertyValues.slice(aryNameProperties[2],(aryNameProperties[2] + aryNameProperties[3]));
	var strLastName = PropertyValues.slice(aryNameProperties[6], (aryNameProperties[6] + aryNameProperties[7]));
	
	document.write(strFirstName + " " + strLastName);
}

//////////////////////////////////////////////////////////
//scan alert
function fncDisplayScanAlertImage()
{
	var strScanAlert = '<div style="text-align: right;"><!-- START SCANALERT CODE -->';
	strScanAlert += '<a target="_blank" href="https://www.scanalert.com/RatingVerify?ref=www.cityoffullerton.com"><img width="115" height="30" border="0" src="//images.scanalert.com/meter/www.cityoffullerton.com/32.gif" alt="HACKER SAFE certified sites prevent over 99.9% of hacker crime." oncontextmenu="alert(';
	strScanAlert += "'Copying Prohibited by Law - HACKER SAFE is a Trademark of ScanAlert'";
	strScanAlert += '); return false;"></a>';
	strScanAlert += '<!-- END SCANALERT CODE --></div>';
	
	document.write(strScanAlert);
}

function fncDisplayScanAlert()
{
	var strScanAlert = '<!-- START SCANALERT CODE -->';
	strScanAlert += '<a target="_blank" href="https://www.scanalert.com/RatingVerify?ref=www.cityoffullerton.com"><img width="115" height="30" border="0" src="//images.scanalert.com/meter/www.cityoffullerton.com/32.gif" alt="HACKER SAFE certified sites prevent over 99.9% of hacker crime." oncontextmenu="alert(';
	strScanAlert += "'Copying Prohibited by Law - HACKER SAFE is a Trademark of ScanAlert'";
	strScanAlert += '); return false;"></a>';
	strScanAlert += '<!-- END SCANALERT CODE -->';
	
	document.write(strScanAlert);
}

//////////////////////////////////////////////////////////
//rounded corners
function fncRoundedCorners()
{
	var aryRoundedClasses = new Array("rounded", "roundedTop", "roundedBottom", "roundedRight", "roundedLeft", "roundedTopRight", "roundedTopLeft", "roundedBottomRight", "roundedBottomLeft");
	var aryRoundedClassesTopRight = new Array("rounded", "roundedTop", "roundedRight", "roundedTopRight");
	var aryRoundedClassesTopLeft = new Array("rounded", "roundedTop", "roundedLeft", "roundedTopLeft");
	var aryRoundedClassesBottomRight = new Array("rounded", "roundedBottom", "roundedRight", "roundedBottomRight");
	var aryRoundedClassesBottomLeft = new Array("rounded", "roundedBottom", "roundedLeft", "roundedBottomLeft");
	//class= "rounded roundedTop roundedBottom roundedRight roundedLeft roundedTopRight roundedTopLeft roundedBottomRight roundedBottomLeft"
	//rounded = roundedTopRight roundedTopLeft roundedBottomRight roundedBottomLeft
	//roundedTop = roundedTopRight roundedTopLeft
	//roundedBottom = roundedBottomRight roundedBottomLeft
	//roundedRight = roundedTopRight roundedBottomRight
	//roundedLeft = roundedTopLeft roundedBottomLeft
	
	var aryGetDivs = document.getElementsByTagName("div");
	var aryRoundedDivs = [];
	var styleName = "rounded";
	for(var i = 0; i < aryGetDivs.length; i++)
	{
		//if(styleName.exec(aryGetDivs[i].className))
		if(aryGetDivs[i].className.indexOf(styleName) != -1)
		{
			aryRoundedDivs[aryRoundedDivs.length] = aryGetDivs[i];
		}
	}
	
	for(var i = 0; i < aryRoundedDivs.length; i++)
	{
		var currentDiv = aryRoundedDivs[i];
		var currentDivStyleType = currentDiv.className;
		var blnHasTopRight = false;
		var blnHasTopLeft = false;
		var blnHasBottomRight = false;
		var blnHasBottomLeft = false;
		
		for(var j = 0; j < aryRoundedClasses.length; j++)
		{
			currentDiv.className = currentDiv.className.replace(aryRoundedClasses[j],"");
		}
		
		//roundedTopRight
		for(var k = 0; k < aryRoundedClassesTopRight.length; k++)
		{
			if(currentDivStyleType == aryRoundedClassesTopRight[k])
			{
				blnHasTopRight = true;
			}
		}
		//roundedTopLeft
		for(var m = 0; m < aryRoundedClassesTopLeft.length; m++)
		{
			if(currentDivStyleType == aryRoundedClassesTopLeft[m])
			{
				blnHasTopLeft = true;
			}
		}
		//roundedBottomRight
		for(var n = 0; n < aryRoundedClassesBottomRight.length; n++)
		{
			if(currentDivStyleType == aryRoundedClassesBottomRight[n])
			{
				blnHasBottomRight = true;
			}
		}
		//roundedBottomLeft
		for(var n = 0; n < aryRoundedClassesBottomLeft.length; n++)
		{
			if(currentDivStyleType == aryRoundedClassesBottomLeft[n])
			{
				blnHasBottomLeft = true;
			}
		}
		
		//alert("blnHasTopRight = " + blnHasTopRight + "; blnHasTopLeft = " + blnHasTopLeft + "; blnHasBottomRight = " + blnHasBottomRight + "; blnHasBottomLeft = " + blnHasBottomLeft);
		var lastCorner = "";
		
		if(blnHasTopRight)
		{
			var tr = document.createElement("div");
			tr.className = "roundedTopRightCorner";
			currentDiv.parentNode.replaceChild(tr, currentDiv);
			lastCorner = tr;
		}
		if(blnHasTopLeft)
		{
			var tl = document.createElement("div");
			tl.className = "roundedTopLeftCorner"
			if(lastCorner != "")
			{
				lastCorner.appendChild(tl);
			}
			else
			{
				currentDiv.parentNode.replaceChild(tl, currentDiv);
			}
			lastCorner = tl;
		}
		if(blnHasBottomRight)
		{
			var br = document.createElement("div");
			br.className = "roundedBottomRightCorner"
			if(lastCorner != "")
			{
				lastCorner.appendChild(br);
			}
			else
			{
				currentDiv.parentNode.replaceChild(br, currentDiv);
			}
			lastCorner = br;
			
		}
		if(blnHasBottomLeft)
		{
			var bl = document.createElement("div");
			bl.className = "roundedBottomLeftCorner";
			if(lastCorner != "")
			{
				lastCorner.appendChild(bl);
			}
			else
			{
				currentDiv.parentNode.replaceChild(bl, currentDiv);
			}
			lastCorner = bl;
		}
		
		lastCorner.appendChild(currentDiv);
	}
}
