
function createBookmarkLink(url, title) {
	try {
		if (window.sidebar) { // Mozilla Firefox Bookmark
			return window.sidebar.addPanel(title, url, "");
		} else if( window.external ) { // IE Favorite
			return window.external.AddFavorite( url, title); 
		} else if(window.opera && window.print) { // Opera Hotlist
			return true; 
		}
	} catch(err) {
		// do nothing
	}
	alert('Could not create a bookmark on your client.\n\nTo return to ' + title + ' you must manually create a bookmark to: \n' + url + '.');
}

function writeBookmarkLink(url, title) {
	try {
		if (window.sidebar) { // Mozilla Firefox Bookmark
			return document.write('<a href="javascript:createBookmarkLink(\'' + url + '\', \'' + title + '\')");">A&ntilde;ade <em>' + title + '</em> a tus favoritos! <img src="/Portals/0/xmod/packages/BusinessDirectory/Favoritos.gif" border="0" /></a>'); 
		} else if (window.external) { // IE Favorite
			return document.write('<a href="javascript:createBookmarkLink(\'' + url + '\', \'' + title + '\')");">A&ntilde;ade <em>' + title + '</em> a tus Favoritos! <img src="/Portals/0/xmod/packages/BusinessDirectory/Favoritos.gif" border="0" /></a>'); 
		} else if (window.opera && window.print) { // Opera Hotlist
			return document.write('<a rel="sidebar" href="' + url + '" title="' + title + '">Create a Bookmark to <em>' + title + '</em></a>');
		} 
	} catch(err) {
		// do nothing
	}
	return document.write('To return to ' + title + ' create a bookmark to: <a style="color: white;" href="' + url + '">' + url + '</a>');
}



function ChangeUserInfo(Control ) {
try 
{

if (document.getElementById) {

ctlValue = Control.value;

ctlText = Control.options[Control.selectedIndex].text;

document.getElementById(vXmodid.UserID).value = ''
document.getElementById(vXmodid.UserFullName).value = ''

document.getElementById(vXmodid.UserID).value = ctlValue
document.getElementById(vXmodid.UserFullName).value = ctlText
document.getElementById(vXmodid.UserEmail).value = ''
document.getElementById(vXmodid.AccountID).value = ctlValue + "-VEND"
document.getElementById(vXmodid.ListingID).value = "BLIST-" + ctlValue + "-VEND-" + vXmodFormatDate

//  txt="Hi .\n\n"
//  txt+="There was an error on this page.\n\n"
//  txt+="Value: " + ctlValue + "\n\n"
//  txt+="Text: " + ctlText + "\n\n"
//  txt+="Click OK to continue.\n\n"
//  alert(txt)
}

}
catch(err)
  {
  txt="Hi .\n\n"
  txt+="There was an error on this page.\n\n"
  txt+="Error description: " + err.description + "\n\n"
  txt+="Error on: " + ctlValue + "\n\n"
  txt+="Click OK to continue.\n\n"
  alert(txt)
  }
finally
  {
  // do nothing
  }
}


function displayNonUS(Control) {

if (document.getElementById) {

	if (Control.selectedIndex == 1) {
	//if (document.getElementById(vXmodid.cboState).selectedIndex == 1)

	document.getElementById('DivNonUS').style.display='';
	}
	else 
	{ 
	document.getElementById('DivNonUS').style.display='none';
	}
}

}

function displayEDO(Control) {

if (document.getElementById) {

	if (Control.selectedIndex == 1) {
	//if (document.getElementById(vXmodid.cboState).selectedIndex == 1)

	document.getElementById('DivEDO').style.display='';
	}
	else 
	{ 
	document.getElementById('DivEDO').style.display='none';
	}
}
}

function displayNOCITY(Control) {

if (document.getElementById) {

	if (Control.selectedIndex == 1) {
	//if (document.getElementById(vXmodid.cboState).selectedIndex == 1)

	document.getElementById('DivNOCITY').style.display='';
	}
	else 
	{ 
	document.getElementById('DivNOCITY').style.display='none';
	}
}

}


function CheckSize(Ctrl, Size) {
x = Ctrl.value.length;
y = Size;
if (y > x)
SendMsg2 (Ctrl, "OK - number of characters is: " + x); else
SendMsg2 (Ctrl, "Too Long - number of characters is: " + x);}
function SendMsg2 (Ctrl, PromptStr) { alert (PromptStr);
return;
}

function CheckSizeBlur(Ctrl, Size) {
x = Ctrl.value.length;
y = Size;
if (x > y)
SendMsg (Ctrl, "Too Long - number of characters is: " + x);
}
function SendMsg (Ctrl, PromptStr) { alert (PromptStr);
Ctrl.focus(); return;
}

function SaveMultipleSubCategory(Control1, ContolCatIndex, Control2){
try 
{

if (ContolCatIndex > 0) {

  var txtSelectedValuesObj = Control2;
  var selectedArray = new Array();
  var selObj = Control1;
  var i;
  var count = 0;

  for (i=0; i<selObj.options.length; i++) {
    if (selObj.options[i].selected) {
      selectedArray[count] = selObj.options[i].value;
      count++;
    }
  }

Control2.value = selectedArray;
} else {
  Control2.value = '';
}

}
catch(err)
  {
  txt="Hi.\n\n"
  txt+="There was an error on this page.\n\n"
  txt+="Sub Category Index is: " + Control1Index + "\n\n"
  txt+="Error description: " + err.description + "\n\n"
  txt+="Click OK to continue.\n\n"
  alert(txt)
  }
finally
  {
  // do nothing
  }


}

function SaveSubCategory(Control1, ContolCatIndex, Control2) {


try 
{
	if (ContolCatIndex > 0) {
//Control2.value = Control1.value + " Index: " +  ContolCatIndex;
		Control2.value = Control1.value;
		//Control2.style.display = '';
	} else {
		Control2.value = ''
		//Control2.style.display = 'none';
	}	

}
catch(err)
  {
  txt="Hi {XMOD_UserFirstName}.\n\n"
  txt+="There was an error on this page.\n\n"
  txt+="Sub Category Index is: " + Control1Index + "\n\n"
  txt+="Error description: " + err.description + "\n\n"
  txt+="Click OK to continue.\n\n"
  alert(txt)
  }
finally
  {
  // do nothing
  }


}

function replaceChars(field1) {
out = ","; // replace this
add = "&nbsp;-&nbsp;"; // with this
temp = "" + field1; // temporary holder

while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add + 
temp.substring((pos + out.length), temp.length));
}
//field1.value = temp;
return document.write(temp)
}


function displayVideoChoice(Control) { 

if (document.getElementById) {


 
if (document.getElementById(vXmodid.VideoType).selectedIndex == 0) 
{ 
document.getElementById('DivVideoLocal').style.display='none'; 
document.getElementById('DivVideoAmazonS3').style.display='none';
document.getElementById('DivVideoYouTube').style.display='none';
document.getElementById('DivVideoJive').style.display='';
document.getElementById('DivVideoImage').style.display='none';
document.getElementById('DivVideoDescription').style.display='none';
} 
else if (document.getElementById(vXmodid.VideoType).selectedIndex == 1) 
{ 
document.getElementById('DivVideoLocal').style.display='';
document.getElementById('DivVideoImage').style.display='';
document.getElementById('DivVideoDescription').style.display='';
document.getElementById('DivVideoAmazonS3').style.display='none';
document.getElementById('DivVideoJive').style.display='none';
document.getElementById('DivVideoYouTube').style.display='none';
} 
else if (document.getElementById(vXmodid.VideoType).selectedIndex == 2) 
{ 
document.getElementById('DivVideoAmazonS3').style.display='';
document.getElementById('DivVideoImage').style.display='';
document.getElementById('DivVideoDescription').style.display='';
document.getElementById('DivVideoLocal').style.display='none';
document.getElementById('DivVideoJive').style.display='none';
document.getElementById('DivVideoYouTube').style.display='none';
}
else if (document.getElementById(vXmodid.VideoType).selectedIndex == 3) 
{ 
document.getElementById('DivVideoYouTube').style.display='';
document.getElementById('DivVideoDescription').style.display='';
document.getElementById('DivVideoImage').style.display='none';
document.getElementById('DivVideoLocal').style.display='none'; 
document.getElementById('DivVideoAmazonS3').style.display='none';
document.getElementById('DivVideoJive').style.display='none';
}
else if (document.getElementById(vXmodid.VideoType).selectedIndex == 4) 
{ 
document.getElementById('DivVideoLocal').style.display='none'; 
document.getElementById('DivVideoAmazonS3').style.display='none';
document.getElementById('DivVideoYouTube').style.display='none';
document.getElementById('DivVideoJive').style.display='';
document.getElementById('DivVideoImage').style.display='none';
document.getElementById('DivVideoDescription').style.display='none';
}
else 
{ 
document.getElementById('DivVideoLocal').style.display='none'; 
document.getElementById('DivVideoAmazonS3').style.display='none';
document.getElementById('DivVideoYouTube').style.display='none';
document.getElementById('DivVideoJive').style.display='none';
document.getElementById('DivVideoImage').style.display='none';
document.getElementById('DivVideoDescription').style.display='none';
}
 
}

} 

function showYouTube(url) {
try
{
var urlInput = url;
var pattern = "watch\?v=";
var replacement = "v/";
var urlInput = urlInput.replace(pattern, replacement);
var YouTubeEmbed = '<object width="320" height="267"><param name="movie" value="' + urlInput + '&rel=0&color1=0x3a3a3a&color2=0x999999&border=1&hl=en"><\/param><param name="wmode" value="transparent"><\/param>\<embed src="' + urlInput + '&rel=0&color1=0x3a3a3a&color2=0x999999&border=1&hl=en" type="application\/x-shockwave-flash" wmode="transparent" width="320" height="267"><\/embed><\/object>';	
return document.writeln(YouTubeEmbed);
}
catch(err)
  {
  txt="Hi .\n\n"
  txt+="There was an error on this page.\n\n"
  txt+="YouTube video cannot be displayed.\n\n"
  txt+="Error description: " + err.description + "\n\n"
  txt+="Error on: " + ctlValue + "\n\n"
  txt+="Click OK to continue.\n\n"
  alert(txt)
  }
finally
  {
  // do nothing
  }
} 


function ClearSubCategory(Control1, Control2) {

try 
{


	Control2.value = '';
	//Control2.style.display = 'none';

}
catch(err)
  {
  txt="Hi {XMOD_UserFirstName}.\n\n"
  txt+="There was an error on this page.\n\n"
  txt+="Error description: " + err.description + "\n\n"
  txt+="Click OK to continue.\n\n"
  alert(txt)
  }
finally
  {
  // do nothing
  }
}



function setCategory() {


categorySel = document.getElementById(vXmodid.cboCategory);
categoryList = CAT[categorySel.value]
Field_ID = vXmodid.SubCategory;
changeSelect(Field_ID, categoryList, categoryList);
}


function changeSelect(fieldID, newOptions, newValues) {
selectField = document.getElementById(fieldID);
selectField.options.length = 0;
for (i=0; i<newOptions.length; i++) {
selectField.options[selectField.length] = new Option(newOptions[i], newValues[i]);
}

}


function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}

addLoadEvent(function() {
setCategory();
});
ad) {
oldonload();
}
func();
}
}
}

addLoadEvent(function() {
setCategory();
});
vent(function() {
setCategory();
});
