



function check_shows()
{
if($id('djs').value=="")
{alert("Please Select and Add Dj");$id('Dj_id').focus();return false;}

if($id('show_country').value=="")
{alert("Please Select Country");$id('country').focus();return false;}

if($id('state_id').value=="")
{alert("Please select State");$id('state_id').focus();return false;}

if($id('show_city').value=="")
{alert("Please Select City");$id('city').focus();return false;}

/*if($id('address').value=="")
{alert("Please Enter Address");$id('address').focus();return false;}*/

if($id('venue_id').value=="")
{alert("Please Select Event Venue");$id('venue_id').focus();return false;}

if($id('venue_id').value=="00")
{alert("There is no venue associated with this location. pls add new venue before submitting Event details.");$id('venue_id').focus();return false;}

if($id('start_month').value=="")
{alert("Please Select Show Start Month");$id('start_month').focus();return false;}

if($id('start_date').value=="")
{alert("Please Select Show Start Date");$id('start_date').focus();return false;}

if($id('start_year').value=="")
{alert("Please Select Show Start Year");$id('start_year').focus();return false;}

if($id('start_hour').value=="")
{alert("Please Select Show Start Time");$id('start_hour').focus();return false;}

/*if($id('event_name').value=="")
{alert("Please Enter Event Name");$id('event_name').focus();return false;}*/

if($id('event_flyer1').value!="")
{if(!isvalidphoto($id('event_flyer1').value))
{alert("Uploading image type should be among .jpg, .gif, .jpeg, .png or .bmp ");$id('event_flyer1').value='';$id('event_flyer1').focus();return false;}}
//alert($id('event_url').value);
/*if($id('event_url').value!='')
{
	var theurl=$id('event_url').value;
  	var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
		 if (tomatch.test(theurl))
				{
					 //window.alert("URL OK.");
					 return true;
				}
		 else
				{
					 window.alert("Please Enter valid URL . ");
					 return false; 
				}
	
}*/

return true;}


var current_djName=new Array();
var current_djID=new Array();


function add_djname(){

	dj_val=document.getElementById('Dj_id').value;
	var array_val=dj_val.split("#");
	if(in_array(array_val[1],current_djID)){
	
	alert(array_val[0]+' is already selected ');
	
	} else {
	current_djID[current_djID.length]=array_val[1];
	current_djName[current_djName.length]=array_val[0];
	show_djName();
	}
}
function show_djName(){
document.getElementById('djs').value=implode(",",current_djID);
var str="";

	for(var a=0;a<current_djID.length;a++){
	var userstring = current_djName[a];
	var brokenuserstring = userstring.split(",");  
	if(str!=""){ str+="</br>"; var hl=""; } else {var hl="<font color='red'>Headliner</font>"}
	str+=brokenuserstring[0]+"&nbsp;"+hl+"&nbsp;(<a style='cursor:pointer' onclick=\"removeDj('"+a+"');\"  class='Light10a Blue10'>Remove</a>)<br/>";
	}
if(str=="") str="No Dj Selected";	
document.getElementById('added_djs').innerHTML=str;
document.getElementById('Dj_id').selectedIndex = 0; 	
}

function removeDj(index){
var temp_arrayName=new Array();
var temp_arrayID=new Array();
var newIndex=0;
	for(var b=0;b<current_djID.length;b++){
		if(b!=index){
		temp_arrayName[newIndex]=current_djName[b];
		temp_arrayID[newIndex]=current_djID[b];	
		newIndex++;
		}
	}
	current_djID=temp_arrayID;
	current_djName=temp_arrayName;
	show_djName();
}


function show_event_comment()
 {
		if(document.getElementById('post_comment').style.display=='none' )
				document.getElementById('post_comment').style.display='';
		else 
				document.getElementById('post_comment').style.display='none';
 }
 
function addnew_city(val)
{
	if(val=='add_city')
	{
		document.getElementById("city_nm").style.display='none';
		document.getElementById("add_city_nm").style.display='';
	}
	else
	{
		document.getElementById("add_city_nm").style.display='none';
		document.getElementById("city_nm").style.display='';
	}	
}
function add_city_to_db()
{
	if(document.getElementById("newcity_name").value=="")
	{
		alert("Please Enter City Name !")
		document.getElementById("newcity_name").focus();
		return false;
	}
	document.getElementById("city_nm").style.display='';
	document.getElementById("add_city_nm").style.display='none';
	var city_val =document.getElementById("newcity_name").value; 
	document.getElementById("newcity_name").value='';
	var url=SiteUrl+"shows/show_operations.php?action=add_city&city_name="+city_val;
	ajaxLink(url,"city_nm");return true;
	return true;
}
function post_event_comment(id)
{
		if(document.getElementById("comment_event").value=="")
		{
			alert("Please Enter Review ")
			document.getElementById("comment_event").focus();
			return false;
		}
		checkcode(document.getElementById("code").value);
		
	return true;
}





//Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
 if (window.XMLHttpRequest) {
    return new XMLHttpRequest(); //Mozilla, Safari ...
 } else if (window.ActiveXObject) {
    return new ActiveXObject("Microsoft.XMLHTTP"); //IE
 } else {
    //Display our error message
    alert("Your browser doesn't support the XmlHttpRequest object.");
 }
}


var receiveReq = getXmlHttpRequestObject();

//Initiate the AJAX request
function makeRequest(url, param) {
//If our readystate is either not started or finished, initiate a new request
 if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
   //Set up the connection to captcha_test.html. True sets the request to asyncronous(default) 
   receiveReq.open("POST", url, true);
   //Set the function that will be called when the XmlHttpRequest objects state changes
   receiveReq.onreadystatechange = updatePage; 

   //Add HTTP headers to the request
   receiveReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   receiveReq.setRequestHeader("Content-length", param.length);
   receiveReq.setRequestHeader("Connection", "close");

   //Make the request
   receiveReq.send(param);
 }   
}


//Called every time our XmlHttpRequest objects state changes
function updatePage() {
	

 //Check if our response is ready
 if (receiveReq.readyState == 4) {

	 //alert(receiveReq.responseText);
   //Set the content of the DIV element with the response text
   if(receiveReq.responseText == 1)
   {
	    var	email_id = document.getElementById('email_id').value;
		var message = document.getElementById('message').value;
		var event_invite_id = document.getElementById('event_invite_id').value;
		document.getElementById('email_id').value="";
		document.getElementById('message').value="";
		document.getElementById('code').value="";
		img = document.getElementById('imgCaptcha'); 
		//Change the image
		img.src = 'image.php?' + Math.random();
		ajaxLink(SiteUrl+"shows/show_operations.php?action=invite&email_id="+email_id+"&message="+message+"&event_id="+event_invite_id,"invite_friend_box");
	   //alert(document.getElementById('dj1').value+" already exist.");
		//document.getElementById('dj1').value="";
		//document.getElementById('dj1').focus();
		return false;
   }
   else
	{
	   alert('The entered Text was not correct. Please try again'); 
			document.getElementById("code").value=''; 
			document.getElementById("code").focus(); 
			img = document.getElementById('imgCaptcha'); 
			//Change the image
			img.src = 'image.php?' + Math.random();
			return false; 
	}

   //Get a reference to CAPTCHA image
   //img = document.getElementById('imgCaptcha'); 
   //Change the image
   //img.src = 'create_image.php?' + Math.random();
 }
}


//Called every time when form is perfomed
function checkcode(theForm) {
 //Set the URL
 var url = 'captcheck.php';
 //Set up the parameters of our AJAX call
 var postStr = "code=" + encodeURIComponent( document.getElementById("code").value );
 //alert(postStr);
 //Call the function that initiate the AJAX request
 makeRequest(url, postStr);
}



function invite_friend(id)
{
//alert(id);		 
	if(document.getElementById('email_id').value=="")
		{
		alert("Please Enter Email Address");
		document.getElementById("email_id").focus();
		return false;
		}
	if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById("email_id").value)))
		{
		alert("Please Enter a Valid Email Address!!");
		document.getElementById("email_id").focus();
		return false;
		}
	/*if(document.getElementById('from_email_id').value=="")
		{
		alert("Please Enter Your Email Address");
		document.getElementById("from_email_id").focus();
		return false;
		}
	if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById("from_email_id").value)))
		{
		alert("Please Enter a Valid Email Address!!");
		document.getElementById("from_email_id").focus();
		return false;
		}		*/
	if(document.getElementById('message').value=="")
		{
		alert("Please Enter Message");
		document.getElementById("message").focus();
		return false;	
		}
		
		
	//checkcode(document.getElementById("code").value); 
	checkcode(document.getElementById("code").value);
	
	


return true;
}


function attend_event(eid,event_name)
{
	var eventname = event_name.replace("$%*", "'")
	if(window.confirm("Please confirm you're going to "+eventname))
	{
		ajaxLink(SiteUrl+"shows/operations.php?action=attend_show&eid="+eid,"attend_show_"+eid);
	}
	else
		return false;
}

function attend_event_detail(event_name,eid,divid)
{
	if(window.confirm("Please confirm you're going to "+event_name))
	{
		ajaxLink(SiteUrl+"shows/operations.php?action=attend_show_detail&event_id="+eid,divid);
		document.getElementById('attend_span').innerHTML="";
	}
	else
		return false;
}

function citydj_validate(val)
{
	if(document.getElementById("dj").value=='' && document.getElementById("city_id").value=='')
	{
		alert("Please Select search values")
		document.getElementById("dj").focus();
		return false;
	}
	return true;
	//var dj_id = document.getElementById("dj").value ;
	//var city_id = document.getElementById("city_id").value ;
	//ajaxLink(SiteUrl+"shows/operations.php?action=search_event&dj_id="+dj_id+"&city_id="+city_id+"&type="+val,"result_event");
}

function search_citydj_event(val)
{
	if(document.getElementById("dj").value=='' && document.getElementById("city_id").value=='')
	{
		alert("Please Select search values")
		document.getElementById("dj").focus();
		return false;
	}
	var dj_id = document.getElementById("dj").value ;
	var city_id = document.getElementById("city_id").value ;
	if(val=='picture')
		ajaxLink(SiteUrl+"people/operations.php?action=event_pictures&dj_id="+dj_id+"&city_id="+city_id,"retult_pictures");
	else
		ajaxLink(SiteUrl+"people/operations.php?action=event_videos&dj_id="+dj_id+"&city_id="+city_id,"result_videos");
	
}
 function fun1(djid)
 {
	 //alert(djid);
	 ajaxLink(SiteUrl+"shows/operations.php?action=dj_citybox_picture&dj="+djid,"id_city_box");
 }
 function fun2(djid)
 {
	// alert(djid);
	
	 ajaxLink(SiteUrl+"people/operations.php?action=event_pictures&dj_id="+djid,"retult_pictures");
	
 }
 
 function fun3(djid)
 {
	 //alert(djid);
	 ajaxLink(SiteUrl+"shows/operations.php?action=dj_citybox_video&dj="+djid,"id_city_box");
 }
 function fun4(djid)
 {
	// alert(djid);
	 ajaxLink(SiteUrl+"people/operations.php?action=event_videos&dj_id="+djid,"result_videos");
	 
 }





function show_citybox(val)
{

	setTimeout('fun1('+val+')',1000);
	fun2(val);
	//return ajaxLink(SiteUrl+"people/operations.php?action=event_pictures&dj_id="+val,"retult_pictures");
	//sleep(1);
	//alert("test");
	//var djid = val;
	
	
	//fun1(djid);
	//ajaxLink(SiteUrl+"people/operations.php?action=event_pictures&dj_id="+val,"retult_pictures");
}
function show_citybox1(val)
{
	//ajaxLink(SiteUrl+"shows/operations.php?action=dj_citybox_video&dj="+val,"id_city_box");
	setTimeout('fun3('+val+')',1000);
	fun4(val);
}
function show_djbox(val)
{
	ajaxLink(SiteUrl+"shows/operations.php?action=city_djbox&city="+val,"id_dj_box");	
}

function add_event_pitcure11()
	{
		var atleastselected = false;		
		
		if(document.getElementById("event_id").value=='')
			{
				alert("Please Select a Event")
				document.getElementById("event_id").focus();
				return false;
			}
		
		for(var i=1;i<=3;i++)
		{	
				if(document.getElementById("Title"+i).value!='')
				{
					if(document.getElementById("picture"+i).value=='')
						{
							alert("Please Upload Picture")
							document.getElementById("picture"+i).focus();
							return false;
						}
						
				}
				if(document.getElementById("picture"+i).value!='')
				{
					if(isvalidphoto(document.getElementById("picture"+i).value))
						{
						return true;
						}
						else
						{
							alert("Uploading image type should be among .jpg, .gif, .jpeg, .png or .bmp");
							return false;
							break;
						}
					if(document.getElementById("Title"+i).value=='')
						{
							alert("Please Enter Title value")
							document.getElementById("Title"+i).focus();
							return false;
						}
				}
			 if(document.getElementById("Title"+i).value!='' && document.getElementById("picture"+i).value!='')
						{
							atleastselected= true;	
						}
		}
		
	if(atleastselected==false)
		{
			alert("Please Upload atleast one photo");
			return false;
		}
		
	return true;
	
}
function delete_event_video()
{    
		var flag=0;
			var Message="Delete";
			  var id="";
				for(i=0;i<document.frm11_product.elements.length;i++)
				{
					if(document.frm11_product.elements[i].type=="checkbox")
					{
						if(document.frm11_product.elements[i].checked==true)
						{
							flag=1;
							if(id=="")
							  id=id+document.frm11_product.elements[i].value;
							   else
							  id=id+","+document.frm11_product.elements[i].value;
						}
					}
			  }
		 if(flag==0)
			 {
			 	alert("Please select the Video to Delete." );
				return false;
			 }
			 else
			 {
				var confirmdelete = window.confirm("Are you sure you want to  " + Message + " the selected Messages?")
				if (confirmdelete){
					ajaxLink(SiteUrl+"shows/show_operations.php?action=eventvideos&id="+id,"result_my_videos");
					return false;
				}
			}
}

function open_win(url,width,height)
{
		
remote=window.open(url,'calander','status=no,scrollbars=yes,resizable=yes,top=0,left=0,height='+height+',width='+width);
		if (remote != null)
		{	
			if (remote.opener == null)
			remote.opener = self;
		}
	}
	
	
/*function cityValid(frm)
{
	
	if (!validRequired(frm.city,"City"))
		return false;
	if(frm.city.value!='')
	{
		var charpos = frm.city.value.search("[^A-Za-z0-9\s]+$"); 
		if(charpos >= 0) 
		{ 
			alert('Only alpha-numeric characters are allowed in City Field'); 
			frm.city.focus();
			return false; 
		} 
	}
	if (!validRequired(frm.state,"State"))
		return false;
	if(frm.state.value!='')
	{
		var charpos = frm.state.value.search("[^A-Za-z0-9\s]+$"); 
		if(charpos >= 0) 
		{ 
			alert("Only alpha-numeric characters are allowed in State Field"); 
			frm.state.focus();
			return false; 
		} 
	}
	
}


function popUpVenueValid(frm)
{
	if (!validRequired(frm.txtVenue,"Venue Name"))
		return false;
	if(frm.lstCity.value==-1)
	{
		alert('Please Select City');
		return false;
	}
}*/
var lastRow = 1;
function addRow(){	
  
  lastRow += 1;
   
	var numFoto=7;
	if(lastRow<numFoto)
    { 
	if(document.getElementById('imgRow'+lastRow))
	document.getElementById('imgRow'+lastRow).style.display="";
	if(lastRow==6)
		document.getElementById('inc_but').style.display="none";
  	}
  
}
function Delete_flyer(pid,eventid)
{
var photoid=pid;
//alert(pid);
var confirmdelete=window.confirm("Are u sure u want to Delete this picture");
if(confirmdelete)
{
ajaxLink(SiteUrl+"shows/show_operations.php?action=delete_flyer&pid="+photoid+"&eventid="+eventid,"flyer_row");	
}
}

var current_gallery_home=0;

function show_event_gallery(pid)
	{
		switch(pid){
			case "next":
						if(current_gallery_home<event_galArray.length-1){
						current_gallery_home++;	
						}
						else
						current_gallery_home=0;
						break;
			case "prev":
						if(current_gallery_home>0){
						current_gallery_home--;	
						}
						else
						current_gallery_home=event_galArray.length-1;
						break;
			default :	
						current_gallery_home=pid;	
						break;
		}
		
		document.getElementById('gallery_home').src=SiteUrl+"uploads/event_image/"+event_galArray[current_gallery_home];
						
	}
function PastEventFilter(){
 var dj_id=document.getElementById('dj_id').value;
 var name=document.getElementById('name').value;
 if(name=='Enter Name')
 name='';
 var sort1=document.getElementById('sort').value;
 var url=SiteUrl+"shows/show_operations.php?action=pastevents&dj_id="+dj_id+"&name="+name+"&sort="+sort1+"";
 document.getElementById('name').value='Enter Name';
 ajaxLink(url,'result_events');
}
function PastEventToUpcoming()
{
	var qry='';
	var dj_id=document.getElementById('dj_id').value;
	var name=document.getElementById('name').value;
	if(name=='Enter Name')
		name='';
	if(dj_id!='')
		qry+="?dj="+dj_id+"";
	if(name!="")
	{
		if(qry!='')
			qry+="&name="+name;
		else
			qry='?name='+name;
	}
	window.location=SiteUrl+'shows/events.php'+qry;
	
}
function EventFilter(){
 var dj_id=document.getElementById('dj_id').value;
 var name=document.getElementById('name').value;
 if(name=='Enter Name')
 name='';
 var cityid=document.getElementById('city').value;
 var url=SiteUrl+"shows/show_operations.php?action=events&dj_id="+dj_id+"&name="+name+"&cityid="+cityid+"";
 document.getElementById('name').value='Enter Name';
 ajaxLink(url,'result_events');

}

function delete_event_video_new(vid,event_id,memidd)
{
	var confirmdelete=window.confirm("Are you sure you want to Delete this Video?");
	if(confirmdelete)
	{
		window.location=SiteUrl+"shows/delet_event_video.php?vid="+vid+"&event_id="+event_id+"&memidd="+memidd;
	}
}

function check_regusername1(val)
{
	ajaxLink("operation_outer.php?action=check_username&uname="+val,"username1_exist");
}
function check_regusername2(val)
{
	ajaxLink("operation_outer.php?action=check_username&uname="+val,"username2_exist");
}
function check_regusername3(val)
{
	ajaxLink("operation_outer.php?action=check_username&uname="+val,"username3_exist");
}
function check_regusername4(val)
{
	ajaxLink("operation_outer.php?action=check_username&uname="+val,"username4_exist");
}
function check_regusername5(val)
{
	ajaxLink("operation_outer.php?action=check_username&uname="+val,"username5_exist");
}
