function fnPlaceData(url,nType,sName) {
	try {
		var xmlDoc = dbsRequest(url);
		if (xmlDoc != null) {
			var sHTML = ""
			for (var nFields = 0; nFields < xmlDoc.childNodes.length; nFields++) {
				if (nType == 5) {
					sHTML += "<option value=\""+dbsGetNodeText(xmlDoc.childNodes[nFields].childNodes[0])+"\">"+dbsGetNodeText(xmlDoc.childNodes[nFields].childNodes[0])+"</option>"
				}
				
				else if (nType == 4) {
					if (nFields > 0)
						sHTML += " &nbsp;";
					sHTML += "<nobr><input style=\"height:15px;\" type=\"checkbox\" name=\"" + sName + "\" value=\"" + dbsGetNodeText(xmlDoc.childNodes[nFields].childNodes[0]) + "\" id=\"fld" + nType+""+nFields + "\"><label for=\"fld" + nType+""+nFields + "\">" + dbsGetNodeText(xmlDoc.childNodes[nFields].childNodes[0]) + "</label></nobr>";
				}
				
				else if (nType == 3) {
					if (nFields > 0)
						sHTML += " &nbsp;";
					sHTML += "<nobr><input style=\"height:15px;\" type=\"radio\" name=\"" + sName + "\" value=\"" + dbsGetNodeText(xmlDoc.childNodes[nFields].childNodes[0]) + "\" id=\"fld" + nType+""+nFields + "\"><label for=\"fld" + nType+""+nFields + "\">" + dbsGetNodeText(xmlDoc.childNodes[nFields].childNodes[0]) + "</label></nobr>";
				}
			}
			document.write(sHTML);
		}
	} catch (e) {
	}
}

function expand_bar(bar_Id) {
	var bar = document.getElementById("bar_"+bar_Id);
	if (bar != null) {
		bar.style.display = ("block" == bar.style.display ? "none" : "block");
		/*for (i=1;i<bar_length;i++){
			if (i!=bar_Id){
				bar = document.getElementById("bar_"+i);
				bar.style.display = 'none';
				}
		}*/
	}
}

function changeClass(obj,opr) {
	if (opr==1) {
		obj.style.font = "bold 12px";
		obj.style.color = "#ff9393";
	}
	else {
		obj.style.font = "bold 12px";
		obj.style.color = "#000000";
	}
}

function fnSetAction(oSelect) {
	var sValue = oSelect[oSelect.selectedIndex].value;
	if (sValue != "-1") {
		var saValue = sValue.split("||");
		
		if (saValue[0] == "1")
			window.open(saValue[1],"_blank");
		else
			window.location = saValue[1];
	}
	else {
		oSelect.selectedIndex = 0;
	}
	return;
}

function fnShowFullImg(sFile) {
	if (sFile.toLowerCase().indexOf("/_cut/") != -1) {
		var sFileTemp = sFile.toLowerCase().replace("_cut/","");
		var nPos = sFileTemp.lastIndexOf("/");
		var sFileName = sFileTemp.substr(nPos+1,sFile.length-nPos);
		if (sFileName.length > 13) {
			sFileName = sFileName.substr(13,sFileName.length-13);		
			var sFilePath = sFile.substr(0,nPos+1);
			sFile = sFilePath + sFileName;
		}
	}
	window.open("ViewImage.asp?Image="+sFile,"image","top=50,left=50,width="+(screen.availWidth-100)+",height="+(screen.availHeight-100)+",scrollbars");
	//window.open("ViewImage.asp?Image="+sFile,"image","fullscreen=1,scrollbars,scrollbars");
}

function fnShowGalleryFullImg(sFile, nID, nCategoryID) {
	//window.open("ViewGalleryImage.asp?Image="+sFile,"image","top=50,left=50,width="+(screen.availWidth-100)+",height="+(screen.availHeight-100)+",scrollbars");
	window.open("ViewGalleryImage.asp?ArticleID="+nID+"&CategoryID="+nCategoryID+"&Image="+sFile,"image","fullscreen=1,scrollbars,scrollbars");
}

function fnShowGallery(iCatID,iArticleID) {
	window.open("ViewGallery.asp?CategoryID="+iCatID+"&ArticleID="+iArticleID,"gallery","top=50,left=50,width="+(screen.availWidth-100)+",height="+(screen.availHeight-100)+",scrollbars=no");
}

function dbsSetURL(sName) {
	window.location.hash = sName.replace("#","");
}

function dbsMail(box,server) {
	window.location = "mailto:" + box + "@" + server;
}

function fnSetQuickNavState(sCatID) {
	var selQuickNav = document.getElementById("ctlQuickNav");
	for (var i=0; i<selQuickNav.options.length; i++) {
		if (selQuickNav.options[i].id == "opt" + sCatID) {
			selQuickNav.options[i].selected = true;
			break;
		}
	}
}

function fnTalkBack(nCategoryID,nArticleID,sTitle) {
	window.open("_TalkBack/AddResponse.asp?CategoryID=" + nCategoryID + "&ArticleID=" + nArticleID + "&Title=" + sTitle,"talkback","top=60,left=30,width=400,height=492")
}

function fnTellFriend(sURL,sCategoryID) {
	window.open("TellFriendPopUp.asp?CategoryID="+sCategoryID+"&URL="+escape(sURL),"tellfriend","top=60,left=30,width=400,height=412,scrollbars=yes")
}

function fnOpenWin(sURL,nWidth,nHeight) {
	window.open(sURL,"tellfriend","top="+((window.screen.height-nHeight)/2)+",left="+((window.screen.width-nWidth)/2)+",width="+nWidth+",height="+nHeight+",scrollbars")
}

function dbsGetContent(sModule,vParam,sPg,sCategoryID,sArticleID) {
	try {
		var xmlHTTP;
		// code for IE
		if (window.ActiveXObject) {
			xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
			xmlHTTP.open("GET","_modules/XML/"+sModule+".asp?pg="+sPg+"&CategoryID="+sCategoryID+"&Param="+vParam+"&ArticleID="+sArticleID+"&DMode=1", false);
			xmlHTTP.send();
			document.write(xmlHTTP.responseXML.documentElement.text);
		}	
		// code for Mozilla, etc.
		else if (window.XMLHttpRequest) {
			xmlHTTP = new XMLHttpRequest();
			xmlHTTP.open("GET","_modules/XML/"+sModule+".asp?pg="+sPg+"&CategoryID="+sCategoryID+"&Param="+vParam+"&ArticleID="+sArticleID+"&DMode=1", false);
			xmlHTTP.send(null);
			document.write(xmlHTTP.responseXML.documentElement.textContent);
		}	
	}
	 catch (e) {
	}
}

function fnHTTPGetRequest(sURL) {
	try {
		var xmlHTTP;
		// code for IE
		if (window.ActiveXObject) {
			xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
			xmlHTTP.open("GET",sURL, false);
			xmlHTTP.send();
			return xmlHTTP;
		}
		// code for Mozilla, etc.
		else if (window.XMLHttpRequest) {
			xmlHTTP = new XMLHttpRequest();
			xmlHTTP.open("GET",sURL, false);
			xmlHTTP.send(null);
			return xmlHTTP;
		}
	}
	 catch (e) {
	 	return null;
	}
}

/******************************** Horizontal Navigation Functions *********************************/
/******************** Added drop down menu************/
var interval, oCurrentDiv;
function fnShowNodes(td, ID, sDir) {
	var oDiv = document.getElementById("Sub_"+ID);
	if (oDiv != null) {
		oDiv.style.visibility = "visible";
		oDiv.style.top = td.offsetHeight + td.offsetTop - oDiv.offsetParent.offsetTop + "px";
		if (sDir == "rtl")
			oDiv.style.left = td.offsetLeft - (oDiv.offsetWidth-td.offsetWidth) - oDiv.offsetParent.offsetLeft + "px";
		else
			oDiv.style.left = td.offsetLeft - oDiv.offsetParent.offsetLeft + "px";
	}
}

function fnHideNodes(ID) {
	var oDiv = document.getElementById("Sub_"+ID);
	if (oDiv != null) {
		oDiv.style.visibility = "hidden";
	}
}


/******************************** Fixing Flash Problemi in IE *********************************/
// Universal event handler
// Please don't use "onload = functionName" etc
// use instead this "addEvent(window, 'load', functionName);"
function addEvent(obj, strEvent, objFunction)
{ 
	if (obj.addEventListener) { 
		obj.addEventListener(strEvent, objFunction, true); 
		return true; 
	}
	else if (obj.attachEvent) { 
		var returnValue = obj.attachEvent("on"+strEvent, objFunction); 
		return returnValue; 
	} 
	else return false; 
}

function removeEvent(obj, strEvent, objFunction)
{ 
	if (obj.addEventListener) {
		obj.removeEventListener(strEvent, objFunction, true)
	}
	else if (obj.attachEvent) {
		obj.detachEvent("on"+strEvent, objFunction);
	}
}

// be careful: this script erases the "FlashVars" content, 
// you can send vars in the file name after "?" like in asp
function startObjects()
{
	objects = document.getElementsByTagName("OBJECT");
	for (var i = 0; i < objects.length; i++)
	{
		if (objects[i].classid.toUpperCase() == "CLSID:D27CDB6E-AE6D-11CF-96B8-444553540000" || objects[i].type.toLowerCase() == "application/x-shockwave-flash")
			objects[i].outerHTML = objects[i].outerHTML;
	}
}

if (navigator.appName == "Microsoft Internet Explorer") {
	//addEvent(window, 'load', startObjects);
}
/******************************** Content Rating *********************************/

function fncRate(nItemID,nCategoryID,nRating,nAverage) {
	var xmlDoc = dbsRequest("_TalkBack/RateContent.asp?ItemID=" + nItemID + "&ItemCategoryID=" + nCategoryID + "&Rating=" + nRating)
	if (xmlDoc != null) {
		var sResult = dbsGetNodeText(xmlDoc);
		
		if (!isNaN(sResult)) {
			nAverage = parseInt(sResult);
			if (nAverage != 0) {
				var sStars = "";
				for (var nStars=1; nStars<=5; nStars++) {
					var ctlRating = document.getElementById("ctlRating_"+nItemID+"_"+nStars);
					if (ctlRating != null) {
						var sHTML;
						if (nStars <= nAverage)
							sHTML = "<img src=\"_Pics/RatingFullStar.gif\" border=\"0\" alt=\" " + nStars + " \">";
						else
							sHTML = "<img src=\"_Pics/RatingStar.gif\" border=\"0\" alt=\" " + nStars + " \">";

						ctlRating.innerHTML = sHTML;
					}
				}
				var ctlRatingsCount = document.getElementById("ctlRatingsCount_"+nItemID);
				if (ctlRatingsCount != null) {
					var sText = ctlRatingsCount.innerText;
					if (isNaN(sText))
						ctlRatingsCount.innerText = "1";
					else
						ctlRatingsCount.innerText = parseInt(ctlRatingsCount.innerText)+1;
				}
				document.getElementById("ctlRatingsPannelContainer_"+nItemID).onmouseout = null;
				document.getElementById("ctlRatingTitle_"+nItemID).innerHTML = sRatingMsg;
			}
		}
		else
			fnSetFullStars(nItemID,nAverage);
	}
}


function fnSetFullStars(nItemID, nRatingCount) {
	for (var nStars=1; nStars<=5; nStars++) {
		var oImg = document.getElementById("imgRate_"+nItemID+"_"+nStars);
		if (oImg != null) {
			if (nStars <= nRatingCount) {
				oImg.src = "_Pics/RatingFullStar.gif";
			}
			else {
				oImg.src = "_Pics/RatingStar.gif";
			}	
		}
	}
}

function fnSetStars(nItemID,nAverage) {
	for (var nStars=1; nStars<=5; nStars++) {
		var oImg = document.getElementById("imgRate_"+nItemID+"_"+nStars);
		if (oImg != null) {
			if (nStars <= nAverage) {
				oImg.src = "_Pics/RatingFullStar.gif";
			}
			else {
				oImg.src = "_Pics/RatingStar.gif";
			}				
		}
	}
}

function fnPrintFlash(sFileURL, nWidth, nHeight,id) {
	if (window.ActiveXObject)
		document.write("<object type=\"application/x-shockwave-flash\" id=\"" + id + "\" width=\"" + nWidth + "\" height=\""+ nHeight + "\">");
	else
		document.write("<object type=\"application/x-shockwave-flash\" id=\"" + id + "\" width=\"" + nWidth + "\" height=\""+ nHeight + "\" data=\"" + sFileURL + "\">");
	document.write("<param name=\"movie\" value=\"" + sFileURL + "\">");
	document.write("<param name=\"quality\" value=\"high\">");
	document.write("<param name=\"wmode\" value=\"transparent\">");
	document.write("</object>");
}

function fnPrintFlashAdv(sFileURL, nWidth, nHeight,id, sFVars) {
	if (window.ActiveXObject)
		document.write("<object type=\"application/x-shockwave-flash\" id=\"" + id + "\" width=\"" + nWidth + "\" height=\""+ nHeight + "\">");
	else
		document.write("<object FlashVars=\"" + sFVars + "\" type=\"application/x-shockwave-flash\" id=\"" + id + "\" width=\"" + nWidth + "\" height=\""+ nHeight + "\" data=\"" + sFileURL + "\">");
	document.write("<param name=\"movie\" value=\"" + sFileURL + "\">");
	document.write("<param name=\"quality\" value=\"high\">");
	document.write("<param name=\"wmode\" value=\"transparent\">");
	document.write("<param name=\"FlashVars\" value=\"" + sFVars + "\">");
	document.write("</object>");
}

// Cache Ratings images
var dbsRatingStar = new Image();
	dbsRatingStar.src ="_Pics/RatingStar.gif";
var dbsRatingFullStar = new Image();
	dbsRatingFullStar.src ="_Pics/FullRatingStar.gif";

function fnFilterStates(nCountryID, nStateID, ctlID) {
	var ctlStates = document.getElementById(ctlID);
	if (ctlStates != null) {
		var xmlDoc = dbsRequest("_Subscription/GetStates.asp?CountryID=" + nCountryID);
		if (xmlDoc != null) {
			ctlStates.options.length = 0;
			if (xmlDoc.hasChildNodes()) {
				var oStates = xmlDoc.getElementsByTagName("state"); 
				for (var nStates=0; nStates<oStates.length; nStates++) {
					var sStateID = dbsGetAttributeText(oStates[nStates],0);
					var sStateTitle = dbsGetAttributeText(oStates[nStates],1);
					var bSelected = (nStateID.toString() == dbsGetAttributeText(oStates[nStates],0));
					
					var oOption = new Option(sStateTitle,sStateID);
					ctlStates.options.length++;
					ctlStates.options[ctlStates.options.length-1] = oOption;
					ctlStates.options[ctlStates.options.length-1].selected = bSelected;
				}
				ctlStates.disabled = false;
			}
			else {
				ctlStates.disabled = true;
				var oOption = new Option("none","");
				ctlStates.options.length++;
				ctlStates.options[ctlStates.options.length-1] = oOption;
			}
		}
	}
}


function fnSetDefaultFormData(oFrm) {
	try {
		var xmlDoc = dbsRequest(sAppDomain+"/GetUserDetails.asp");
		for (var nAttributes = 0; nAttributes < xmlDoc.attributes.length; nAttributes++) {
			if (document.getElementById(xmlDoc.attributes[nAttributes].name)) {
				if (dbsGetAttributeText(xmlDoc, nAttributes) != "")
					document.getElementById(xmlDoc.attributes[nAttributes].name).value = dbsGetAttributeText(xmlDoc, nAttributes);
			}
		}
	} catch (e) {
	}
}

function fnPrintWin(URL) {
	window.open(URL,"_blank");
}

function fnShowSelectElemByClass(sClassName) {
	if (dbsBrowserType == "ie") {
		var colList = document.getElementsByTagName("SELECT");
		for (var i=0; i<colList.length; i++) {
			if (colList[i].className.toLowerCase() == sClassName.toLowerCase() || sClassName == "") {
				colList[i].style.visibility = "visible";
			}
		}
	}
}

function fnHideSelectElemByClass(sClassName) {
	if (dbsBrowserType == "ie") {
		var colList = document.getElementsByTagName("SELECT");
		for (var i=0; i<colList.length; i++) {
			if (colList[i].className.toLowerCase() == sClassName.toLowerCase() || sClassName == "") {
				colList[i].style.visibility = "hidden";
			}
		}
	}
}




