function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
	location.href=location.href;
}

function getObject(theObjectID)
// returns the object as element
{
	if (document.all && !document.getElementById)
	{
		return document.all(theObjectID)
	}
	else
	{
		return document.getElementById(theObjectID)
	}
}

function initOptions(theSelect)
// clears(deletes) all options for at theSelect select box
{
	theSelect=getObject(theSelect);
	while(theSelect.firstChild){
		theSelect.removeChild(theSelect.firstChild);
	}
}

function selectedText(theSelect)
{
	theSelect=getObject(theSelect);
	for (i=0;i<theSelect.options.length;i++)
	{
		if(theSelect.options[i].selected)
		{
			return(theSelect.options[i].text);
		}
	}
}

function selectedValue(theSelect)
{
	theSelect=getObject(theSelect);
	for (i=0;i<theSelect.options.length;i++)
	{
		if(theSelect.options[i].selected)
		{
			return(theSelect.options[i].value);
		}
	}
}

function getAllValues(theSelect)
{
	var theSelect=getObject(theSelect);
	var allValues = "";
	for (i=0;i<theSelect.options.length;i++)
	{
		allValues = allValues + theSelect.options[i].value;
	}
	return(allValues);
}

function removeSelectedOption(theSelect)
{
	theSelect=getObject(theSelect);
	for (i=0;i<theSelect.options.length;i++)
	{
		if(theSelect.options[i].selected)
		{
			theSelect.options[i]=null;
		}
	}
}

function addOption(theSelect, theValue, theText)
// adds a new option to theSelect select box
{
	theSelect=getObject(theSelect);
	theSelect.options[theSelect.options.length]=new Option(theText,theValue);
}

function selectOption(theSelect, theValue)
{
	var theSelect = getObject(theSelect);
	var theOptions = theSelect.options;
	var i;

	for(i=1;i<theOptions.length;i++)
	{
		if(theOptions[i].value==theValue)
		{
			theSelect.selectedIndex=i;
			break;
		}
	}
}

function addToFavoite()
{
	window.external.AddFavorite(document.location,document.title);
}

function IsKeyDigit()
{
	var nKey=event.keyCode;
	//alert(nKey);
	if ((nKey==8)||(nKey==9)||(nKey==13)||(nKey==35)||(nKey==36)||(nKey==37)||(nKey==39)||(nKey==48)||(nKey==49)||(nKey==50)||(nKey==51)||(nKey==52)||(nKey==53)||(nKey==54)||(nKey==55)||(nKey==56)||(nKey==57)||(nKey==96)||(nKey==97)||(nKey==98)||(nKey==99)||(nKey==100)||(nKey==101)||(nKey==102)||(nKey==103)||(nKey==104)||(nKey==105)||(nKey==110)||(nKey==190))
	{
		return(true);
	}
	else
	{
		return(false);
	}
}

function showhide(theObject)
{
	theObject = getObject(theObject);
	if(theObject.style.display=="none")
	{
		theObject.style.display="block";
	}
	else
	{
		theObject.style.display="none";
	}
}

function replaceAll(theString,from_string,to_string)
{
	while(theString.indexOf(from_string)!=-1)
	{
		theString = theString.replace(from_string,to_string);
	}
	return(theString);
}

function getExt(fullname)
{
	fullname = fullname.substring(fullname.indexOf(".")+1,fullname.length);
	return(fullname);
}

function allowBackgroundColorChange(img)
{
	if($.browser.msie){
		var imgName = img.src.toUpperCase()
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		{
			var imgID = (img.id) ? "id='" + img.id + "' " : ""
			var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			var imgStyle = "display:inline-block;" + img.style.cssText
			if (img.align == "left") imgStyle = "float:left;" + imgStyle
			if (img.align == "right") imgStyle = "float:right;" + imgStyle
			if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
			var strNewHTML = "<span " + imgID + imgClass + imgTitle
			+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
			img.outerHTML = strNewHTML
		}
	}
}

function sendcontact(businessid){
	if(validateForm(document.contactForm)){
		createCookie('submitCookie',businessid,1);
		document.contactForm.submit();
	}
}
