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 + '\')");">Create a Bookmark to <em>' + title + '</em></a>'); 
		} else if (window.external) { // IE Favorite
			return document.write('<a href="javascript:createBookmarkLink(\'' + url + '\', \'' + title + '\')");">Add <em>' + title + '</em> to your Favorites</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>');
}


var Comb50 = "";
function LoadGallery(pictureName,imageFile,titleCaption,captionText)
      {
	if (document.all)
  	{
	document.getElementById(pictureName).style.filter="blendTrans(duration=2)";
	document.getElementById(pictureName).filters.blendTrans.Apply();
 	}
	document.getElementById(pictureName).src = imageFile;
	if (document.all)
 	{
 	document.getElementById(pictureName).filters.blendTrans.Play();
	}
	document.getElementById(titleCaption).innerHTML=captionText;
      }


function ChangeUserInfo(Control) {
try 
{

if (document.getElementById) {

ctlValue = Control.value;

ctlText = Control.options[Control.selectedIndex].text;

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 = "INVLIST-" + 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 displayPrice() {

if (document.getElementById) {

if (document.getElementById(vXmodid.showPricing).selectedIndex == 0) 
{ 
document.getElementById('DivPrice').style.display='none'; 
document.getElementById('DivPriceRange').style.display='none';
document.getElementById('DivSalePrice').style.display='none';
document.getElementById('DivPayPal').style.display='none';
} 
else if (document.getElementById(vXmodid.showPricing).selectedIndex == 1) 
{ 
document.getElementById('DivPrice').style.display='none'; 
document.getElementById('DivPriceRange').style.display='none';
document.getElementById('DivSalePrice').style.display='none';
document.getElementById('DivPayPal').style.display='none';
} 
else if (document.getElementById(vXmodid.showPricing).selectedIndex == 2) 
{ 
document.getElementById('DivPrice').style.display=''; 
document.getElementById('DivPriceRange').style.display='none';
document.getElementById('DivSalePrice').style.display='none';
document.getElementById('DivPayPal').style.display='';
} 
else if (document.getElementById(vXmodid.showPricing).selectedIndex == 3) 
{ 
document.getElementById('DivPrice').style.display='none'; 
document.getElementById('DivPriceRange').style.display='';
document.getElementById('DivSalePrice').style.display='none';
document.getElementById('DivPayPal').style.display='none';
}


else if (document.getElementById(vXmodid.showPricing).selectedIndex == 4) 
{ 
document.getElementById('DivPrice').style.display='none'; 
document.getElementById('DivPriceRange').style.display='none';
document.getElementById('DivSalePrice').style.display='';
document.getElementById('DivPayPal').style.display='';
} 

else if (document.getElementById(vXmodid.showPricing).selectedIndex == 5) 
{ 
document.getElementById('DivPrice').style.display=''; 
document.getElementById('DivPriceRange').style.display='none';
document.getElementById('DivSalePrice').style.display='';
document.getElementById('DivPayPal').style.display='';
}  
else 
{ 
document.getElementById('DivPrice').style.display='none'; 
document.getElementById('DivPriceRange').style.display='none';
document.getElementById('DivSalePrice').style.display='none';
document.getElementById('DivPayPal').style.display='none';
}
 
}

}


function checkHTML() {
var strShortDescript = document.getElementById(vXmodid.ShortDescript).value;
var strCompanyProfile = document.getElementById(vXmodid.CompanyProfile).value;
var strNotes = document.getElementById(vXmodid.Notes).value;
var strSpecs = document.getElementById(vXmodid.Specifications).value;
var strTestimonial1 = document.getElementById(vXmodid.Testimonial1).value;
var strTestimonial2 = document.getElementById(vXmodid.Testimonial2).value;
var strDiscount = document.getElementById(vXmodid.Discount).value;
var reg = new RegExp("<[^>]*>");

var arsDescript = reg.test(strShortDescript);
var arCprofile = reg.test(strCompanyProfile);
var arNotes = reg.test(strNotes);
var arSpecs = reg.test(strSpecs);
var arTestimonial1 = reg.test(strTestimonial1);
var arTestimonial2 = reg.test(strTestimonial2);
var arDiscount = reg.test(strDiscount);

if (document.getElementById) {

if (arsDescript) {
document.getElementById(vXmodid.ShortDescriptHTML).value = 'Yes';
}else{
document.getElementById(vXmodid.ShortDescriptHTML).value = 'No';
}

if (arCprofile) {
document.getElementById(vXmodid.CompanyProfileHTML).value = 'Yes';
}else{
document.getElementById(vXmodid.CompanyProfileHTML).value = 'No';
}

if (arNotes) {
document.getElementById(vXmodid.NotesHTML).value = 'Yes';
}else{
document.getElementById(vXmodid.NotesHTML).value = 'No';
}

if (arSpecs) {
document.getElementById(vXmodid.SpecsHTML).value = 'Yes';
}else{
document.getElementById(vXmodid.SpecsHTML).value = 'No';
}

if (arTestimonial1) {
document.getElementById(vXmodid.Testimonial1HTML).value = 'Yes';
}else{
document.getElementById(vXmodid.Testimonial1HTML).value = 'No';
}

if (arTestimonial2) {
document.getElementById(vXmodid.Testimonial2HTML).value = 'Yes';
}else{
document.getElementById(vXmodid.Testimonial2HTML).value = 'No';
}

if (arDiscount) {
document.getElementById(vXmodid.DiscountHTML).value = 'Yes';
}else{
document.getElementById(vXmodid.DiscountHTML).value = 'No';
}

}
}



function displayRatings() {

if (document.getElementById) {

if (document.getElementById(vXmodid.ShowRatings).selectedIndex == 0) 
{ 
document.getElementById('DivAllowRatings').style.display='none';
} 
else if (document.getElementById(vXmodid.ShowRatings).selectedIndex == 1) 
{ 
document.getElementById('DivAllowRatings').style.display='';
} 
else if (document.getElementById(vXmodid.ShowRatings).selectedIndex == 2) 
{ 
document.getElementById('DivAllowRatings').style.display='none';
} 
else 
{ 
document.getElementById('DivAllowRatings').style.display='none';
}
 
}

}


function displayReviews() {

if (document.getElementById) {

if (document.getElementById(vXmodid.ShowComments).selectedIndex == 0) 
{ 
document.getElementById('DivCommentApproval').style.display='none';
} 

else if (document.getElementById(vXmodid.ShowComments).selectedIndex == 1) 
{ 
document.getElementById('DivCommentApproval').style.display='';
} 
else if (document.getElementById(vXmodid.ShowComments).selectedIndex == 2) 
{ 
document.getElementById('DivCommentApproval').style.display='none';
} 
else 
{ 
document.getElementById('DivCommentApproval').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.\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 displayAudioChoice() { 

if (document.getElementById) {

if (document.getElementById(vXmodid.AudioType).selectedIndex == 0) 
{
//document.getElementById('DivVideoJive').style.display=''; 
document.getElementById('DivAudioLocal').style.display='none'; 
document.getElementById('DivAudioAmazonS3').style.display='none';
document.getElementById('DivAudioDescription').style.display='none';
document.getElementById('DivAudioApproved').style.display='none';
} 
else if (document.getElementById(vXmodid.AudioType).selectedIndex == 1) { 
document.getElementById('DivAudioAmazonS3').style.display='';
document.getElementById('DivAudioDescription').style.display='';
document.getElementById('DivAudioLocal').style.display='none';
document.getElementById('DivAudioApproved').style.display='';
//document.getElementById('DivAudioJive').style.display='none';
}
else if (document.getElementById(vXmodid.AudioType).selectedIndex == 2) 
{
document.getElementById('DivAudioDescription').style.display='';
document.getElementById('DivAudioLocal').style.display=''; 
document.getElementById('DivAudioAmazonS3').style.display='none';
document.getElementById('DivAudioApproved').style.display='';
//document.getElementById('DivAudioJive').style.display='none';
}
else 
{ 
//document.getElementById('DivAudioJive').style.display=''; 
document.getElementById('DivAudioLocal').style.display='none'; 
document.getElementById('DivAudioAmazonS3').style.display='none';
document.getElementById('DivVideoYouTube').style.display='none';
document.getElementById('DivVideoImage').style.display='none';
document.getElementById('DivAudioDescription').style.display='none';
document.getElementById('DivAudioApproved').style.display='none';
}
 
}

} 



function displayVideoChoice() { 

if (document.getElementById) {

if (document.getElementById(vXmodid.VideoType).selectedIndex == 0) 
{
document.getElementById('DivVideoJive').style.display=''; 
document.getElementById('DivVideoLocal').style.display='none'; 
document.getElementById('DivVideoAmazonS3').style.display='none';
document.getElementById('DivVideoYouTube').style.display='none';
document.getElementById('DivVideoImage').style.display='none';
document.getElementById('DivVideoDescription').style.display='none';
document.getElementById('DivVideoApproved').style.display='none';
} 
else if (document.getElementById(vXmodid.VideoType).selectedIndex == 1) { 
document.getElementById('DivVideoAmazonS3').style.display='';
document.getElementById('DivVideoImage').style.display='';
document.getElementById('DivVideoDescription').style.display='';
document.getElementById('DivVideoLocal').style.display='none';
document.getElementById('DivVideoYouTube').style.display='none';
document.getElementById('DivVideoJive').style.display='none';
document.getElementById('DivVideoApproved').style.display='';
}
else if (document.getElementById(vXmodid.VideoType).selectedIndex == 2) 
{
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';
document.getElementById('DivVideoApproved').style.display='';
}
else if (document.getElementById(vXmodid.VideoType).selectedIndex == 3) 
{
document.getElementById('DivVideoLocal').style.display='';
document.getElementById('DivVideoImage').style.display='';
document.getElementById('DivVideoDescription').style.display='';
document.getElementById('DivVideoAmazonS3').style.display='none';
document.getElementById('DivVideoYouTube').style.display='none';
document.getElementById('DivVideoJive').style.display='none';
document.getElementById('DivVideoApproved').style.display='';
}
else 
{ 
document.getElementById('DivVideoJive').style.display=''; 
document.getElementById('DivVideoLocal').style.display='none'; 
document.getElementById('DivVideoAmazonS3').style.display='none';
document.getElementById('DivVideoYouTube').style.display='none';
document.getElementById('DivVideoImage').style.display='none';
document.getElementById('DivVideoDescription').style.display='none';
document.getElementById('DivVideoApproved').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="445" height="364"><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="445" height="364"><\/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();
});
