// JavaScript Document

var dtCh= "/";
var minYear = 1000;
var maxYear = 10000;

/*********FUNCTIONS FOR FEATURED ARTISTS GALLERY SCROLLER IN HOME PAGE***********/
function ScrollHor(id,dis)
{
    var obj=document.getElementById(id);//alert(obj);
    obj.scrollLeft=obj.scrollLeft+dis;
    timeout=setTimeout( function(){ ScrollHor(id,dis);},10);
}
//FUNCTION FOR NEWSLETTER SIGNUP IN HOME PAGE
function newslettersignup()
{
	var frm		=	document.frmnewsletter;
	var email	=	frm.txtEmail.value;
	if(checkBlank(frm.txtEmail,"Email address ")==false)
	{
		return false;
	}
	if(checkEmail(frm.txtEmail," E-mail Address ") == false)
	{
		return false;
	}
	
	var captchacode	=	document.getElementById('txtNewsletterCaptcha').value;
	if(captchacode == '')
	{
		alert("Please Enter the Verification Code");
		return false;
	}

	var aUrl	=	"/includes/ajax/newslettersignup.php?emailid="+email+"&captch="+captchacode+"&rand="+Math.random(); 
	aRequestGet(aUrl,getResponseNewsletter);
}
function getResponseNewsletter(flag,value)
{
	if(flag)
	{	
		if(value == 0)
		{
			document.getElementById('errormessage').innerHTML	 =	'<b>Invalid Verification Code</b>';
			document.getElementById('newslettercaptcha').focus();	
		}
		else
		{
			document.getElementById('errormessage').innerHTML	=	value;
			document.getElementById('txtEmail').value			=	"";
		}
		document.getElementById('txtNewsletterCaptcha').value =	"";			
		window.frames['newslettercaptcha'].location.reload();
	}
}
function hidecalDiv(divname)
{
	document.getElementById(divname).style.display	=	'none';
}
//FUNCTION TO OPEN MONTH DIV IFOR TOUR DIARY IN HOME PAGE
function showtourDiv(divname)
{
	if(document.getElementById(divname).style.display == 'none')
	{	
		document.getElementById(divname).style.display	=	'block';
	}
	if(divname != 'suggest')
	{
		setTimeout ( "hidecalDiv('"+divname+"')", 4000 );
	}
	
}
//FUNCTION TO GET EVENTS FOR PARTICULAR MONTH AND YEAR IN RIGHTPANEL
function getEvent(frmName,month,year,hdnmon,hdnyear)
{	
	var frm	=	frmName;
	
	if(month != '')
	{
		document.getElementById(hdnmon).value	=	month;
	}
	else
	{
		document.getElementById(hdnmon).value	=	document.getElementById('monthname').value;
	}
	if(year != '')
	{
		document.getElementById(hdnyear).value	=	year;
	}
	else
	{
		document.getElementById(hdnyear).value	=	document.getElementById('yearname').value;
	}
	frm.submit();
}

//FUNCTION TO GET TOUR DIARY EVENTS
function getTourDiary(frmName,month,year,flag,date)
{	
	var frm			=	frmName;
	var arrMonth	=	new	Array('January','February','March','April','May','June','July','August','September','October','November','December');
	//var arrMonth	=	new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

	if(flag	==	1 && date != '')
	{
		var url = 'artist-tour-diary-events-'+date+'-'+month+'-'+year+'.htm';
	}
	else
	{
		var url = 'artist-tour-diary-events-'+month+'-'+year+'.htm';
	}
	
	frm.action	=	url;
	frm.submit();
}
function getNews(frmName,month,year)
{		
	var frm			=	frmName;
	var url = 'news-'+month+'-'+year+'.htm';
	
	frm.action	=	url;
	frm.submit();
}

function getVault(vyr)
{	
	var frm	=	document.frmChartVault;
	document.getElementById('hdnVaultYear').value	=	vyr;
	frm.submit();
}

function feValidate(frm)
{
	if(frm.id == "frmRegistration")
	{
		if(checkBlank(frm.txtRegEmail," Email-Address ") == false)
			return false;
		if(checkEmail(frm.txtRegEmail," Email-Address ") == false)
			return false;
		if(checkBlank(frm.txtRegPwd," Password ") == false)
			return false;
		if(checkBlank(frm.txtRegConfPwd," Confirm Password ") == false)
			return false;
		if(confirmPassword(frm.txtRegPwd,frm.txtRegConfPwd) == false)
			return false;
		if(checkSelect(frm.selRegDobDt," Date of Birth ") == false)
			return false;
		if(checkSelect(frm.selRegDobMon," Month of Birth ") == false)
			return false;
		if(checkBlank(frm.txtRegYear," Year Of Birth ") == false)
			return false;
		if(dateValidate(frm.selRegDobDt,frm.selRegDobMon,frm.txtRegYear,frm,"Birth") == false)
			return false;
		if(document.getElementById('hdnUniqueVal').value != 1)
			return false;
	
	}
	if(frm.id == "frmLogin")
	{
		if(checkBlank(frm.txtLogEmail," Email Id ") == false)
			return false;
		if(checkEmail(frm.txtLogEmail," Email-Address ") == false)
			return false;
		if(checkBlank(frm.txtLogPwd," Password ") == false)
			return false;

		validateLogin();
	}
	if(frm.id == "frmDetails")
	{
		if(checkBlank(frm.txtDetFirst," Name ") == false)
			return false;
		if(checkBlank(frm.txtDetLast," Subject ") == false)
			return false;
		if(checkEmail(frm.txtDetEmail," Email-Address ") == false)
			return false;
	}
	if(frm.id == "frmForgotPwd")
	{
		if(checkBlank(frm.txt4gotEmail," Email-Address ") == false)
			return false;
		if(checkEmail(frm.txt4gotEmail," Email-Address ") == false)
			return false;
	}
}
function selectValue(frmName,limitVal,fieldName)
{	
	frm = frmName;
	document.getElementById(fieldName).value	=	limitVal;
	frm.submit();
	return true;
}

function selectValueSubmit(frmName,limitVal,fieldName,browseChar)
{	
	frm = frmName;
	if(frm.id	==	'frmTracks')
	{
		if(browseChar	==	'')
		{
			var Url	=	'/tracks.htm';
		}
		else
		{
			var Url	=	'/tracks/browse-'+browseChar+'.htm';
		}
	}
	else
	{
		if(browseChar	==	'')
		{
			var Url	=	'/albums.htm';
		}
		else
		{
			var Url	=	'/albums/browse-'+browseChar+'.htm';
		}
	}
	document.getElementById(fieldName).value	=	limitVal;
	frm.action =	Url;
	frm.submit();
}

function selectValuePaging(frmName,limitVal,fieldName)
{	
	var frm	=	document.getElementById(frmName);
	document.getElementById(fieldName).value	=	limitVal;
	frm.submit();
}

//FUNCTION FOR SEARCH TO GO TO ANOTHER SCTION
function sendUrl(url)
{	
	var frm = document.frmSearch;
	frm.action = url;
	frm.submit();
}

//FUNCTION FOR SEARCH FUNCTIONALITY
function srchFunc(url)
{	
	var str;
	var frm	=	document.frmSearch;
	var searchparameter	=	strtrim(document.getElementById('q').value);
	
	if(url == "/index.php?p=googlesearch")
	{
		str = "/index.php?p=googlesearch&cx=009522629152018714698%3Atbddoit1im4&cof=FORID%3A10&ie=UTF-8&q="+searchparameter+"&sa=Search";
	}
	else
	{
		str		=	url+'/search-'+searchparameter+'.htm';
	}
	
	frm.action	=	str;
	frm.submit();	
}

//ERROR MESSAGE FUNCTION
function errormessage(msg)
{
	window.parent.document.getElementById('errormsgdiv').innerHTML	=	msg;	
}

//FUNCTION FOR VALIDATING ARTISTS - BANDS BIOGRAPHY 'DO YOU KNOW MORE' POPUP PAGE
function validateInfo(frmName,artId)
{	
	var frm		=	frmName;
	var aUrl	=	'/includes/ajax/artistinfo.php';
	var count	=	0;

	if(frm.id == 'frmBioInfo') {
	
		var captchacode	=	document.getElementById('txtCaptchaCode'+artId).value;
		if(captchacode == '')
		{
			alert("Please Enter the Verification Code");
			return false;
		}
	
		aUrl	+=	'?type=artist&Id='+artId;
		aUrl	+=	'&captchacode='+captchacode;
		
		var mName	=	document.getElementById('txtBioMNm'+artId);
		if(mName != null && mName.value != '')
		{
			aUrl	+=	'&mname='+mName.value;
			count++;
		}
	
		var lName	=	document.getElementById('txtBioLNm'+artId);
		if(lName != null && lName.value != '')
		{
			aUrl	+=	'&lname='+frm.lName.value;
			count++;
		}
	
		var nick	=	document.getElementById('txtBioNickNm'+artId);
		if(nick != null && nick.value != '')
		{
			aUrl	+=	'&nick='+nick.value;
			count++;
		}
	
		var dbMonth = document.getElementById('selBioDobMon'+artId);
		var dbDate	= document.getElementById('selBioDobDt'+artId);
		var dbYear	= document.getElementById('txtBioYear'+artId);
		if(dbDate != null && dbMonth != null && dbYear != null)
		{
			if(dbDate.value != 0 && dbMonth.value != 0 && dbYear.value != 0)
			{
				var DoB		= dbYear.value+'-'+dbMonth.value+'-'+dbDate.value;
				aUrl	+=	'&dob='+DoB;
				count++;
			}
		}
	
		var ddMonth = document.getElementById('selBioDodMon'+artId);
		var ddDate	= document.getElementById('selBioDodDt'+artId);
		var ddYear	= document.getElementById('txtBioDodYear'+artId);
		if(ddDate != null && ddMonth != null && ddYear != null)
		{	
			if(ddDate.value != 0 && ddMonth.value != 0 && ddYear.value != 0)
			{
				var DoD		= ddYear.value+'-'+ddMonth.value+'-'+ddDate.value;
				aUrl	+=	'&dod='+DoD;
				count++;
			}
		}
	
		var place	=	document.getElementById('txtBioCity'+artId);
		if(place != null && place.value != '')
		{
			aUrl	+=	'&place='+place.value;
			count++;
		}
	
		var fan		=	document.getElementById('txtBioFanSite'+artId);
		if(fan != null && fan.value != '')
		{
			aUrl	+=	'&fansite='+fan.value;
			count++;
		}
		
		var agent	=	document.getElementById('txtBioAgt'+artId);
		if(agent != null && agent.value != '')
		{
			aUrl	+=	'&agent='+agent.value;
			count++;
		}
		if(count == 0)
		{
			alert("Please enter details");
			return false;
		}
		else
		{	
			aUrl	+=	'&rand='+Math.random();//alert(aUrl);
			document.getElementById('MessageDiv').style.display	=	'';
			document.getElementById('txtCaptchaCode'+document.getElementById('hdnAId').value).value = '';
			document.getElementById('txtCaptchaCode'+document.getElementById('hdnAId').value).focus();
			aRequestGet(aUrl, GetResponseBiography);
			return false;
		}
	
	
	} else if(frm.id == 'frmBandBioInfo') {
		
		var captchacode =	document.getElementById('txtBandCaptchaCode'+artId).value;
		var fansite		=	document.getElementById('txtBandFanSite'+artId);
		var agent		=	document.getElementById('txtBandAgt'+artId);
		var formMonth 	= 	document.getElementById('selBandFormMon'+artId);
		var disMonth 	= 	document.getElementById('selBandDisMon'+artId);
		var disYear		= 	document.getElementById('txtBandDisYear'+artId);

		if(captchacode == ''){
			alert("Please Enter the Verification Code");
			return false;
		}

		aUrl	+=	'?type=band&Id='+artId;
		aUrl	+=	'&captchacode='+captchacode;
		if(formMonth != null && formMonth.value != '')
		{
			aUrl	+=	'&formmonth='+formMonth.value;
			count++;
		}
		if(disMonth != null && disMonth.value != '')
		{
			aUrl	+=	'&dismonth='+disMonth.value;
			count++;
		}
		if(disYear != null && disYear.value != '' && disYear.value != '0')
		{
			aUrl	+=	'&disyear='+disYear.value;
			count++;
		}
		if(fansite != null && fansite.value != '')
		{
			aUrl	+=	'&fansite='+fansite.value;
			count++;
		}
		if(agent != null && agent.value != '')
		{
			aUrl	+=	'&agent='+agent.value;
			count++;
		}
		if(count == 0) {
			alert('Please enter details');
			return false;
		} else {
			document.getElementById('eMsgDiv').style.display	=	'';
			aRequestGet(aUrl, GetResponseBandBiography);
			return false;
		}
	
	
	} else if(frm.id == 'frmRegistration') {
		
		aUrl	+=	'?type=registration';
		var fname = document.getElementById('txtRegFNm').value;
		var lname = document.getElementById('txtRegLNm').value;

		if(fname != '' && fname != null)		
			aUrl += '&fname='+fname;
		if(lname != '' && lname != null)		
			aUrl += '&lname='+lname;

		if(checkBlank(frm.txtRegEmail," Email-Address ") == false)
			return false;
		if(checkEmail(frm.txtRegEmail," Email-Address ") == false)
			return false;
		if(checkBlank(frm.txtRegPwd," Password ") == false)
			return false;
		if(checkBlank(frm.txtRegConfPwd," Confirm Password ") == false)
			return false;
		if(confirmPassword(frm.txtRegPwd,frm.txtRegConfPwd) == false)
			return false;
		if(checkSelect(frm.selRegDobDt," Date of Birth ") == false)
			return false;
		if(checkSelect(frm.selRegDobMon," Month of Birth ") == false)
			return false;
		if(checkBlank(frm.txtRegYear," Year Of Birth ") == false)
			return false;
		if(dateValidate(frm.selRegDobDt,frm.selRegDobMon,frm.txtRegYear,frm,"Birth") == false)
			return false;
		if(checkBlank(frm.txtRegCaptcha," Verification Code ") == false)
			return false;
		if(document.getElementById('hdnUniqueVal').value != 1)
			return false;

		var email = document.getElementById('txtRegEmail').value;
		var passw = document.getElementById('txtRegPwd').value;
		var dob	  = document.getElementById('txtRegYear').value +'-'+ document.getElementById('selRegDobMon').value +'-'+ document.getElementById('selRegDobDt').value; 
		var captchacode = document.getElementById('txtRegCaptcha').value;
		var newsletter;
		var thirdemail;

		if(document.getElementById('chkRegNewsletter').checked == true)
			newsletter = 'y';
		else
			newsletter = 'n';

		if(document.getElementById('chkRegThirdEmail').checked == true)
			thirdemail = 'y';
		else
			thirdemail = 'n';

		aUrl += '&newsltr='+newsletter+'&thirdemail='+thirdemail+'&email='+email+'&passw='+passw+'&dob='+dob+'&captcha='+captchacode+'&rand='+Math.random();//alert(aUrl);
		document.getElementById('errormsg').innerHTML 	= 	'';
		aRequestGet(aUrl, GetResponseReg);
		return false;

	
	} else if(frm.id == 'frmSuggestTrivia') {

		aUrl	+=	'?type=suggesttrivia';
		var qtname = document.getElementById('txtQuesType').value;
		var gname = document.getElementById('txtGenre').value;
		var source 	= document.getElementById('txtSource').value;

		if(qtname != '' && qtname != null)		
			aUrl += '&qtname='+qtname;
		if(gname != '' && gname != null)		
			aUrl += '&gname='+gname;
		if(source != '' && source != null)		
			aUrl += '&source='+source;

		if(checkBlank(frm.slCategory," Category Name ") == false)
			return false;
		if(document.getElementById('slQues').value == "" || document.getElementById('slQues').value == null) 
		{
			alert('Please select Question Type');
			return false;
		}
		if(document.getElementById('slGenre').value == "" || document.getElementById('slGenre').value == null) 
		{
			alert('Please select Genre Type');
			return false;
		}
		if(checkBlank(frm.txtQuestion," Question ") == false)
			return false;
		//charCounter('txtQuestion', '300');
		if(checkBlank(frm.txtAnswer," Answer ") == false)
			return false;
		//charCounter('txtAnswer', '300')
		if(checkBlank(frm.txtTrvCaptcha," Verification Code ") == false)
			return false;

		var cname 	= document.getElementById('slCategory').value;
		var qtype 	= document.getElementById('slQues').value;
		var gtype 	= document.getElementById('slGenre').value;
		var ques 	= document.getElementById('txtQuestion').value;
		var ans 	= document.getElementById('txtAnswer').value;
		var captchacode = document.getElementById('txtTrvCaptcha').value;

		document.getElementById('msgdiv').style.display = 	'none';
		aUrl += '&cname='+cname+'&qtype='+qtype+'&gtype='+gtype+'&ques='+ques+'&ans='+ans+'&captcha='+captchacode+'&rand='+Math.random();//alert(aUrl);
		aRequestGet(aUrl, GetResponseTrv);
		return false;

	}
}

function GetResponseBiography(flag,value)
{
	if(flag)
	{
		document.getElementById('MessageDiv').style.display = "none";
		if(strtrim(value)	== 'Invalid') {

			document.getElementById('MessageDiv').innerHTML		=	"<b>Invalid Verification Code</b>";
			document.getElementById('MessageDiv').style.display	=	'';
			window.frames['captchaframe'].location.reload();

		} else {	

			var status = value.split('$$');
			document.getElementById('MessageDiv').style.display		=	'none';
			parent.$(".knowmore").colorbox.close() //CLOSING THE COLORBOX POPUP	
			document.getElementById('msgdiv').innerHTML			=	'Email sent to admin';		
			document.getElementById('msgdiv').style.display		=	'';

		}
	}
}

function GetResponseBandBiography(flag, value) {
	if(flag) {	
		document.getElementById('eMsgDiv').style.display = "none";
		if(value == 1) {

			parent.$(".bandknowmore").colorbox.close() //CLOSING THE COLORBOX POPUP	
			document.getElementById('msgdiv').innerHTML			=	'Email sent to admin';		
			document.getElementById('msgdiv').style.display		=	'';

		} else if(value == 0){

			document.getElementById('eMsgDiv').innerHTML		=	"<b>Invalid Verification Code<b/>";
			document.getElementById('eMsgDiv').style.display	=	'';
			document.getElementById('txtBandCaptchaCode'+document.getElementById('hdnBId').value).value			=	'';
			document.getElementById('txtBandCaptchaCode'+document.getElementById('hdnBId').value).focus();
			window.frames['bandcaptchaframe'].location.reload();

		} else {

			document.getElementById('eMsgDiv').innerHTML		=	value;
			document.getElementById('eMsgDiv').style.display	=	'';
		}
	}
}

function GetResponseReg(flag,value) {
	if(flag) {

		if(value == 1) {
			document.getElementById('errormsg').innerHTML 		= 	'';
			parent.$(".inline1").colorbox.close() //CLOSING THE COLORBOX POPUP	

			$.fn.colorbox({href:"http://"+location.host+"/ackRegister.html"});

			$(document).ready(function() {
            $.fn.colorbox({href:"http://"+location.host+"/ackRegister.html", open:true}) ;}); 

		} else {

			document.getElementById('errormsg').innerHTML 		= 	"<b>Invalid Verification Code</b>";
			document.getElementById('txtRegCaptcha').value = '';
			document.getElementById('txtRegCaptcha').focus();
			window.frames['regcaptcha'].location.reload();
		}

	}
}

function GetResponseTrv(flag,value) {

	if(flag) {

		if(value == 0) {

			document.getElementById('errormsg').innerHTML 		= 	"<b>Invalid Verification Code</b>";
			document.getElementById('txtTrvCaptcha').value = '';
			document.getElementById('txtTrvCaptcha').focus();
			window.frames['trvcaptcha'].location.reload();

		} else { 

			parent.$(".trivia").colorbox.close() //CLOSING THE COLORBOX POPUP	
			//alert(document.getElementById('msgdiv'));alert(document.getElementById('msgdiv').innerHTML);
			document.getElementById('msgdiv').innerHTML 	 = 	'Thank you for your suggestion';
			document.getElementById('msgdiv').style.display = 	'';
		}
	}
}

//FUNCTION FOR COLORBOX POPUP
function colorboxpopup()
{
	
	$(document).ready(function()
	{
		
		$(".colorbox").colorbox();
		$(".inline").colorbox({width:"", inline:true, href:"#bookmark-popup"});
		$(".inline1").colorbox({inline:true, href:"#bookmark-login",
							onOpen:function(){ 
									document.getElementById('frmRegistration').reset(); 
									if(document.getElementById('selRegDobDt') != '' && document.getElementById('selRegDobDt') != null) 
										document.getElementById('selRegDobDt').value = ''; 
									if(document.getElementById('selRegDobMon') != '' && document.getElementById('selRegDobMon') != null) 
										document.getElementById('selRegDobMon').value = '';
									
							}, 
							onLoad:function(){ 
									document.getElementById('errormsg').innerHTML = '';
									if(document.getElementById('MessageDiv').style.display != 'none')document.getElementById('MessageDiv').style.display = 'none';
									window.reload = document.getElementById('regcaptcha').src = "http://"+location.host+"/readcaptchaimg.php";//window.frames['captchaframe'].location.reload();
							}
		});

		$(".inline2").colorbox({inline:true, href:"#bookmark-loginn1"});
		$(".inline3").colorbox({inline:true, href:"#bookmark-Details"});
		$(".contact").colorbox({inline:true, href:"#bookmark-contact", 
							onOpen:function(){ 
									document.getElementById('frmContact').reset(); 
							}, 
							onLoad:function(){
									if(document.getElementById('errMsg').style.display != 'none')document.getElementById('errMsg').style.display = 'none'; 
									window.reload = document.getElementById('contactcaptcha').src = "http://"+location.host+"/readcaptchaimg.php";//window.frames['captchaframe'].location.reload();
							}
		});
		
		$(".forgot").colorbox({inline:true, href:"#bookmark-forgot"});
		//ADDED ON 19TH FEB 2011
		$(".trivia").colorbox({inline:true, href:"#suggest-trivia",
							onOpen:function(){ 
									document.getElementById('slQues').value = ""; 
									document.getElementById('txtQuesType').value = ""; 
									document.getElementById('slGenre').value = ""; 
									document.getElementById('txtGenre').value = ""; 
									document.getElementById('txtQuestion').value = ""; 
									document.getElementById('txtAnswer').value = ""; 
									document.getElementById('txtSource').value = ""; 
									document.getElementById('txtTrvCaptcha').value = ""; 
							}, 
							onLoad:function(){ 
									document.getElementById('errormsg').innerHTML = '';
									window.reload = document.getElementById('trvcaptcha').src = "http://"+location.host+"/readcaptchaimg.php";//window.frames['captchaframe'].location.reload();
							}
			
		});
		//ADDED ON 19TH FEB 2011 
		$(".knowmore").colorbox({ inline:true, scrolling: false,href:"#divknowmore", 
							onOpen:function(){ 
									document.getElementById('MessageDiv').innerHTML = '';
									document.getElementById('frmBioInfo').reset();
									var id = document.getElementById('hdnAId').value;
									if(document.getElementById('selBioDobDt'+id) != '' && document.getElementById('selBioDobDt'+id) != null) 
										document.getElementById('selBioDobDt'+id).value = ''; 
									if(document.getElementById('selBioDobMon'+id) != '' && document.getElementById('selBioDobMon'+id) != null) 
										document.getElementById('selBioDobMon'+id).value = '';
									if(document.getElementById('selBioDodDt'+id) != '' && document.getElementById('selBioDodDt'+id) != null)  
										document.getElementById('selBioDodDt'+id).value = ''; 
									if(document.getElementById('selBioDodMon'+id) != '' && document.getElementById('selBioDodMon'+id) != null)
										document.getElementById('selBioDodMon'+id).value = ''; 
									
							}, 
							onLoad:function(){ 
									if(document.getElementById('MessageDiv').style.display != 'none')document.getElementById('MessageDiv').style.display = 'none';
									window.reload = document.getElementById('captchaframe').src = "http://"+location.host+"/readcaptchaimg.php";//window.frames['captchaframe'].location.reload();
							}
		});
		$(".bandknowmore").colorbox({ inline:true, scrolling: false,href:"#divbandknowmore", 
							onOpen:function(){ 
									document.getElementById('frmBandBioInfo').reset(); 
									var id = document.getElementById('hdnBId').value;
									if(document.getElementById('selBandFormMon'+id) != '' && document.getElementById('selBandFormMon'+id) != null) 
										document.getElementById('selBandFormMon'+id).value = '';
									if(document.getElementById('selBandDisMon'+id) != '' && document.getElementById('selBandDisMon'+id) != null)  
										document.getElementById('selBandDisMon'+id).value = ''; 

							}, 
							onLoad:function(){ 
									if(document.getElementById('eMsgDiv').style.display != 'none') document.getElementById('eMsgDiv').style.display = 'none';
									window.reload = document.getElementById('bandcaptchaframe').src = "http://"+location.host+"/readcaptchaimg.php";//window.frames['captchaframe'].location.reload();
							}
		});
		$(".uploadimage").colorbox({ inline:true, scrolling: false,href:"#divuploadimge", 
							onOpen:function(){ 
									document.getElementById('frmBioUploadImage').reset(); 
							}, 
							onLoad:function(){ 
									if(document.getElementById('errMsgImage').style.display != 'none')document.getElementById('errMsgImage').style.display = 'none'; 
									window.reload = document.getElementById('uploadimageartistcaptcha').src = "http://"+location.host+"/readcaptchaimg.php";//window.frames['captchaframe'].location.reload();
							}
		});
		$(".banduploadimage").colorbox({ inline:true, scrolling: false,href:"#divbanduploadimge", 
							onOpen:function(){ 
									document.getElementById('frmBandUploadImage').reset(); 
							} , 
							onLoad:function(){ 
									if(document.getElementById('errMsgBandImage').style.display != 'none')document.getElementById('errMsgBandImage').style.display = 'none'; 
									window.reload = document.getElementById('uploadimagebandcaptcha').src = "http://"+location.host+"/readcaptchaimg.php";//window.frames['captchaframe'].location.reload();
							} 
		});
		$(".ackregister").colorbox({ inline:true, scrolling: false,href:"#ackRegister"});
		$(".ackforgot").colorbox({ inline:true, scrolling: false,href:"#ackForgot"});
		$(".reportabuse").colorbox({ inline:true, scrolling: false,href:"#abusediv"});
		$(".gallabuse").colorbox({ inline:true, scrolling: false,href:"#gallabusediv"});
		$(".imageabuse").colorbox({ inline:true, scrolling: false, href:"#imageabusediv",
				onOpen:function(){ 
					
					var frm = document.getElementById('frmImageAbuse');
					document.getElementById('hndimgid').value 	= document.getElementById('hndPhotoId').value;	
					document.getElementById('hdnid').value 		= document.getElementById('hdnBandId').value;
					frm.hdntype.value 	= document.getElementById('hdnType').value;
				}, 
				onCleanup:function(){ 
					document.getElementById('frmImageAbuse').reset();				
				} 
		});

		//Example of preserving a JavaScript event for inline calls.
		$("#click").click(function(){
		$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
		return false;
		});
		});
		function MM_jumpMenu(targ,selObj,restore){ //v3.0
		eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
		if (restore) selObj.selectedIndex=0;
	}

}
function openAck(str)
{
		$.fn.colorbox({href:str});
}

//FUNCTION FOR PLAYING VIDEOS IN BIOGRAPHY IMAGE
function showVideo(frmName,fldName,videoId)
{
	var frm =	frmName;
	document.getElementById(fldName).value	= videoId;
	
	frm.submit();
}

//FUNCTION TO CHECK EMAIL ID WHILE REGISTERING....
function chkEmail(str)
{
	var aUrl	=	"/includes/ajax/frontajax.php?action=register&par="+str;
	document.getElementById('loaderImg').style.display = 'block';
	document.getElementById('hdnUniqueVal').value = '';
	aRequestGet(aUrl, GetResponseSignUp);
}

function GetResponseSignUp(flag,value)
{
	if(flag)
	{	
		if(value == 0)
		{
			document.getElementById('loaderImg').style.display 	= 'none';
			document.getElementById('MessageDiv').innerHTML 	= "Email Id already exists";
			document.getElementById('MessageDiv').style.display = 'block';
			document.getElementById('hdnUniqueVal').value = value;
		}
		else
		{
			document.getElementById('loaderImg').style.display 	= 'none';
			document.getElementById('MessageDiv').style.display = 'none';
			document.getElementById('hdnUniqueVal').value = 1;
		}
	}
}

//FUNCTION TO CHECK LOGIN INFORMATION
function validateLogin()
{
	var usrName	=	document.getElementById('txtLogEmail').value;
	var passW	=	document.getElementById('txtLogPwd').value;
	var str		=	usrName+"$$"+passW;
	var aUrl	=	"/includes/ajax/frontajax.php?action=login&par="+str;
	aRequestGet(aUrl, GetResponseLogin);
}

function GetResponseLogin(flag,value)
{
	if(flag)
	{	
		if(value == 1)
		{
			window.location = "/";
		}
		else
		{
			document.getElementById('msgdiv').innerHTML = value;
			document.getElementById('msgdiv').style.display = "";
			return false;
		}
	}
}

function activationMail()
{	
	var frm		=	document.frmLogin;
	var Uname	=	frm.txtLogEmail.value;
	var aUrl	=	"/includes/ajax/frontajax.php?action=activationMail&par="+Uname;//alert(aUrl);return false;
	aRequestGet(aUrl, GetResponseAtivationLogin);
	//return false;
}

function GetResponseAtivationLogin(flag,value)
{
	if(flag)
	{
		document.getElementById("msgdiv").innerHTML		=	"Activation mail has been sent to your email address";
		document.getElementById('msgdiv').style.display = 	"";	
		return false;
	}
}


function CloseDivdeath1(myID)
{
	 document.getElementById(myID).style.display="none";
	 return true;
}

//FUNCTION TO CHECK OR UNCHECK ALL CHECKBOXES IN TRIVIA PAGE
function checkUncheckAll(theElement)
{
		
     var theForm = theElement.form, z = 0;

	 for(z=0; z<theForm.length;z++)
	 {	
     	 if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall')
	  	 {
	  		theForm[z].checked = theElement.checked;
	  	 }
     }
}
function checkSingle(theElement)
{
	if(!theElement.checked)
	{
		document.getElementById('chkSelectAll').checked = 0;
	}
	var theForm = theElement.form, z = 0,no=0,ct=0;
	for(z=0; z<theForm.length;z++)
	 {	
     	 if(theForm[z].type == 'checkbox' && theForm[z].checked == true && theForm[z].name != 'chkSelectAll')
	  	 {
			flg=1;
			ct++;
			no++;
	  	 }
		 if(theForm[z].type == 'checkbox' && theForm[z].checked == false && theForm[z].name != 'chkSelectAll')
		 {
			 no++;
		 }		 
	 }
	 if(ct == no-1)
	 {
		 document.getElementById('chkSelectAll').checked = 1;
	 }
	 else
	 {
		 document.getElementById('chkSelectAll').checked = 0;
	 }
}
//FUNCTION TO GENERATE TRIVIA REPORT
function genTrivia(frmName)
{
	var frm = frmName;
	frm.submit();
}
//FUNCTION FOR VIDEO GALLERY
function videoFunc(frmName,fldVal,fldName)
{
	var frm		=	frmName;
	var value	=	document.getElementById(fldVal).value;
	document.getElementById(fldName).value	=	value;
	frm.submit();
}

var num,t;
function changeImg(imgnum,str,num)
{
		if(str == 'over')
		{
			clearTimeout(t);
			document.getElementById('img1').style.cursor='pointer';
			document.getElementById('img1').src = "../images/frontend/banners/content"+num+".jpg";
			document.getElementById('content'+num).className = "active";
				var temp1 = 1; 
				while(temp1 < 4)
				{
						if(temp1 == num)
						{
							temp1 = eval(temp1) + eval(1);
						}
						document.getElementById('content'+temp1).className = "";
						if(temp1 != 4)
						{
							temp1 = eval(temp1) + eval(1);
						}
				}
				if(num != 4)	
				{
						document.getElementById('content'+temp1).className = "";
				}
				if(num == 4)
				{
					num = 1;
				}
				else
				{
					++num;
				}
		}
		else
		{
			if(num != 4)
			{
				++num;
			}
				t=setTimeout("changeImgTime('"+num+"')",10000);
		}
		
}

function showPage()
{
	var url = document.getElementById('img1').src;
	var no = url.charAt(url.length-5);
	var path = document.getElementById('content'+no).href;
	window.location=path;
}


function changeImgTime(num)
{
		if(num == '1')
		{
				clearTimeout(t);
				document.getElementById('img1').src = "../images/frontend/banners/content"+num+".jpg";
				document.getElementById('content'+num).className = "active";
				document.getElementById('content4').className = "";
				document.getElementById('content3').className = "";
				document.getElementById('content2').className = "";
				t=setTimeout("changeImgTime('2')",10000);
		}else
		{
				document.getElementById('img1').src = "../images/frontend/banners/content"+num+".jpg";
				document.getElementById('content'+num).className = "active";
				var temp = 1;
				while(temp < 4)
				{
						if(temp == num)
						{
							temp = eval(temp) + eval(1);
						}
						document.getElementById('content'+temp).className = "";
						if(temp != 4)
						{
							temp = eval(temp) + eval(1);
						}
				}
				if(num != 4)	
				{
						document.getElementById('content'+temp).className = "";
				}
				if(num == 4)
				{
					num = 1;
				}
				else
				{
					++num;
				}
				
				t=setTimeout("changeImgTime('"+num+"')",10000);
		}
}

function setScroll(x,y)
{
	window.scrollTo(x,y);
}
//Trivia section functions
function displaySuggest(id,style)
{
	document.getElementById(id).style.display	=	style;
}

function reportValidation(frmName)
{
	var count1=0;
	for(var k=0;k<frmName.length;k++)
	{
		elm = frmName.elements[k];
		if(elm.type =="checkbox" && elm.checked ==true)
		{
			count1++;
		}
	}
	if(document.getElementById('chkSelectAll').checked == true)
	{
		document.getElementById('hdnChkValAll').value= 1 ;
	}
	if(count1<= 0)
	{
		alert("Please select at least one check box");
		return false;
	}
	else
	{
			var tem="";
			if(document.frmTrivia.chkSelect	!=	null)
			{
				var index = document.frmTrivia.chkSelect.length;
				if(index == undefined)
				{
					index =1;
				}
			}
			if(index ==1)
			{
				 if(document.frmTrivia.chkSelect.checked)
				{
				 var id =document.frmTrivia.chkSelect.value;
				 tem = tem+id+"$$";
				 id="";
				}
			}
			else
			{
				for(i=0;i<index;i++)
					{
						 if(document.frmTrivia.chkSelect[i].checked)
						 {
							 var id =document.frmTrivia.chkSelect[i].value;
							 //document.getElementById('hdnChkVal').value= "$$"+i ;
							 tem = tem+id+"$$";
							 id="";
						 }
					}
			}
			document.getElementById('hdnCheckval').value =tem;
			// code for adding question
			document.getElementById('hdnMsgid').value = 89;
			//document.frmTrivia.action	=	'/trivia/questionlist.htm';
			document.frmTrivia.submit();
	}
}


function daccordian(basepath)
{	
	
	ddaccordion.init({
	headerclass: "music-charts", //Shared CSS class name of headers group
	contentclass: "submenu", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: false, //persist state of opened contents within browser session?
	toggleclass: ["statusicon", "statusicon"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["suffix", "<img src='http://"+basepath+"/images/frontend/plus.png' class='statusicon' />", "<img src='http://"+basepath+"/images/frontend/minus.png' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "normal", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	
	oninit:function(headers, expandedindices)
	{	 
		//custom code to run when headers have initalized
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})
}
function add(box,boxVal)
{
	if(document.getElementById(box).value=='')
	{
		document.getElementById(box).value = boxVal;
		document.getElementById(box).style.color = "gray";
	}          
}

function removeText(box,text)
{
	if(strtrim(document.getElementById(box).value) == text)
	{
		document.getElementById(box).value = "";
		document.getElementById(box).style.color = "black";
	}
 
}
var i,temp="";

function viewlistpage(frmName)
{
		
		if(document.getElementById('hdnSessionval').value == '')
		{
			alert("Please add questions to trivia report.");
			return false;
		}
		document.frmTrivia.action	=	'/trivia/questionlist.htm';
		document.frmTrivia.submit();
}
function deleteTriviaQue(frmName)
{
	var count2=0;
	for(var k=0;k<frmName.length;k++)
	{
		elm = frmName.elements[k];
		if(elm.type =="checkbox" && elm.checked ==true)
		{
			count2++;
		}
	}
	if(count2<= 0)
	{
		alert("Please select at least one check box");
		return false;
	}
	else
	{
		var tem1="";
		if(document.frmGenerate.chkSelect	!=	null)
		{
			var index = document.frmGenerate.chkSelect.length;
			if(index == undefined)
			{
				index =1;
			}
		}
		if(index ==1)
		{
			 if(document.frmGenerate.chkSelect.checked)
			{
			 var id =document.frmGenerate.chkSelect.value;
			 tem1 = tem1+id+"$$";
			 id="";
			}
		}
		else
		{
			for(i=0;i<index;i++)
				{
					 if(document.frmGenerate.chkSelect[i].checked)
					 {
						 var id =document.frmGenerate.chkSelect[i].value;
						 tem1 = tem1+id+"$$";
						 id="";
					 }
				}
		}
		document.getElementById('hdnDeltrvid').value =tem1;
	}

}

function getShop(frmName,val,fldVal,url)
{	
	var frm = frmName;
	document.getElementById(fldVal).value	=	val;
	frm.action = url;
	frm.submit();
} 

function getVideoDetails(value)
{
	var detail	=	document.getElementById('video'+value).value
	var val	=	detail.split('%%');
	document.getElementById('vdTitle').innerHTML	=	val[2];
}


function daysInMonth(iMonth, iYear)
{
	return 32 - new Date(iYear, iMonth, 32).getDate();
}

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year)
{
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function isDate(dtStr)
{	
	//var daysInMonth = DaysArray(12);
	var pos1	=	dtStr.indexOf(dtCh)
	var pos2	=	dtStr.indexOf(dtCh,pos1+1)
	var strMonth=	dtStr.substring(0,pos1)
	var strDay	=	dtStr.substring(pos1+1,pos2)
	var strYear	=	dtStr.substring(pos2+1)
	
	strYr		=	strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) 
		strDay=strDay.substring(1);

	if (strMonth.charAt(0)=="0" && strMonth.length>1) 
		strMonth=strMonth.substring(1);

	for (var i = 1; i <= 3; i++) 
	{
		if (strYr.charAt(0)=="0" && strYr.length>1) 
			strYr=strYr.substring(1);
	}
	
	var month 	= parseInt(strMonth);
	var day 	= parseInt(strDay);
	var year 	= parseInt(strYr);
	
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	
	if ( (strDay.length<1) || (day<1) || (day>31) || (month==2 && day>daysInFebruary(year)) || (day > daysInMonth(month,year) ))
	{
		alert("Please enter a valid day");
		return false
	}

	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	
	if(strYear == '')
	{
		alert("Please enter a valid year");
		return false;
	}

	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
	//return true
}

function BiographyAjax(mode, pagenum, id)
{	
	var aUrl = "/includes/ajax/pagingajax.php?mode="+mode+"&pagenum="+pagenum+"&id="+id;//alert(aUrl);
	aRequestGet(aUrl, GetResponseBiographyAjax)
}

function GetResponseBiographyAjax (flag, value)
{
	if(flag)
	{	
		var content = value.split("$$");
		document.getElementById(content[0]).innerHTML = content[1];
	}
}

//FUNCTION FOR VALIDATING CONTACT-US FORM
function validateContact(frmName)
{
	var frm = frmName;
	if(checkBlank(frm.txtContName," Name ") == false)
		return false;
	if(checkBlank(frm.txtContSub," Subject ") == false)
		return false;
	if(checkBlank(frm.txtContEmail," Email-Address ") == false)
		return false;
	if(checkEmail(frm.txtContEmail," Email-Address ") == false)
		return false;
	if(checkBlank(frm.txtContMsg," Your Comment ") == false)
		return false;
	if(checkBlank(frm.txtCaptchaCode, " Verification Code ") == false)
	{
		return false;
	}
	else
	{	
		document.getElementById('errMsg').style.display = "";
		var captchacode	=	document.getElementById('txtCaptchaCode').value;
		var name		=	document.getElementById('txtContName').value;
		var subject		=	document.getElementById('txtContSub').value;
		var email		=	document.getElementById('txtContEmail').value;
		var siteurl		=	document.getElementById('txtContUrl').value;
		var message		=	document.getElementById('txtContMsg').value;

		var aUrl	=	"/includes/ajax/bandinfo.php?mode=contactus&captchacode="+captchacode+"&name="+name+"&subject="+subject+"&email="+email+"&siteurl="+siteurl+"&message="+message+"&rand="+Math.random();//alert(aUrl);
		aRequestGet(aUrl, GetResponseContact);
		return false;
	}
}

function GetResponseContact(flag, value)
{	
	if(flag) {
		document.getElementById('errMsg').style.display = "none";
		if(value == 0) {

			document.getElementById('errMsg').innerHTML = "<b>Invalid Verification Code</b>";
			document.getElementById('errMsg').style.display = "";
			document.getElementById('txtCaptchaCode').value = '';
			document.getElementById('txtCaptchaCode').focus();
			window.frames['contactcaptcha'].location.reload();
			return false;

		} else {

 			parent.$(".contact").colorbox.close() //CLOSING THE COLORBOX POPUP
			$.fn.colorbox({href:"http://"+location.host+"/ackContact.html"});

			 $(document).ready(function() {
            $.fn.colorbox({href:"http://"+location.host+"/ackContact.html", open:true}) ;}); 
		}
	}
}

//FUNCTION FOR VALIDATING ARTISTS BIOGRAPHY 'UPLOAD IMAGE' POPUP PAGE
function validateBioImage(frmName,artId)
{	
	var frm		=	frmName;
	if(frm.id == "frmBioUploadImage") {

		var code	=	document.getElementById('txtImageArtCaptchaCode'+artId);
		if(checkBlank(frm.flArtistImage," Image ") == false)
			return false;
		if(frm.chkTerms.checked == false)
		{
			alert('Please agree to the terms and conditions to upload image');
			return false;
		}
		if(checkBlank(code, " Verification Code ") == false)
			return false;
		else
		{
			document.getElementById('errMsgImage').style.display = "";
			document.getElementById('frmBioUploadImage').action = "/upload.php?type=artist&captchacode="+document.getElementById('txtImageArtCaptchaCode'+artId).value;
			return true;
		}

	} else if(frm.id == "frmBandUploadImage") {

		var code	=	document.getElementById('txtImageBandCaptchaCode'+artId);
		if(checkBlank(frm.flBandImage," Image ") == false)
			return false;
		if(frm.chkBandTerms.checked == false)
		{
			alert('Please agree to the terms and conditions to upload image');
			return false;
		}
		if(checkBlank(code, " Verification Code ") == false)
			return false;
		else
		{
			document.getElementById('errMsgBandImage').style.display = "";
			document.getElementById('frmBandUploadImage').action = "/upload.php?type=band&captchacode="+document.getElementById('txtImageBandCaptchaCode'+artId).value;
			return true;
		}
	}
}

function GetResponseArtistImageUpload(value)
{
	
	document.getElementById('errMsgImage').style.display = "none";
	if(value == '0') {

		document.getElementById('errMsgImage').innerHTML = "<b>Invalid Verification Code</b>";;
		document.getElementById('errMsgImage').style.display = "";
		document.getElementById('txtImageArtCaptchaCode'+document.getElementById('hdnArtistId').value).value = "";
		document.getElementById('txtImageArtCaptchaCode'+document.getElementById('hdnArtistId').value).focus();
		window.frames['uploadimageartistcaptcha'].location.reload();
		return false;	

	} else if(value == '1') {

		parent.$(".uploadimage").colorbox.close() //CLOSING THE COLORBOX POPUP
		document.getElementById('msgdiv').innerHTML = "Your image has been sent to admin for approval";
		document.getElementById('msgdiv').style.display = "";

	} else { 
		document.getElementById('errMsgImage').innerHTML = value;
		document.getElementById('errMsgImage').style.display = "";
		return false;
	}
}

function GetResponseBandImageUpload(value) {
	
	document.getElementById('errMsgBandImage').style.display = "none";
	if(value == '0') {

		document.getElementById('errMsgBandImage').innerHTML = "<b>Invalid Verification Code</b>";;
		document.getElementById('errMsgBandImage').style.display = "";
		document.getElementById('txtImageBandCaptchaCode'+document.getElementById('hdnBandId').value).value = "";
		document.getElementById('txtImageBandCaptchaCode'+document.getElementById('hdnBandId').value).focus();
		window.frames['uploadimagebandcaptcha'].location.reload();
		return false;	

	} else if(value == '1') {

		parent.$(".banduploadimage").colorbox.close() //CLOSING THE COLORBOX POPUP
		document.getElementById('msgdiv').innerHTML = "Your image has been sent to admin for approval";
		document.getElementById('msgdiv').style.display = "";

	} else { 
		document.getElementById('errMsgBandImage').innerHTML = value;
		document.getElementById('errMsgBandImage').style.display = "";
		return false;
	}
}

//ADDED ON 19TH JAN 2011 FOR BAND GALLERY.
function getImageData(img, imgId, imgTitle, firstid, lastid, detArr, type){

	if(imgId == firstid && imgId == lastid) {

		document.getElementById('prev').innerHTML = "<img src='images/frontend/gallery-buttan.gif' border='0' />";
		document.getElementById('next').innerHTML = "<img src='images/frontend/gallery-next.gif' border='0' />";

	} else if(imgId == lastid) {
	
		document.getElementById('prev').innerHTML = "<img src='images/frontend/gallery-prev.gif' border='0' style='cursor:pointer;' title='Prev' alt='Prev' alt='Next' title='Next' onclick=\"javascript: test('"+detArr+"', 'prev', '"+firstid+"', '"+lastid+"')\" />";
		document.getElementById('next').innerHTML = "<img src='images/frontend/gallery-next.gif' border='0' />";

	} else if(imgId == firstid) { 

		document.getElementById('prev').innerHTML = "<img src='images/frontend/gallery-buttan.gif' border='0' />";
		document.getElementById('next').innerHTML = "<img src='images/frontend/gallery-green-buttan.gif' border='0' style='cursor:pointer;' alt='Next' title='Next' onclick=\"javascript: test('"+detArr+"', 'next', '"+firstid+"', '"+lastid+"')\" />"

	} else {	

		document.getElementById('prev').innerHTML = "<img src='images/frontend/gallery-prev.gif' border='0' style='cursor:pointer;' title='Prev' alt='Prev' alt='Next' title='Next' onclick=\"javascript: test('"+detArr+"', 'prev', '"+firstid+"', '"+lastid+"')\" />";
		document.getElementById('next').innerHTML = "<img src='images/frontend/gallery-green-buttan.gif' border='0' style='cursor:pointer;' alt='Next' title='Next' onclick=\"javascript: test('"+detArr+"', 'next', '"+firstid+"', '"+lastid+"')\" />";

	}
	document.getElementById("bigImage").style.display = 'none';
	document.getElementById('bigImage').innerHTML = img;
	document.getElementById('bigImage').title = imgTitle;
	document.getElementById('bigImage').alt = imgTitle;
	document.getElementById('hndPhotoId').value = imgId;
	document.getElementById("ShowLoading").style.display = 'inline';
	setTimeout("getComments('"+imgId+"', '0', '"+type+"')", 1000 );
}


function test(idArr, type, firstid, lastid, flag) {
	
	var value = idArr.split("-");
	var val = document.getElementById('hndPhotoId').value;
	
	for(var i=0; i<value.length; i++) {
		
		if(value[i] != '') { 
			var detail = value[i].split("$$");	
			
			if(detail[2].indexOf(val) != -1) {
				var key = i;
			}
		}
	}
	
	if(type == 'prev') { 
			var index = parseInt(key - 1);
	} else {
		var index = parseInt(key + 1);
	}
	
	var text = value[index].split("$$");

	if(text[4] == 'band') {
		var img = "<img src='/bandphotogly/"+text[0]+"' border='0' width='"+text[1]+"' />";
		var arttype = "bandimage"; 
	} else {
		var img = "<img src='/photogly/"+text[0]+"' border='0' width='"+text[1]+"' />";
		var arttype = "artistimage"; 
	}
	
	var imgId = text[2];
	var imgTitle = text[3];
	getImageData(img, imgId, imgTitle, firstid, lastid, idArr, arttype)
}

function getImageDataAll(img, imgId, imgTitle, firstid, lastid, detArr, type){
	
	var cVal = imgId.split("**");
	var Id = cVal[0];
	var compareValue = cVal[1];

	if(compareValue == firstid && compareValue == lastid) {

		document.getElementById('prev').innerHTML = "<img src='images/frontend/gallery-buttan.gif' border='0' />";
		document.getElementById('next').innerHTML = "<img src='images/frontend/gallery-next.gif' border='0' />";

	} else if(compareValue == lastid) {
	
		document.getElementById('prev').innerHTML = "<img src='images/frontend/gallery-prev.gif' border='0' style='cursor:pointer;' title='Prev' alt='Prev' alt='Next' title='Next' onclick=\"javascript: testall('"+detArr+"', 'prev', '"+firstid+"', '"+lastid+"', '"+compareValue+"')\" />";
		document.getElementById('next').innerHTML = "<img src='images/frontend/gallery-next.gif' border='0' />";

	} else if(compareValue == firstid) { 

		document.getElementById('prev').innerHTML = "<img src='images/frontend/gallery-buttan.gif' border='0' />";
		document.getElementById('next').innerHTML = "<img src='images/frontend/gallery-green-buttan.gif' border='0' style='cursor:pointer;' alt='Next' title='Next' onclick=\"javascript: testall('"+detArr+"', 'next', '"+firstid+"', '"+lastid+"' ,'"+compareValue+"')\" />"

	} else {	

		document.getElementById('prev').innerHTML = "<img src='images/frontend/gallery-prev.gif' border='0' style='cursor:pointer;' title='Prev' alt='Prev' alt='Next' title='Next' onclick=\"javascript: testall('"+detArr+"', 'prev', '"+firstid+"', '"+lastid+"',  '"+compareValue+"')\" />";
		document.getElementById('next').innerHTML = "<img src='images/frontend/gallery-green-buttan.gif' border='0' style='cursor:pointer;' alt='Next' title='Next' onclick=\"javascript: testall('"+detArr+"', 'next', '"+firstid+"', '"+lastid+"',  '"+compareValue+"')\" />";

	}

	document.getElementById("bigImage").style.display = 'none';
	document.getElementById('bigImage').innerHTML = img;
	document.getElementById('bigImage').title = imgTitle;
	document.getElementById('bigImage').alt = imgTitle;
	document.getElementById('hndPhotoId').value = Id;
	document.getElementById("ShowLoading").style.display = 'inline';
	setTimeout("getComments('"+Id+"', '1', '"+type+"')", 1000 );
	
}

function testall(idArr, type, firstid, lastid, id) {
	
	var value = idArr.split("-");
	for(var i=0; i<value.length; i++) {
		
		if(value[i] != '') { 
			var detail = value[i].split("$$");
			
			if(detail[5] == id) {
				var key = i;
			}
		}
	}
	
	if(type == 'prev') { 
			var index = parseInt(key - 1);
	} else {
		var index = parseInt(key + 1);
	}
	var text = value[index].split("$$");//alert(text);
	
	if(text[4] == 'band') {
		var img = "<img src='/bandphotogly/"+text[0]+"' border='0' width='"+text[1]+"' />";
		var arttype = "bandimage"; 
	} else {
		var img = "<img src='/photogly/"+text[0]+"' border='0' width='"+text[1]+"' />";
		var arttype = "artistimage"; 
	}
	
	var imgId = text[2]+'**'+text[5];
	var imgTitle = text[3];
	getImageDataAll(img, imgId, imgTitle, firstid, lastid, idArr, arttype)
}

function getComments(imgId, flag, type) {

	if(flag == 1)
		var aUrl = "/includes/ajax/frontajax.php?action=commentcount&type="+type+"&imgId="+imgId;
	else
		var aUrl = "/includes/ajax/frontajax.php?action=bandcomments&type="+type+"&imgId="+imgId;

	aUrl += "&rand="+Math.random();
	//alert(aUrl);
	aRequestGet(aUrl, GetResponseComments)
}

function GetResponseComments (flag, value) {
	if(flag) {

		//alert(value);
		var val = value.split("----");//alert(val);

		if(val[0] == "commentcount") {

			if(val[1] != '0') {
				document.getElementById('CommText').innerHTML = "Comments:&nbsp;";
				document.getElementById('CommValue').innerHTML = '<a href="'+val[6]+'">('+val[1]+')</a>';
				document.getElementById('CommText').style.display = '';
				document.getElementById('CommValue').style.display = '';
			} else {
				document.getElementById('CommText').style.display = 'none';
				document.getElementById('CommValue').style.display = 'none';
			}

			if(val[3] != '0') {
				document.getElementById('ViewMore').innerHTML = '<a href="'+val[4]+'">View More '+val[5]+' Images ('+val[3]+')</a>'
				document.getElementById('ViewMore').style.display = '';
			} else {
				document.getElementById('ViewMore').style.display = 'none';
			}
			document.getElementById('hdnBandId').value = val[8];
			document.getElementById('hdnType').value = val[7];

		} else {
			document.getElementById('commentSection').innerHTML = val[1];
		}

		var detail = val[2].split("$$DWEB$$");//alert(detail);
		document.getElementById("ShowLoading").style.display = 'none';
		document.getElementById("bigImage").style.display = 'inline';

		if(detail[0] != '') {
			document.getElementById('captText').innerHTML = "Caption:";
			document.getElementById('captValue').innerHTML = detail[0];
			document.getElementById('captText').style.display = '';
			document.getElementById('captValue').style.display = '';
		} else {
			document.getElementById('captText').style.display = 'none';
			document.getElementById('captValue').style.display = 'none';
		}

		if(detail[1] != '') {
			document.getElementById('Source').innerHTML = "Source:&nbsp;"+detail[1];
			document.getElementById('Source').style.display = '';
		} else {
			document.getElementById('Source').style.display = 'none';
		}	

		if(detail[2] != '') {
			document.getElementById('By').innerHTML = "By:&nbsp;"+detail[2];
			document.getElementById('By').style.display = '';
		} else {
			document.getElementById('By').style.display = 'none';
		}

		if(detail[3] != '' & detail[4] != '')
			document.getElementById('imgDimension').innerHTML = detail[3]+"&nbsp;&times;&nbsp;"+detail[4]+"&nbsp;pixels";
		if(detail[5] != '')
			document.getElementById('imgType').innerHTML = detail[5].split("/")[1];
		if(detail[6] != '')
			document.getElementById('imgDate').innerHTML = detail[6];

		
	}
}

function bGalleryCommentsPaging(mode, pagenum, id, type) {

	document.getElementById("commentSection").style.display = "none";
	var aUrl = "/includes/ajax/frontajax.php?action="+mode+"&pagenum="+pagenum+"&imgId="+id+"&type="+type;//alert(aUrl);
	aRequestGet(aUrl, GetResponseGalleryComments)
}

function GetResponseGalleryComments(flag, value) {

	if(flag) {
		var comment = value.split("----");
		document.getElementById("commentSection").innerHTML = comment[1];
		document.getElementById("commentSection").style.display = "";
		//alert(value);
	}
}

function reportAbuse(idFld,reasonFld, mailFld,nameFld, typeFld, artIdFld)
{	
	var id 		= document.getElementById(idFld).value;
	var reason 	= document.getElementById(reasonFld).value;
	var mail 	= document.getElementById(mailFld).value;
	var name 	= document.getElementById(nameFld).value;
	var type 	= document.getElementById(typeFld).value;
	var artid 	= document.getElementById(artIdFld).value;

	if(checkBlank(document.getElementById(nameFld),"Name ")==false)
		return false;
	if(checkBlank(document.getElementById(mailFld),"Email address ")==false)
		return false;
	if(checkEmail(document.getElementById(mailFld)," E-mail Address ") == false)
		return false;

	var aUrl = "/includes/ajax/frontajax.php?action=reportabuse&type="+type+"&id="+artid+"&imgid="+id+"&reason="+reason+"&name="+name+"&email="+mail+"&rand="+Math.random();//alert(aUrl);
	aRequestGet(aUrl, GetResponseAbuse)
}

function GetResponseAbuse(flag, value)
{
	if(flag)
	{	
		if(value == 1) {
			parent.$(".imageabusediv").colorbox.close() //CLOSING THE COLORBOX POPUP
			document.getElementById("errorMsg").style.display = '';
			document.getElementById("errorMsg").innerHTML = "<b>Reported abuse to administrator</b>";
		}
	}
}

function charCounter(fldName,length) {

	var length = parseInt(length);//alert(document.getElementById(fldName).value.length);alert(length);
	if(document.getElementById(fldName).value.length > length) {

		document.getElementById(fldName).value = document.getElementById(fldName).value.substring(0,length);
        document.getElementById(fldName).value.length = document.getElementById(fldName).value;
		return false;
	}
}
//ADDED ON 19TH JAN 2011 FOR BAND GALLERY.
