<!-- 
var request;
var request2;
var request3;
var url;
var urlSingle;
var isbenziPlayerOpen=false;
var date = new Date();
var bfirst = false;
function getLoadingVisible(){
            var clientwidth = document.documentElement.clientWidth;
            var clientheight = document.documentElement.clientHeight;
            if(arguments[0] == "GB"){
                        clientwidth = 905;
                        clientheight = 465;
            }else{
                        clientwidth = document.documentElement.clientWidth;
                        clientheight = document.documentElement.clientHeight;
            }
            document.getElementById("Layer1").style.left = ((Number(clientwidth)/2) - 124) + "px";
            document.getElementById("Layer1").style.top = ((Number(clientheight)/2) - 23) + "px";
            document.getElementById("Layer1").style.display="block";
}

function getLoadingVisibleSearch(){           
            document.getElementById("Layer1").style.left = 630 + "px";
            document.getElementById("Layer1").style.top = 300 + "px";
            document.getElementById("Layer1").style.display="block";
}


function featuredSearch(writerName,siteCountry){
if(writerName=='' || writerName=='Search' ) { 
		alert('Please enter keywords') 
		document.featuredWriterSearch.writerName.value="";
		document.featuredWriterSearch.writerName.focus();
		return;   
	}
	var frm =document.featuredWriterSearch;	
	frm.writerName.value=writerName;
	var urlToFile ="/TemplateAction?system_action=writer_search&name="+escape(UTF8.encode(writerName));
	urlToFile=ajaxURLModification(urlToFile);
	sendRequestBio(urlToFile, processRequest);       
	
 }
	
	//URL modification for AJAX cache problem
	function ajaxURLModification(url)
	{
		var randomNo = Math.random();
		if(randomNo < 0.1)
			url = url + '&ajaxABC='+randomNo;
		else if(randomNo > 0.1 && randomNo < 0.2)
			url = url + '&ajaxDEF='+randomNo;
		else if(randomNo > 0.2 && randomNo < 0.3)
			url = url + '&ajaxGHI='+randomNo;
		else if(randomNo > 0.3 && randomNo < 0.4)
			url = url + '&ajaxJKL='+randomNo;
		else if(randomNo > 0.4 && randomNo < 0.5)
			url = url + '&ajaxMNO='+randomNo;
		else if(randomNo > 0.5 && randomNo < 0.6)
			url = url + '&ajaxPQR='+randomNo;
		else if(randomNo > 0.6 && randomNo < 0.7)
			url = url + '&ajaxSTU='+randomNo;
		else if(randomNo > 0.7 && randomNo < 0.8)
			url = url + '&ajaxVWX='+randomNo;
		else if(randomNo > 0.8 && randomNo < 0.9)
			url = url + '&ajaxYZA='+randomNo;
		else 
			url = url + '&ajaxBCD='+randomNo;
		
		return url;
		
	}
function sendRequest(url, processChange){
	// branch for native XMLHttpRequest object	
	if (window.XMLHttpRequest) {
	    request2 = new XMLHttpRequest();
	    request2.onreadystatechange = processChange;
	    request2.open("GET", url, true);
	    request2.send(null);	
	// branch for IE/Windows ActiveX version
	} else if (window.ActiveXObject) {
	    request2 = new ActiveXObject("Microsoft.XMLHTTP");
	    if (request2) {
			//alert("hi");
	        request2.onreadystatechange = processChange;
	        request2.open("GET", url, true);		
	        request2.send(null);
	    }
	}
}
function sendRequestBio(url, processChange){
	// branch for native XMLHttpRequest object	
	if (window.XMLHttpRequest) {
	    request3 = new XMLHttpRequest();
	    request3.onreadystatechange = processChange;
	    request3.open("GET", url, true);
	    request3.send(null);	
	// branch for IE/Windows ActiveX version
	} else if (window.ActiveXObject) {
	    request3 = new ActiveXObject("Microsoft.XMLHTTP");
	    if (request3) {
			//alert("hi");
	        request3.onreadystatechange = processChange;
	        request3.open("GET", url, true);		
	        request3.send(null);
	    }
	}
}

function processRequest(){
	if(request3.readyState==4){	
	  	if(request3.status==200){
	  	var xmlDoc =request3.responseXML;
		var writerInfo =xmlDoc.getElementsByTagName('writer-info');
		if(writerInfo.length==0){  
			var messageTable ='<div id="FWrightsearchblock">';
			messageTable=messageTable+'<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td height="24" class="goldencolor fontbold" bgcolor="#5c5c5c">&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;Bio Title</span></td></tr><tr><td height="24" style="color:#ffffff;" bgcolor="#666666"><span class="txtLeftAlign" style="margin-left:10px;">Nothing Found to Display</span></td></tr></table></div>';
			document.getElementById('FWrightsearchblock').innerHTML = messageTable;
			showDiv('FWrightsearchblock');
			}else{
			var tableBuf ='<div id="FWrightsearchblock">';
			tableBuf = tableBuf  + '<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td height="24" class="goldencolor fontbold" bgcolor="#5c5c5c">&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;Bio Title</span></td></tr><tr><td align="left" valign="top" bgcolor="#5c5c5c"><div class="FWsearchscroll" style="#450px;"><table width="100%"  border="0" cellspacing="1" cellpadding="2">';
			var index=1;
			for(var i=0;i<writerInfo.length;i++){   
			var writerLink='';
			var talentId = writerInfo[i].childNodes[0].childNodes[0].nodeValue;
			var bioId = writerInfo[i].childNodes[5].childNodes[0].nodeValue;
			var bioTitle, dataId, languageCode, writerName, version, siteCountry,bulkId;
			if(writerInfo[i].childNodes[6].childNodes[0] != null){
				bioTitle = writerInfo[i].childNodes[6].childNodes[0].nodeValue;   
			}
			if(writerInfo[i].childNodes[7].childNodes[0] != null){
				dataId = writerInfo[i].childNodes[7].childNodes[0].nodeValue;   
			}
			if(writerInfo[i].childNodes[8].childNodes[0] != null){
				languageCode = writerInfo[i].childNodes[8].childNodes[0].nodeValue;   
			}
			if(writerInfo[i].childNodes[1].childNodes[0] != null){
				//writerName = UTF8.encode(writerInfo[i].childNodes[1].childNodes[0].nodeValue);   
				writerName = writerInfo[i].childNodes[1].childNodes[0].nodeValue;   
			}
			if(writerInfo[i].childNodes[12].childNodes[0] != null){
				version = writerInfo[i].childNodes[12].childNodes[0].nodeValue;   
			}
			if(writerInfo[i].childNodes[11].childNodes[0] != null){
				siteCountry = writerInfo[i].childNodes[11].childNodes[0].nodeValue;   
			}
			if(writerInfo[i].childNodes[15].childNodes[0] != null){
				bulkId = writerInfo[i].childNodes[15].childNodes[0].nodeValue;   
			}
			var trimedWriterName='';
			if(writerName.length>35){            
				writerName = writerName.replace(/@/g,' / ');            
				trimedWriterName=writerName.substr(0,25)+'...';                                     
			}else{   
					writerName = writerName.replace(/@/g,' / ');  
					trimedWriterName=writerName;
					//alert(writerName);
			}
			
			tableBuf = tableBuf+'<tr>';
			if(bioId!="0"){
				if(talentId=="0"){
					tableBuf = tableBuf+'<td height="23" bgcolor="#666666"><span class="writers_name"><a title=\''+replaceEscapedCharsWithChars(bioTitle)+'\' href="javascript:getWriterBio(\''+talentId+'\',\''+bioId+'\',\''+languageCode+'\',\''+version+'\',\''+dataId+'\',\''+siteCountry+'\',\''+bulkId+'\')">&nbsp;&nbsp;'+ index +'&nbsp;&nbsp;&nbsp;&nbsp;'+  replaceEscapedCharsWithChars(bioTitle) +'</a></span></td>';
					}else{
					tableBuf = tableBuf+'<td height="23" bgcolor="#666666"><span class="writers_name"><a title=\''+replaceEscapedCharsWithChars(writerName)+'\' href="javascript:getWriterBio(\''+talentId+'\',\''+bioId+'\',\''+languageCode+'\',\''+version+'\',\''+dataId+'\',\''+siteCountry+'\',\''+bulkId+'\')">&nbsp;&nbsp;'+ index +'&nbsp;&nbsp;&nbsp;&nbsp;'+  replaceEscapedCharsWithChars(bioTitle) +'<span class=\'writers_namebrack\' >  ( '+UTF8.decode(replaceEscapedCharsWithChars(trimedWriterName))+ ')</span>'+'</a></span></td>';	
					}
			
			}else{
			tableBuf = tableBuf+'<td height="23" bgcolor="#666666"><span class="writers_name"><a title=\''+replaceEscapedCharsWithChars(writerName)+'\' href="javascript:getWriterDetails(\''+talentId+'\',\''+escapeSpecialChars(writerName)+'\')">&nbsp;&nbsp;'+ index +'&nbsp;&nbsp;&nbsp;&nbsp<span class=\'writers_namebrack\' >  '+replaceEscapedCharsWithChars(trimedWriterName)+ '</span>'+'</a></span></td>';
			}
			tableBuf = tableBuf+'</tr>';       
			index++;
		}
		tableBuf = tableBuf+'</table></div></td></tr></table>';
		tableBuf = tableBuf+'</div>';
		document.getElementById('FWrightsearchblock').innerHTML = tableBuf;
		    }
		}
	}
}

// Used for mouseover image change for featuredwriter and new release section
function  swapThisImage(obj){
	// Image source
	var imgsrc = obj.src;
	//Checking if not scrolling not reached to last state
	if(obj.src.toString().indexOf("btm") != -1){
	if(enablingNext){
		// Checking if over found over image
		if(imgsrc.indexOf("mo") != -1) {
			obj.src = obj.src.toString().substr(0,obj.src.toString().length-7) + ".jpg";
		// If Over not found
		}else{
			obj.src = obj.src.toString().substr(0,obj.src.toString().length-4) + "_mo.jpg";
		}
	}
	}else{
		if(enablingPrev){
		// Checking if over found over image
		if(imgsrc.indexOf("mo") != -1) {
			obj.src = obj.src.toString().substr(0,obj.src.toString().length-7) + ".jpg";
		// If Over not found
		}else{
			obj.src = obj.src.toString().substr(0,obj.src.toString().length-4) + "_mo.jpg";
		}
	}
	}
}
//Used for mouseover image change for featured songs in homepage section
function  swapHomeFSImage(obj){
	// Image source
	var imgsrc = obj.src;
	//Checking if not scrolling not reached to last state
	if(obj.src.toString().indexOf("btm") != -1){
	if(enablingNext1){
		// Checking if over found over image
		if(imgsrc.indexOf("mo") != -1) {
			obj.src = obj.src.toString().substr(0,obj.src.toString().length-7) + ".jpg";
		// If Over not found
		}else{
			obj.src = obj.src.toString().substr(0,obj.src.toString().length-4) + "_mo.jpg";
		}
	}
	}else{
		if(enablingPrev1){
		// Checking if over found over image
		if(imgsrc.indexOf("mo") != -1) {
			obj.src = obj.src.toString().substr(0,obj.src.toString().length-7) + ".jpg";
		// If Over not found
		}else{
			obj.src = obj.src.toString().substr(0,obj.src.toString().length-4) + "_mo.jpg";
		}
	}
	}
}
function keyEventCode(e)
{
  if (!e)
	var e = window.event
	var keyCode =  e.which;
	if(!keyCode)
	  {
		 keyCode =  e.keyCode;
	 }	
  return keyCode;
}

function handleWritersSearchKeyPressEvent(e)
{
	if(keyEventCode(e) == 13){
		featuredSearch(document.featuredWriterSearch.writerName.value,document.featuredWriterSearch.searchCountry.value);
		return false;
	}
}
function loadDivWriter(contextRoot)
{
getHTMLContentForDiv('FWriterLeftDiv','/'+contextRoot+'/ActionServlet?system_action=displayPageletData&pageletType=FWLEFTDIV','text');
//getHTMLContentForDiv('FWriterRightDiv','/'+contextRoot+'/ActionServlet?system_action=displayPageletData&pageletType=FWRIGHTDIV','text');
}
function loadData(contextRoot)
{
getHTMLContentForDiv('homePage_videosBlock','/'+contextRoot+'/ActionServlet?system_action=displayPageletData&pageletType=VIDEOS','text');
getHTMLContentForDiv('homePage_newReleaseBlock','/'+contextRoot+'/ActionServlet?system_action=displayPageletData&pageletType=NEW RELEASE','text');
getHTMLContentForDiv('homePage_newsBlock','/'+contextRoot+'/ActionServlet?system_action=displayPageletData&pageletType=NEWS','text');
getHTMLContentForDiv('homePage_rightContent','/'+contextRoot+'/ActionServlet?system_action=displayPageletData&pageletType=FEATURED SONGS','text');

//getHTMLContentForDiv('FWriterRightDiv','/'+contextRoot+'/ActionServlet?system_action=displayPageletData&pageletType=FWRIGHTDIV','text');
}
function hideDiv(displayWriterSearch){
	document.getElementById(displayWriterSearch).style.visibility='hidden';
}

function showDiv(displayWriterSearch){
	document.getElementById(displayWriterSearch).style.visibility='visible';
}
function showLayer(LayerContent){
	var layer=document.getElementById(LayerContent).style.display;
	if(layer=='none')
	document.getElementById(LayerContent).style.display='block';
	else
	document.getElementById(LayerContent).style.display='none';
	
}
//Benji palyer
function BB_openBrWindow(theURL,winName) {
	var SongChesterWindow;
	var h = 285;
	var w = 368;
	var nTop = (screen.height - h) / 2;
	var nLeft = (screen.width - w) / 2;
	var features = "height=" + h +",width=" + w + ",top=" + nTop + ",left=" + nLeft+",resizable";
	if (window.document.all && SongChesterWindow) SongChesterWindow.close();
	SongChesterWindow= window.open(theURL,winName,features);
		SongChesterWindow.focus();
  }
  
//Tabs
function enableContent()
{
	divCtrls=document.getElementsByTagName("div");
	var liCtrls;
	var id;
	
	for(i=0;i<divCtrls.length;i++)
	{
		try
		{
			
			if(divCtrls[i].id.indexOf('Content')>-1)
			{
				id=divCtrls[i].id.split("~")[1];
				var menu;
				menu=document.getElementById('menu~'+id);
					if(menu.className=='current')
						divCtrls[i].style.display='block';
					else
						divCtrls[i].style.display='none';	
					
			}
						
		}
		catch(exception)
		{
		}	
	}
}


function setID(liCtrl)
{
	var liCtrls,i;
	var liItems = document.getElementById("header");
		
	liCtrls=liItems.getElementsByTagName("li");
	
	//liCtrls = shareClass("li","menu");
	
	for(i=0;i<liCtrls.length;i++)
	{
		try
		{
			liCtrls[i].className='';
						
		}
		catch(exception)
		{
		}	
	}	
	liCtrl.className='current';
	enableContent();
	
}


function escapeString(s) {	
	var eChars = ["\\", "'", '"'];
	var lasti = eChars.length;
	for (var i = 0; i < lasti; i++) {
	var sArray = s.split(eChars[i]);
	var lastj = sArray.length;
	s = '';
	for (var j = 0; j < lastj; j++) {
		s += sArray[j] + '\\' + eChars[i];
	}
	}
	var last = s.length - 2*eChars.length;	
	return s.substring(0, last);
}

//Tooltip for song search pages - Added by Maria Joe
function showtip(current,e,text){
	if (document.all||document.getElementById){
		thetitle=text.split('<br>')
		if (thetitle.length>1){
			thetitles=''
			for (i=0;i<thetitle.length;i++)
				thetitles+=thetitle[i]
			current.title=thetitles
		}
		else
			current.title=text
	}		
	else if (document.layers){
		document.tooltip.document.write('<layer bgColor="white" style="border:1px solid black;font-size:12px;">'+text+'</layer>')
		document.tooltip.document.close()
		document.tooltip.left=e.pageX+5
		document.tooltip.top=e.pageY+5
		document.tooltip.visibility="show"
	}
}
function hidetip(){
	if (document.layers)
	document.tooltip.visibility="hidden"
}
		var siteArea;
		var dataId;
		var systemAction;
		var actionname;
		var siteCountry;
		var authId;
		var pId;
		var pSubId;
	 
	function showtemplate(sitearea,dataid,systemaction,action,sitecountry,aid,pid,psubid) {
		siteArea = sitearea;
		dataId = dataid;
		systemAction = systemaction;
		actionname = action;
		siteCountry = sitecountry;
		authId = aid;
		pId = pid;
		pSubId = psubid;
		//var url = "/TemplateAction?system_action=checkStatus&dataid="+dataId;
		//url = ajaxURLModification(url);
		//sendRequest(url, validateStatus);
		
		document.siteDataForm.action="/TemplateAction";
	  	document.siteDataForm.system_action.value=systemAction;
		document.siteDataForm.actionType.value=actionname;
		document.siteDataForm.country.value=siteCountry;
		document.siteDataForm.dataId.value=dataId;
		document.siteDataForm.siteArea.value=siteArea;
		//alert(authId + "->" +pId+ "->" + pSubId);
		document.siteDataForm.aid.value=authId;
		document.siteDataForm.pid.value=pId;
		document.siteDataForm.psubid.value=pSubId;
				
		document.siteDataForm.method="post";
		document.siteDataForm.target="_top";
		document.siteDataForm.submit();  	 
			
	}
	// added for featured writer edit
	function showbiotemplate(sitearea,dataid,bulkid,bioid,systemaction,action,sitecountry,aid,pid,psubid,langcode,version) {
		siteArea = sitearea;
		dataId = dataid;
		bulkId=bulkid;
		bioId=bioid;
		systemAction = systemaction;
		actionname = action;
		siteCountry = sitecountry;
		authId = aid;
		pId = pid;
		pSubId = psubid;
		langCode=langcode;
		bioVersion=version;
		//var url = "/TemplateAction?system_action=checkStatus&dataid="+dataId;
		//url = ajaxURLModification(url);
		//sendRequest(url, validateBioStatus);
		document.siteDataBioForm.action="/TemplateAction";
	  	document.siteDataBioForm.system_action.value=systemAction;
		document.siteDataBioForm.actionType.value=actionname;
		document.siteDataBioForm.country.value=siteCountry;
		document.siteDataBioForm.dataId.value=dataId;
		document.siteDataBioForm.bulkId.value=bulkId;
		document.siteDataBioForm.bioId.value=bioId;
		document.siteDataBioForm.siteArea.value=siteArea;
		document.siteDataBioForm.aid.value=authId;
		document.siteDataBioForm.pid.value=pId;
		document.siteDataBioForm.psubid.value=pSubId;
		document.siteDataBioForm.bioLang.value=langCode;		
		document.siteDataBioForm.bioVersion.value=bioVersion;			
		
		document.siteDataBioForm.method="post";
		document.siteDataBioForm.target="_top";
		document.siteDataBioForm.submit();  	 
	}
	function validateBioStatus(){
	if(request2.readyState==4){
	    if(request2.status==200){
		   var status = request2.responseText;		 
		   if(status!=null&&status == "pending"){
		   	alert("This content is already in progress....");
		  	return;		  	 
		   }else{
		  	document.siteDataBioForm.action="/TemplateAction";
		  	document.siteDataBioForm.system_action.value=systemAction;
			document.siteDataBioForm.actionType.value=actionname;
			document.siteDataBioForm.country.value=siteCountry;
			document.siteDataBioForm.dataId.value=dataId;
			document.siteDataBioForm.bioId.value=bioId;
			document.siteDataBioForm.bulkId.value=bulkId;
			document.siteDataBioForm.siteArea.value=siteArea;
			document.siteDataBioForm.aid.value=authId;
			document.siteDataBioForm.pid.value=pId;
			document.siteDataBioForm.psubid.value=pSubId;
			document.siteDataBioForm.bioLang.value=langCode;		
			document.siteDataBioForm.bioVersion.value=bioVersion;			
			
			document.siteDataBioForm.method="post";
			document.siteDataBioForm.target="_top";
			document.siteDataBioForm.submit();  	 
		   }
		   }else {
	        alert("There was a problem retrieving the XML data:\n" + request2.statusText);
		}
	}
}
	function deletePublishData(sitearea,dataid,version,section,persentationid) {
		if(confirm("Do you want to Unpublish this data! Data will be no longer available after unpublish.")) 
		{
//			document.getElementById("Layer1").style.display="block";
			document.siteDataForm.action="/TemplateAction";
			document.siteDataForm.system_action.value="delete";
			document.siteDataForm.dataId.value=dataid;
			document.siteDataForm.siteArea.value=sitearea;
			document.siteDataForm.version.value=version;
			document.siteDataForm.section.value=section;
			document.siteDataForm.pid.value=persentationid;
			//alert(sitearea + "->" + dataid + "->" + version);
			document.siteDataForm.method="post";
			document.siteDataForm.submit();  	 
//			document.getElementById("Layer1").style.display="none";
		}
	}



	function validateStatus(){
	if(request2.readyState==4){
	    if(request2.status==200){
		   var status = request2.responseText;		 
		   if(status!=null&&status == "pending"){
		   	alert("This content is already in progress....");
		  	return;		  	 
		   }else{
		  	document.siteDataForm.action="/TemplateAction";
		  	document.siteDataForm.system_action.value=systemAction;
			document.siteDataForm.actionType.value=actionname;
			document.siteDataForm.country.value=siteCountry;
			document.siteDataForm.dataId.value=dataId;
			document.siteDataForm.siteArea.value=siteArea;
			//alert(authId + "->" +pId+ "->" + pSubId);
			document.siteDataForm.aid.value=authId;
			document.siteDataForm.pid.value=pId;
			document.siteDataForm.psubid.value=pSubId;
					
			document.siteDataForm.method="post";
			document.siteDataForm.target="_top";
			document.siteDataForm.submit();  	 
		   }
		   }else {
	        alert("There was a problem retrieving the XML data:\n" + request2.statusText);
		}
	}
}
	
	//added by Narasimha
	function handleLoadDepts(){
		if(request2.readyState==4){
	    if(request2.status==200){
		var deparmentInfo = request2.responseText;
			if(deparmentInfo!=""){
				onDepartmentSelect(deparmentInfo);
			}
           }else{
	   	alert("There was a problem with request.... ");
	   	}
	}
	}
// added by omprakash jaiswal

function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
}

function charsLimit(fieldLength,fieldName,formName)
{  
	
	
	var tex =document.formName.fieldName.value;
	
	var len = tex.length;
	if(len > fieldLength){
		tex = tex.substring(0,fieldLength);
		document.formName.fieldName.value =tex;
		return false;
	}
	if(len==fieldLength)
		{
			alert("Number of characters should not exceed "+fieldLength);
			document.formName.fieldName.focus();
		}
}

function doSpecialCharcheck(fieldName) {
	var mikExp = /[$#@%^*+{}`~=|?><!]/;
	var strPass = document.getElementById(fieldName).value;
	var strLength = strPass.length;
	var lchar = document.getElementById(fieldName).value.charAt((strLength) - 1);
	if(lchar.search(mikExp) != -1) {
		var tst = document.getElementById(fieldName).value.substring(0, (strLength) - 1);
		document.getElementById(fieldName).value = tst;
	}
	if(lchar.search(mikExp) != -1){
		alert("The following characters\n\r\n\r@ ! $ % ^ @ * # { + } ` ~ = ? < > \n\r\n\r are not allowed!\n");
	}

}

 function checkEmailId(address) {	
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;   
	     if(reg.test(address) == false) {
	      alert("Please enter an valid E-mail ID.")
	      return false;
	     }
     return true;	
	}
	function validatePhoneNumber(phoneNumber){
		var   digits="0123456789-"  
		for(i=0; i<phoneNumber.length; i++)
			{
				 if (digits.indexOf(phoneNumber.charAt(i))<0){
					return false;  
				 } else{
					return true;	 
				 }
				 }
	}
	// method for playing video from home page	
	function gotoVideoPage(flvfile,labelname,writername,songtitle,dataid,version){
			var sform=document.homepagevideo;
			sform.flvfile.value=flvfile;
			sform.labelname.value=labelname;
			sform.writername.value=writername;
			sform.songtitle.value=songtitle;
			sform.dataid.value=dataid;
			sform.version.value=version;
			sform.action = "/video_display.jsp";
			sform.submit();
	}
var winType;
var newmusicwindow;
function playSingle(assetid,type){	
		isbenziPlayerOpen=true;
		if(bfirst == true){			
			//closeWindow();
			closePlayer();
		}
   		var urlToFile ="/TemplateAction?system_action=playLayer&assetid="+assetid+"&type="+type;
		if(arguments[2] == 'new'){
			winType = arguments[2];
		}else{
			winType = 'self';
		}
   		sendSingleRequest(urlToFile, processSingleRequest);
		mmediaValue = assetid;
		mindexValue = type; 
		bfirst = true;
		window.scrollTo(0,0);
      }

   function sendSingleRequest(urlSingle, processChange){
	// branch for native XMLHttpRequest object	

	if (window.XMLHttpRequest) {
	    request = new XMLHttpRequest();
	    request.onreadystatechange = processChange;
	    request.open("GET", urlSingle, true);
	    request.send(null);	
	// branch for IE/Windows ActiveX version
	} else if (window.ActiveXObject) {
	    request = new ActiveXObject("Microsoft.XMLHTTP");
	    if (request) {
	        request.onreadystatechange = processChange;
	        request.open("GET", urlSingle, true);		
	        request.send();
	    }
	}

	
}
function closeWindow(){
    try{
		if(newmusicwindow && !newmusicwindow.closed){
			newmusicwindow.close();
		}
	}catch(e){
		return false;	
	}
}
var vidPaneID ;
var mpSingleAssetId;
var mpSinglesongUrl;
var mpSingleAssetTitle;
var mpSingleArtistName;
var mpSingleAlbumTitle;
var mpSingleAlbumTitle;
var mpSingleLabelName;
var mpSingleArtistName;
function processSingleRequest(){
	if(request.readyState==4){		
		  	if(request.status==200){
		  	var xmlDoc =request.responseXML;
		  	var playsingle =xmlDoc.getElementsByTagName('play-single');			
		  	var assetId ='';
			var assetTitle ='';
			var songUrl ='';
			var composer = '';
			var artistName ='';
			var releaseDate ='';
			var albumTitle = '';
			var labelName ='';
			var type='';
		  	for(var i=0;i<playsingle.length;i++){
				mpSingleAssetId = assetId = playsingle[i].childNodes[0].childNodes[0].nodeValue;
				mpSingleAssetTitle = assetTitle = escapeSpecialChars(playsingle[i].childNodes[1].childNodes[0].nodeValue);
				mpSinglesongUrl = songUrl = playsingle[i].childNodes[2].childNodes[0].nodeValue;
				composer = escapeSpecialChars(playsingle[i].childNodes[3].childNodes[0].nodeValue);
				mpSingleArtistName = artistName = escapeSpecialChars(playsingle[i].childNodes[4].childNodes[0].nodeValue);
				mpSingleReleaseDate = releaseDate = playsingle[i].childNodes[5].childNodes[0].nodeValue;
				mpSingleAlbumTitle = albumTitle = escapeSpecialChars(playsingle[i].childNodes[6].childNodes[0].nodeValue);
				mpSingleLabelName = labelName = escapeSpecialChars(playsingle[i].childNodes[7].childNodes[0].nodeValue);
				type = playsingle[i].childNodes[8].childNodes[0].nodeValue;
			}
			vidPaneID = document.getElementById('mpcontainer');
			vidPaneID.innerHTML = "";
			vidPaneID.style.display = "none";
			if(type=="single"){
         	 vidPaneID.style.display='block';
			// <![CDATA[
			   var so = new SWFObject("/resources/flash/player/b2baudioplayer.swf", "b2baudioplayer", "240", "170", "9");
			   so.addParam("wmode", "window");
			   so.addParam("flashvars", "playType=single&repeat_playlist=true&autoplay=true&song_url="+songUrl+"&song_title="+assetTitle+"&artist="+artistName+"&year_tag="+releaseDate+"&album_tag="+albumTitle+"&label_tag="+labelName+"&_window="+winType+"");
			   so.write(vidPaneID);
			// ]]> 
//------------------------------------------------------------------- IE Start
/*			var nameanchor = document.createElement('a');			
			nameanchor.setAttribute('name','playeranchorsw');
			alert(nameanchor.name);
			nameanchor.style.width = '0px';
			nameanchor.style.height = 'opx';			
			if(winType == 'self'){
				vidPaneID.appendChild(nameanchor); 
			}			
			if(winType == 'self'){
				var urlpath = window.location.href;				
				if(window.location.hash == "#playeranchorsw"){
					urlpath = urlpath.replace(/#playeranchorsw/g,"");
				}
				window.location.href = urlpath +"#playeranchorsw";
			}*/
//------------------------------------------------------------------- IE End
			}
		}
	}
}
if(top === self){}else{document.write("<script src='/resources/script/B2BMusicLoader.js' type='text/javascript' ></script>");
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	if(isIE){
		document.write("<style type='text/css'>");
		document.write(".playSingleStyle {position: absolute;display: none;padding:5px 3px;width: 240px;					background-image:url(../../resources/images/benji_grip.png);_background-image:none;background-repeat:no-repeat;height: 190px !important; cursor: move;z-index:10000;padding-top:15px;}.playSingleStyle {display: inline-block;height:171px; width:246px !important;}.playSingleStyle {					filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../resources/images/benji_grip.png');}");
		document.write("</style>");
	}
	//if(isIE){try{}catch(e){}}
}
// This document also closes music player if user pressed on Close button
function closePlayer(){
	vidPaneID.innerHTML = "";
	vidPaneID.style.display = "none";
}
 function openPopup(assetid,songurl,songtitle, artist,type){
 		var url = "";
		if(type == "single")
		 {
		url = "/edeco/songplayer/benji_player.jsp?type=single&assetid="+assetid+"&song_url="+songurl+"&song_title="+songtitle+"&artist="+artist;	
		//alert(url);
		window.open(url,'benji','width=266,height=375');
		vidPaneID.style.display='none';
        vidPaneID.innerHTML='';
			
		} 
 }
	 function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}
	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	
	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}
	
	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
 	function hidePlayer(){
		 	isbenziPlayerOpen=false;
			vidPaneID.style.display='none';
			vidPaneID.innerHTML=''; 
		}
    
   function moveHandler(e){
      if (e == null) { e = window.event } 
      if (e.button<=1&&dragOK){
         savedTarget.style.left=e.clientX-dragXoffset+'px';
         savedTarget.style.top=e.clientY-dragYoffset+'px';
         return false;
      }
   }

   function cleanup(e) {
      document.onmousemove=null;
      document.onmouseup=null;
      savedTarget.style.cursor=orgCursor;
      dragOK=false;
   }

   function dragHandler(e){
      var htype='-moz-grabbing';
      if (e == null) { e = window.event; htype='move';} 
      var target = e.target != null ? e.target : e.srcElement;
      orgCursor=target.style.cursor;
      if (target.className=="playSingleStyle") {
         savedTarget=target;       
         target.style.cursor=htype;
         dragOK=true;
         dragXoffset=e.clientX-parseInt(vidPaneID.style.left);
         dragYoffset=e.clientY-parseInt(vidPaneID.style.top);
         document.onmousemove=moveHandler;
         document.onmouseup=cleanup;
         return false;
      }
   }
   function replaceEscapedCharsWithChars(s){
		if(s!=null && s!=''){
			s=s.replace(/\^apos\^/g,"'");
			s=s.replace(/\^quot\^/g,'"');
			s=s.replace(/\^at\^/g,'@');
			s=s.replace(/\^hash\^/g,'#');
			s=s.replace(/\^lt\^/g,'<');
			s=s.replace(/\^amp\^/g,'&');	
			s=s.replace(/\^gt\^/g,'>');
				
		}
		return s;
   }
   function escapeSpecialChars(s){
		if(s!=null && s!=''){
			s=s.replace(/'/g,"^apos^");
			s=s.replace(/"/g,'^quot^');
			s=s.replace(/@/g,'^at^');
			s=s.replace(/#/g,'^hash^');
			s=s.replace(/</g,'^lt^');
			s=s.replace(/>/g,'^gt^');
		}
		return s;
   }
   function replaceEscapedCharsWithCharsForUI(s){
		if(s!=null && s!=''){
			s=s.replace(/"/g,'&quot;');
		}
		return s;
   }
	 document.onmousedown=dragHandler;

	 // added By Ravindra for Chart template suggestion box implementation

if (typeof(bsn) == "undefined")
	_b = bsn = {};

if (typeof(_b.Autosuggest) == "undefined")
	_b.Autosuggest = {};
//else
	//alert("Autosuggest is already set!");

_b.AutoSuggest = function (id, param){
	// no DOM - give up!
	//
	if (!document.getElementById)
		return 0;
	// get field via DOM
	//
	this.fld = _b.DOM.gE(id);

	if (!this.fld)
		return 0;
	// init variables
	//
	this.sInp 	= "";
	this.nInpC 	= 0;
	this.aSug 	= [];
	this.iHigh 	= 0;
	
	// parameters object
	//
	this.oP = param ? param : {};
	
	// defaults	
	//
	var k, def = {minchars:1, meth:"get", varname:"input", className:"autosuggest", timeout:2500, delay:500, offsety:-5, shownoresults: true, noresults: "", maxheight: 250, cache: true, maxentries: 25};
	for (k in def)
	{
		if (typeof(this.oP[k]) != typeof(def[k]))
			this.oP[k] = def[k];
	}
	// set keyup handler for field
	// and prevent autocomplete from client
	//
	var p = this;
	// NOTE: not using addEventListener because UpArrow fired twice in Safari
	//_b.DOM.addEvent( this.fld, 'keyup', function(ev){ return pointer.onKeyPress(ev); } );
	this.fld.onkeypress 	= function(ev){ return p.onKeyPress(ev); };
	this.fld.onkeyup 		= function(ev){ return p.onKeyUp(ev); };
	this.fld.setAttribute("autocomplete","off");
};

_b.AutoSuggest.prototype.onKeyPress = function(ev){
	var key = (window.event) ? window.event.keyCode : ev.keyCode;
	// set responses to keydown events in the field
	// this allows the user to use the arrow keys to scroll through the results
	// ESCAPE clears the list
	// TAB sets the current highlighted value
	//
	var RETURN = 13;
	var TAB = 9;
	var ESC = 27;
	var bubble = 1;
	switch(key){
		case RETURN:
			this.setHighlightedValue();
			bubble = 0;
			break;

		case ESC:
			this.clearSuggestions();
			break;
	}

	return bubble;
};



_b.AutoSuggest.prototype.onKeyUp = function(ev){
	var key = (window.event) ? window.event.keyCode : ev.keyCode;
	// set responses to keydown events in the field
	// this allows the user to use the arrow keys to scroll through the results
	// ESCAPE clears the list
	// TAB sets the current highlighted value
	//
	var ARRUP = 38;
	var ARRDN = 40;
	var bubble = 1;
	switch(key){
		case ARRUP:
			this.changeHighlight(key);
			bubble = 0;
			break;
		case ARRDN:
			this.changeHighlight(key);
			bubble = 0;
			break;
		default:
			this.getSuggestions(this.fld.value);
	}

	return bubble;
};

_b.AutoSuggest.prototype.getSuggestions = function (val){
	
	// if input stays the same, do nothing
	//
	if (val == this.sInp)
		return 0;
	
	// kill list
	//
	_b.DOM.remE(this.idAs);
	this.sInp = val;
	// input length is less than the min required to trigger a request
	// do nothing
	//
	if (val.length < this.oP.minchars){
		this.aSug = [];
		this.nInpC = val.length;
		return 0;
	}
	var ol = this.nInpC; // old length
	this.nInpC = val.length ? val.length : 0;
	// if caching enabled, and user is typing (ie. length of input is increasing)
	// filter results out of aSuggestions from last request
	//
	var l = this.aSug.length;
	if (this.nInpC > ol && l && l<this.oP.maxentries && this.oP.cache){
		var arr = [];
		for (var i=0;i<l;i++){
			if (this.aSug[i].value.substr(0,val.length).toLowerCase() == val.toLowerCase())
				arr.push( this.aSug[i] );
		}
		this.aSug = arr;
		this.createList(this.aSug);
		return false;
	}
	else
	// do new request
	//
	{
		var pointer = this;
		var input = this.sInp;
		clearTimeout(this.ajID);
		this.ajID = setTimeout( function() { pointer.doAjaxRequest(input) }, this.oP.delay );
	}

	return false;
};

_b.AutoSuggest.prototype.doAjaxRequest = function (input){
	// check that saved input is still the value of the field
	//
	if (input != this.fld.value)
		return false;
	var fieldName = this.fld.name;
	if(fieldName == 'writerName'){
		var writerOption = document.featuredWriterSearch.SelectSearch;
		var selectedOption = writerOption.options[writerOption.selectedIndex].value;
		if(selectedOption != 'WS'){
			return false;
		}
	}

	var pointer = this;
	// create ajax request
	//
	if (typeof(this.oP.script) == "function")
		var url = this.oP.script(encodeURIComponent(this.sInp));
	else
		var url = this.oP.script+this.oP.varname+"="+encodeURIComponent(this.sInp);
	
	if (!url)
		return false;
	
	var meth = this.oP.meth;
	var input = this.sInp;
	
	var onSuccessFunc = function (req) { pointer.setSuggestions(req, input) };
	var onErrorFunc = function (status) { alert("AJAX error: "+status); };
	//var onErrorFunc = function (status) { alert("AJAX error: "+status); };

	var myAjax = new _b.Ajax();
	myAjax.makeRequest( url, meth, onSuccessFunc, onErrorFunc );
};


_b.AutoSuggest.prototype.setSuggestions = function (req, input){
	// if field input no longer matches what was passed to the request
	// don't show the suggestions
	//
	if (input != this.fld.value)
		return false;
	this.aSug = [];
	if (this.oP.json){
		var jsondata = eval('(' + req.responseText + ')');
		for (var i=0;i<jsondata.results.length;i++){
			this.aSug.push(  { 'id':jsondata.results[i].id, 'value':jsondata.results[i].value, 'info':jsondata.results[i].info }  );
		}
	}else{
		var xml = req.responseXML;
		// traverse xml
		//
		var results = xml.getElementsByTagName('results')[0].childNodes;
		for (var i=0;i<results.length;i++){
			if (results[i].hasChildNodes())
				this.aSug.push(  { 'id':results[i].getAttribute('id'), 'value':results[i].childNodes[0].nodeValue, 'info':results[i].getAttribute('info') }  );
		}
	
	}
	
	this.idAs = "as_"+this.fld.id;
	this.createList(this.aSug);

};

_b.AutoSuggest.prototype.createList = function(arr){
	var pointer = this;
	// get rid of old list
	// and clear the list removal timeout
	//
	_b.DOM.remE(this.idAs);
	this.killTimeout();
	
	// if no results, and shownoresults is false, do nothing
	//
	if (arr.length == 0 && !this.oP.shownoresults)
		return false;
	// create holding div
	//
	var div = _b.DOM.cE("div", {id:this.idAs, className:this.oP.className});	
	
	var hcorner = _b.DOM.cE("div", {className:"as_corner"});
	var hbar = _b.DOM.cE("div", {className:"as_bar"});
	var header = _b.DOM.cE("div", {className:"as_header"});
	header.appendChild(hcorner);
	header.appendChild(hbar);
	div.appendChild(header);
	// create and populate ul
	//
	var ul = _b.DOM.cE("ul", {id:"as_ul"});
	
	// loop throught arr of suggestions
	// creating an LI element for each suggestion
	//
	for (var i=0;i<arr.length;i++){
		// format output with the input enclosed in a EM element
		// (as HTML, not DOM)
		//
		var val = arr[i].value;
		var st = val.toLowerCase().indexOf( this.sInp.toLowerCase() );
		var output = val.substring(0,st) + "<em>" + val.substring(st, st+this.sInp.length) + "</em>" + val.substring(st+this.sInp.length);
		
		
		var span 		= _b.DOM.cE("span", {}, output, true);
		if (arr[i].info != ""){
			var br			= _b.DOM.cE("br", {});
			span.appendChild(br);
			var small		= _b.DOM.cE("small", {},"");
//			var small		= _b.DOM.cE("small", {}, arr[i].info);
			span.appendChild(small);
		}
		
		var a 			= _b.DOM.cE("a", { href:"#" });
		var tl 		= _b.DOM.cE("span", {className:"tl"}, " ");
		var tr 		= _b.DOM.cE("span", {className:"tr"}, " ");
		a.appendChild(tl);
		a.appendChild(tr);
		a.appendChild(span);
		a.name = i+1;
		a.onclick = function () { pointer.setHighlightedValue(); return false; };
		a.onmouseover = function () { pointer.setHighlight(this.name); };
		
		var li = _b.DOM.cE(  "li", {}, a  );
		
		ul.appendChild( li );
	}
	// no results
	//
	if (arr.length == 0 && this.oP.shownoresults){
		var li = _b.DOM.cE(  "li", {className:"as_warning"}, this.oP.noresults  );
		ul.appendChild( li );
	}
	if (arr.length!= 0){
	div.appendChild( ul );
	var fcorner = _b.DOM.cE("div", {className:"as_corner"});
	var fbar = _b.DOM.cE("div", {className:"as_bar"});
	var footer = _b.DOM.cE("div", {className:"as_footer"});
	footer.appendChild(fcorner);
	footer.appendChild(fbar);
	div.appendChild(footer);
	// get position of target textfield
	// position holding div below it
	// set width of holding div to width of field
	//
	var pos = _b.DOM.getPos(this.fld);
	
	div.style.left 		= pos.x + "px";
	div.style.top 		= ( pos.y + this.fld.offsetHeight + this.oP.offsety ) + "px";
	div.style.width 	= this.fld.offsetWidth + "px";
	// set mouseover functions for div
	// when mouse pointer leaves div, set a timeout to remove the list after an interval
	// when mouse enters div, kill the timeout so the list won't be removed
	
	// Ravindra 

	div.onmouseover 	= function(){ pointer.killTimeout() };
	div.onmouseout 		= function(){ pointer.resetTimeout() };
	// add DIV to document
	//
	document.getElementsByTagName("body")[0].appendChild(div);}
	// currently no item is highlighted
	//
	this.iHigh = 0;
	
	// remove list after an interval
	//
	//var pointer = this;
	//this.toID = setTimeout(function () { pointer.clearSuggestions() }, this.oP.timeout);
};


_b.AutoSuggest.prototype.changeHighlight = function(key){	
	var list = _b.DOM.gE("as_ul");
	if (!list)
		return false;
	
	var n;
	if (key == 40)
		n = this.iHigh + 1;
	else if (key == 38)
		n = this.iHigh - 1;
	
	if (n > list.childNodes.length)
		n = list.childNodes.length;
	if (n < 1)
		n = 1;
	this.setHighlight(n);
};

_b.AutoSuggest.prototype.setHighlight = function(n){
	var list = _b.DOM.gE("as_ul");
	if (!list)
		return false;
	
	if (this.iHigh > 0)
		this.clearHighlight();
	
	this.iHigh = Number(n);
	list.childNodes[this.iHigh-1].className = "as_highlight";
	this.killTimeout();
};


_b.AutoSuggest.prototype.clearHighlight = function(){
	var list = _b.DOM.gE("as_ul");
	if (!list)
		return false;
	
	if (this.iHigh > 0){
		list.childNodes[this.iHigh-1].className = "";
		this.iHigh = 0;
	}
};


_b.AutoSuggest.prototype.setHighlightedValue = function (){
	if (this.iHigh)
	{
		this.sInp = this.fld.value = this.aSug[ this.iHigh-1 ].value;
		// move cursor to end of input (safari)
		//
		this.fld.focus();
		if (this.fld.selectionStart)
			this.fld.setSelectionRange(this.sInp.length, this.sInp.length);
		
		this.clearSuggestions();
		// pass selected object to callback function, if exists
		//
		if (typeof(this.oP.callback) == "function")
			this.oP.callback( this.aSug[this.iHigh-1] );
	}
};

_b.AutoSuggest.prototype.killTimeout = function(){
	clearTimeout(this.toID);
};

_b.AutoSuggest.prototype.resetTimeout = function(){
	clearTimeout(this.toID);
	var pointer = this;
	this.toID = setTimeout(function () { pointer.clearSuggestions() }, 1000);
};

_b.AutoSuggest.prototype.clearSuggestions = function (){
	this.killTimeout();
	var ele = _b.DOM.gE(this.idAs);
	var pointer = this;
	if (ele){
		var fade = new _b.Fader(ele,1,0,250,function () { _b.DOM.remE(pointer.idAs) });
	}
};

// AJAX PROTOTYPE _____________________________________________
if (typeof(_b.Ajax) == "undefined")
	_b.Ajax = {};


_b.Ajax = function (){
	this.req = {};
	this.isIE = false;
};

_b.Ajax.prototype.makeRequest = function (url, meth, onComp, onErr){
	
	if (meth != "POST")
		meth = "GET";
	
	this.onComplete = onComp;
	this.onError = onErr;
	var pointer = this;
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest){
		this.req = new XMLHttpRequest();
		this.req.onreadystatechange = function () { pointer.processReqChange() };
		this.req.open("GET", url, true); //
		this.req.send(null);
	// branch for IE/Windows ActiveX version
	}else if (window.ActiveXObject){
		this.req = new ActiveXObject("Microsoft.XMLHTTP");
		if (this.req)
		{
			this.req.onreadystatechange = function () { pointer.processReqChange() };
			this.req.open(meth, url, true);
			this.req.send();
		}
	}
};


_b.Ajax.prototype.processReqChange = function(){
	
	// only if req shows "loaded"
	if (this.req.readyState == 4) {
		// only if "OK"
		if (this.req.status == 200){
			this.onComplete( this.req );
		} else {
			this.onError( this.req.status );
		}
	}
};


// DOM PROTOTYPE _____________________________________________

if (typeof(_b.DOM) == "undefined")
	_b.DOM = {};
/* create element */
_b.DOM.cE = function ( type, attr, cont, html ){
	var ne = document.createElement( type );
	if (!ne)
		return 0;
		
	for (var a in attr)
		ne[a] = attr[a];
	
	var t = typeof(cont);
	
	if (t == "string" && !html)
		ne.appendChild( document.createTextNode(cont) );
	else if (t == "string" && html)
		ne.innerHTML = cont;
	else if (t == "object")
		ne.appendChild( cont );

	return ne;
};



/* get element */
_b.DOM.gE = function ( e )
{
	var t=typeof(e);
	if (t == "undefined")
		return 0;
	else if (t == "string")
	{
		var re = document.getElementById( e );
		if (!re)
			return 0;
		else if (typeof(re.appendChild) != "undefined" )
			return re;
		else
			return 0;
	}
	else if (typeof(e.appendChild) != "undefined")
		return e;
	else
		return 0;
};



/* remove element */
_b.DOM.remE = function ( ele )
{
	var e = this.gE(ele);
	
	if (!e)
		return 0;
	else if (e.parentNode.removeChild(e))
		return true;
	else
		return 0;
};



/* get position */
_b.DOM.getPos = function ( e )
{
	var e = this.gE(e);

	var obj = e;

	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	
	var obj = e;
	
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;

	return {x:curleft, y:curtop};
};
// FADER PROTOTYPE _____________________________________________
if (typeof(_b.Fader) == "undefined")
	_b.Fader = {};

_b.Fader = function (ele, from, to, fadetime, callback){	
	if (!ele)
		return 0;
	
	this.e = ele;
	
	this.from = from;
	this.to = to;
	
	this.cb = callback;
	
	this.nDur = fadetime;
		
	this.nInt = 50;
	this.nTime = 0;
	
	var p = this;
	this.nID = setInterval(function() { p._fade() }, this.nInt);
};




_b.Fader.prototype._fade = function(){
	this.nTime += this.nInt;
	
	var ieop = Math.round( this._tween(this.nTime, this.from, this.to, this.nDur) * 100 );
	var op = ieop / 100;
	
	if (this.e.filters) // internet explorer
	{
		try{
			this.e.filters.item("DXImageTransform.Microsoft.Alpha").opacity = ieop;
		} catch (e) { 
			// If it is not set initially, the browser will throw an error.  This will set it if it is not set yet.
			this.e.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity='+ieop+')';
		}
	}
	else // other browsers
	{
		this.e.style.opacity = op;
	}
	
	
	if (this.nTime == this.nDur)
	{
		clearInterval( this.nID );
		if (this.cb != undefined)
			this.cb();
	}
};



_b.Fader.prototype._tween = function(t,b,c,d)
{
	return b + ( (c-b) * (t/d) );
};

// ends here Ravindra 
/**
	*  UTF-8 data encode / decode
	**/	 
	var UTF8 = { 
		// public method for url encoding
		encode : function (string) {
			string = string.replace(/\r\n/g,"\n");
			var utftext = "";	 
			for (var n = 0; n < string.length; n++) {	 
				var c = string.charCodeAt(n);	 
				if (c < 128) {
					utftext += String.fromCharCode(c);
				}
				else if((c > 127) && (c < 2048)) {
					utftext += String.fromCharCode((c >> 6) | 192);
					utftext += String.fromCharCode((c & 63) | 128);
				}
				else {
					utftext += String.fromCharCode((c >> 12) | 224);
					utftext += String.fromCharCode(((c >> 6) & 63) | 128);
					utftext += String.fromCharCode((c & 63) | 128);
				}	 
			}	 
			return utftext;
		},	 
		// public method for url decoding
		decode : function (utftext) {
			var string = "";
			var i = 0;
			var c = c1 = c2 = 0;	 
			while ( i < utftext.length ) {	 
				c = utftext.charCodeAt(i);	 
				if (c < 128) {
					string += String.fromCharCode(c);
					i++;
				}
				else if((c > 191) && (c < 224)) {
					c2 = utftext.charCodeAt(i+1);
					string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
					i += 2;
				}
				else {
					c2 = utftext.charCodeAt(i+1);
					c3 = utftext.charCodeAt(i+2);
					string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
					i += 3;
				} 
			}	 
			return string;
		}	 
	}
	
	//------------------------------------------------
	//START OF WORLDWIDE DIRECTORY STAFF REORDER CODE
	//------------------------------------------------
	function swapRowUp(chosenRow) {
	if (chosenRow.rowIndex != 0) {
	moveRow(chosenRow, chosenRow.rowIndex-1);
	}
	}
	function swapRowDown(chosenRow) {
	var mainTable = document.getElementById("stafftable");
	if (chosenRow.rowIndex != mainTable.rows.length-1) {
	moveRow(chosenRow, chosenRow.rowIndex+1);
	}
	}
	//moves the target row object to the input row index
	function moveRow(targetRow, newIndex) {
	//since we are not actually swapping
	//but simulating a swap, have to "skip over"
	//the current index
	if (newIndex > targetRow.rowIndex) {
	newIndex++;
	}
	//establish proper reference to the table
	var mainTable = document.getElementById('stafftable');
	//insert a new row at the new row index
	var theCopiedRow = mainTable.insertRow(newIndex);
	//copy all the cells from the row to move
	//into the new row
	for (var i=0; i<targetRow.cells.length; i++) {
	var oldCell = targetRow.cells[i];
	var newCell = document.createElement("TD");

	//if(i==0)
	//	newCell.setAttribute("width","40%");
	//if(i==1)
	//	newCell.setAttribute("width","50%");
	if(i==2){ 
		//newCell.setAttribute("style","text-align:center;");
		newCell.setAttribute("width","5%");
		}
	if(i==3)
		newCell.setAttribute("width","5%");
		
	newCell.innerHTML = oldCell.innerHTML;
	theCopiedRow.appendChild(newCell);
	copyChildNodeValues(targetRow.cells[i], newCell);
	}
	//delete the old row
	mainTable.deleteRow(targetRow.rowIndex);
	}
	function copyChildNodeValues(sourceNode, targetNode) {
	for (var i=0; i < sourceNode.childNodes.length; i++) {
	try{ 
	targetNode.childNodes[i].value = sourceNode.childNodes[i].value;
	}
	catch(e){

	}
	}
	}
	//------------------------------------------------
	//END OF WORLDWIDE DIRECTORY STAFF REORDER CODE
	//------------------------------------------------
	
	//------------------------------------------------
	//START OF TOP 5 CHART REORDER CODE
	//------------------------------------------------
	function moveRowUp(chosenRow) {
		if (chosenRow.rowIndex != 0) {
			moveChartRow(chosenRow, chosenRow.rowIndex-1);
		}
	}
	function moveRowDown(chosenRow) {
		var mainTable = document.getElementById("chartId");
			if (chosenRow.rowIndex != mainTable.rows.length-1) {
			moveChartRow(chosenRow, chosenRow.rowIndex+1);
		}
	}
		//moves the target row object to the input row index
	function moveChartRow(targetRow, newIndex,chosenRow) {
	//since we are not actually swapping
	//but simulating a swap, have to "skip over"
	//the current index
	if (newIndex > targetRow.rowIndex) {
	newIndex++;
	}
	//establish proper reference to the table
	var mainTable = document.getElementById('chartId');
	//insert a new row at the new row index
	var theCopiedRow = mainTable.insertRow(newIndex);
	//copy all the cells from the row to move
	//into the new row
	for (var i=0; i<targetRow.cells.length; i++) {
	var oldCell = targetRow.cells[i];	
	var newCell = document.createElement("TD");
	if(i==0) newCell.setAttribute("class","chartRowPadding");
	if(i==0) newCell.setAttribute("className","chartRowPadding");
	if(i==1) newCell.setAttribute("class","chartRowPadding");	
	if(i==1) newCell.setAttribute("className","chartRowPadding");
	if(i==2) newCell.setAttribute("class","chartRowPadding");
	if(i==2) newCell.setAttribute("className","chartRowPadding");

	//if(i==3) newCell.setAttribute("class","chartRowPadding");
	//if(i==3) newCell.setAttribute("className","chartRowPadding");
//	if(i==4) newCell.setAttribute("class","chartRowPadding");
	//if(i==4) newCell.setAttribute("className","chartRowPadding");
//	if(i==5) newCell.setAttribute("class","chartRowPadding");
//	if(i==5) newCell.setAttribute("className","chartRowPadding");
	newCell.innerHTML = oldCell.innerHTML;
	
	theCopiedRow.appendChild(newCell);
	copyChildNodeValues(targetRow.cells[i], newCell);
	}
	//delete the old row
	mainTable.deleteRow(targetRow.rowIndex);
	}
		
	//------------------------------------------------
	//END OF TOP 5 CHART REORDER CODE
	//------------------------------------------------
//------------------------------------------------
//START OF OVERRIDE SONG DETAILS TEXT
//------------------------------------------------

var objRowSelected = null;
var clrHilight = 'white';
var txtOld = "";	
var element = null;
 function updateSongDetailText(tableName){
    isIE = (navigator.appVersion.indexOf ("MSIE") != -1);
    isNS4 = (document.layers) ? true : false;
    isNS6 = (!document.layers) && (navigator.userAgent.indexOf ('Netscape')!=-1);

    if (document.getElementById){
      element = document.getElementById (tableName);
	  }
    else  //TODO: Need to test this piece of code still. Happens only in NN4 so far 
      eval (element = "document." + tableName);
    
	initNNFunctions();
	element.attachEvent ('onmouseover', selectRow);
    element.attachEvent ('ondblclick', onEdit);
    document.attachEvent ('onkeydown' , captureDelKey);
	
	element.focus ();
}
 function initNNFunctions ()
  {
    if ((self.Node) && (self.Node.prototype)){
      Node.prototype.removeNode = NNRemoveNode;

      Element.prototype.insertAdjacentText = NNInsertAdjacentText;
      Element.prototype.insertAdjacentElement = NNInsertAdjacentElement;
      Element.prototype.insert__Adj = NNInsertAdj;
      Element.prototype.attachEvent = NNAttachEvent;
      Element.prototype.detachEvent = NNDetachEvent;
      Element.prototype.setCapture = NNSetCapture;
      Element.prototype.releaseCapture = NNReleaseCapture;
      Element.prototype.__defineGetter__('document', NNDocumentGetter);

      HTMLElement.prototype.focus = NNNullFunction;
      HTMLElement.prototype.attachEvent = NNAttachEvent;
      HTMLElement.prototype.detachEvent = NNDetachEvent;
      HTMLElement.prototype.__defineGetter__('innerText', NNInnerTextGetter);
      HTMLElement.prototype.__defineSetter__('innerText', NNInnerTextSetter);

      HTMLDocument.prototype.attachEvent = NNAttachEvent;
      HTMLDocument.prototype.detachEvent = NNDetachEvent;

      Event.prototype.__defineGetter__('keyCode', NNKeyCodeGetter);
    }
  }
  
 function selectRow () {
    var srcElem = getEventRow ();
    if (srcElem.tagName != "TR") return;
    if (objRowSelected){
      objRowSelected.style.backgroundColor = '';
      objRowSelected = null;
    }
    if (srcElem.rowIndex > 0)
    {
      srcElem.style.backgroundColor = clrHilight;
      objRowSelected = srcElem;
    }
    element.focus ();
  }

function getEventRow (){
    var srcElem = window.event.srcElement;
    while (srcElem.tagName != "TR" && srcElem.tagName != "TABLE"){
      srcElem = srcElem.parentNode;
    }
    return srcElem;
  }
 
function onEdit (){
    var srcElem = getEventCell ();
    if (srcElem.tagName != "TD") return;
    if (srcElem.firstChild && srcElem.firstChild.tagName == "INPUT") return;
    
    txtOld = srcElem.innerHTML;
    srcElem.innerHTML = ""; 

    var objInput = document.createElement ("INPUT");
    objInput.style.width = "100%";//srcElem.clientWidth;
	objInput.style.margin = "1px";
    objInput.type = "text";
    objInput.value = "" + txtOld;

   	objInput.attachEvent ("onmouseout", focusLost);
    objInput.attachEvent ("onkeypress", checkForEnter);
    srcElem.insertAdjacentElement ("beforeEnd", objInput);
    objInput.select();
  }
  function getEventCell () {
    var srcElem = window.event.srcElement;
    while (srcElem.tagName != "TD" && srcElem.tagName != "TABLE")
    {
      srcElem = srcElem.parentNode;
    }
    return srcElem;
  }

  function checkForEnter (){
    if (event.keyCode == 13) focusLost ();
  }
  function focusLost (){
    var objSrcElm = window.event.srcElement;
	var editedtd = objSrcElm.parentNode;
    objSrcElm.parentNode.innerHTML = objSrcElm.value;
	updateSongDetail(editedtd);
  }
  
  function updateSongDetail(editedTd){
	  var song_detail_org = document.templateForm.songdetails.value;
	  var updatedetail = '';
	  var editedColumnHeader = '';
	  var columnPositionInSongdetail = 0;
	  var table = document.getElementById('updateSongDetailText');
	  var tbody = table.getElementsByTagName('tbody')[0];
	  var tdRows = tbody.getElementsByTagName('tr');
	  for(var i=0;i<tdRows.length;i++){
			var tds = tdRows[i].getElementsByTagName('td');
			for(var j=0;j<tds.length;j++){
				if(editedTd == tds[j]){
					if(j==0){
						columnPositionInSongdetail = 3;
					}else if(j==1){
						columnPositionInSongdetail = 4;
					}else if(j==2){
						columnPositionInSongdetail = 5;
					}else if(j==3){
						columnPositionInSongdetail = 6;
					}
					var selectedRowValue = song_detail_org.split('##')[i];
					var selectedColumnValue = selectedRowValue.split('@');
					var ne = '';
					for(var k=0;k<selectedColumnValue.length;k++){
						if(columnPositionInSongdetail==4){
							document.templateForm.artistname.value = editedTd.innerHTML;
						}
						if(k==columnPositionInSongdetail){ 
							ne += editedTd.innerHTML + '@';
						}else{
							ne += selectedColumnValue[k] + '@';
						}
					}
					var newValue = song_detail_org.replace(selectedRowValue,ne.substring(0,ne.length-1));
					newValue=replaceOverrideSpecialChars(newValue);		
					document.templateForm.songdetails.value = newValue;
					document.templateForm.songdetail.value = newValue;
					songtitlestring=newValue;
					break;
				}
			}
		}
  }
   
  function replaceOverrideSpecialChars(s){
		if(s!=null && s!=''){
			s=s.replace(/&amp;/g,'&');
		}
		return s;
   }
   
  function captureDelKey (){
    var keyPressed = event.keyCode;
    var srcElem = window.event.srcElement;
    if ((keyPressed == 46) && (srcElem.tagName != "INPUT") && (objRowSelected)){
      deleteRow (objRowSelected.rowIndex - 1);
      objRowSelected = null;
    }
  }

 function NNRemoveNode (a1){
    var p = this.parentNode;
    if (p&&!a1) {
      var df = document.createDocumentFragment ();
      for (var a = 0; a < this.childNodes.length; a++)
      {
        df.appendChild (this.childNodes[a])
      }
      p.insertBefore (df , this)
    }
    return p?p.removeChild (this):this;
  }
  
  function NNRemoveNode (a1){
    var p = this.parentNode;
    if (p&&!a1){
      var df = document.createDocumentFragment ();
      for (var a = 0; a < this.childNodes.length; a++)
      {
        df.appendChild (this.childNodes[a])
      }
      p.insertBefore (df , this)
    }
    return p?p.removeChild (this):this;
  }

  function NNInsertAdjacentText (a1 , a2){
    var t = document.createTextNode (a2||"")
    this.insert__Adj (a1 , t);
  }

  function NNInsertAdjacentElement (a1 , a2){
    this.insert__Adj (a1 , a2);
    return a2;
  }

  function NNInsertAdj (a1 , a2) {
    var p = this.parentNode;
    var s = a1.toLowerCase ();
    if (s == "beforebegin"){p.insertBefore (a2 , this)}
    if (s == "afterend"){p.insertBefore (a2 , this.nextSibling)}
    if (s == "afterbegin"){this.insertBefore (a2 , this.childNodes[0])}
    if (s == "beforeend"){this.appendChild (a2)}
  }

  function NNAttachEvent (strEvent, funcHandle) {
    var shortTypeName = strEvent.replace (/on/, "");
    funcHandle._ieEmuEventHandler = function (e){
      window.event = e;
      window.event.srcElement = e.target;
      return funcHandle ();
    };
    this.addEventListener (shortTypeName, funcHandle._ieEmuEventHandler, false);
  }

  function NNDetachEvent (strEvent, funcHandle){
    var shortTypeName = strEvent.replace (/on/, "");
    if (typeof funcHandle._ieEmuEventHandler == "function")
      this.removeEventListener (shortTypeName, funcHandle._ieEmuEventHandler, false);
    else 
      this.removeEventListener (shortTypeName, funcHandle, true);
  }

  function NNSetCapture (){
    //TODO: FIX THIS FIRST BEFORE ANYTHING ELSE!! MAJOR HACK FOR NOW
    document.attachEvent ('onmousemove', resizeColoumn);
    document.attachEvent ('onmouseup', releaseMouse);
  }

  function NNReleaseCapture () {
    //TODO: FIX THIS SECOND THEN GO TO EVERYTHING ELSE! 
    document.detachEvent ('onmousemove', resizeColoumn);
    document.detachEvent ('onmouseup', releaseMouse);
  }

  function NNNullFunction () { /*Nothing here*/ }

  function NNInnerTextGetter () {
    return this.innerHTML.replace (/<[^>]+>/g,"");
  }

  function NNInnerTextSetter (txtStr){
    var parsedText = document.createTextNode (txtStr);
    this.innerHTML = "";
    this.appendChild (parsedText);
  }

  function NNKeyCodeGetter (){
    return this.which;
  }

  function NNDocumentGetter (){
    return this.ownerDocument;
  }
	
//------------------------------------------------
//END OF OVERRIDE SONG DETAILS TEXT
//------------------------------------------------	