
///////////////////////////////////////////// GENERAL ADMIN PANEL ISSUES //////////////////////////////////////////////////////////////
	function SelectDeselectRow(RowID,totalcell,CheckBoxValue ,tempcolor, bgcolor){
		if(CheckBoxValue) {
			for(s=1;s<=totalcell;s++) {
			   document.getElementById("Row"+s+RowID).style.background=tempcolor;
			}
		} else {
			for(s=1;s<=totalcell;s++) {
				document.getElementById("Row"+s+RowID).style.background=bgcolor;
			}
		}
	} // End Function

	///////////////////////////////////////////////////
	function SelectUnselectAll(PresentState,totalcell) {
	
		if (PresentState) {
			for(i=0;i<document.frmList.elements.length;i++) {
				
				if(document.frmList.elements[i].type=="checkbox" && document.frmList.elements[i].name != "SelectAll") {
					
					document.frmList.elements[i].checked=true;
					SelectDeselectRow(document.frmList.elements[i].value,totalcell,true,'#dce5ec',document.frmList.elements[i-1].value,document.frmList.elements[i-2].value)
				}
			}
		} else {
			for(i=0;i<document.frmList.elements.length;i++) {
				
				if(document.frmList.elements[i].type=="checkbox" && document.frmList.elements[i].name != "SelectAll") {
					document.frmList.elements[i].checked=false;
					SelectDeselectRow(document.frmList.elements[i].value,totalcell,false,'#dce5ec',document.frmList.elements[i-1].value,document.frmList.elements[i-2].value)
				}
			}
		} // End Else
	} // End Function

	
	///////////////////////////////////////////////////
	function ChangeStatus(URL,Status,Message) {
		
		var confirmdelete = window.confirm("Are you sure you want to " + Message + " the selected "+document.frmList.item.value+"(s)?\n")
		if (confirmdelete) {
			document.frmList.t_status.value=Status;
			document.frmList.method="post";
			document.frmList.action=URL;
			document.frmList.submit();
		}
	}
			
///////////////////////////////////////////////////////////////////////////////////////////////////////////

//############# Newsletter Send Member Script #############################################################
//#########################################################################################################
function isEmailValid(sEmail) {
	if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(frm_contact.sEmail.value))) {
		alert(" Please Enter the Valid Email ID. ");
		return false;
	}
}
			
function SendResponse(ResponseID,Subject) {
	if(document.frmNewslettersList.SelectedEmailAddresses.options.length!=0) {
		var confirmsave = window.confirm("Are you sure you want to send the selected newsletter \""+Subject+"\" to "+document.frmNewslettersList.SelectedEmailAddresses.options.length+" recepient(s)?")
		if (confirmsave) {
			document.frmNewslettersList.target="_self";
			SelectAllItemsInList('frmNewslettersList','SelectedEmailAddresses');
			document.frmNewslettersList.action=("sendnewsletters.php?ID="+ResponseID+"&subject="+Subject+"");
			document.frmNewslettersList.submit();
		}
	} else {
		alert("Please add email addresses in the Selected Recepients list to send the newsletter.");
	}
}

function AddNewEmailAddressInList(FormName,NewEmailAddress,ListName) { 
	var NewEmailAddressString = eval('document.'+FormName+"."+NewEmailAddress+".value")

	if(NewEmailAddressString!="") {
		if(isEmailValid(NewEmailAddressString)) {
			//Checking if selected value already exists in the list
			var ItemExistsInList = false
			for (var i=eval('document.'+FormName+'.'+ListName+'.options.length')-1; i>=0; i--) {
				if(eval('document.'+FormName+'.'+ListName+'.options['+i+'].value=='+FormName+'.'+NewEmailAddress+'.value')) {
					ItemExistsInList = true
				}
			}

			if(!ItemExistsInList==true) {
				//Item doesnt exist in list
				//eval('document.'+FormName+'.'+ListName+'.options[document.'+FormName+'.'+ListName+'.options.length]=new Option('+FormName+'.'+NewEmailAddress+'.value,FormName+'.'+NewEmailAddress+'.value'));
				eval('document.'+FormName+'.'+ListName+'.options[document.'+FormName+'.'+ListName+'.options.length]=new Option('+FormName+'.'+NewEmailAddress+'.value,'+FormName+'.'+NewEmailAddress+'.value)');
				DisplayListCount();
				alert("New email address successfully added in the selected recepients list.");
			} else {
				alert("The selected email address already exists in the list.");
			}
		} else {
			alert("Please enter a valid email address.");
		}
	} else {
		alert("Please enter a valid email address.");
	}
}

function DisplayListCount() {
	
		document.getElementById("SelectedUserCount").innerHTML = "<a class=SmallBlackText><b>Selected Recepients: (" + document.getElementById("frmNewslettersList").SelectedEmailAddresses.options.length + ")</b></a>";

}

function AddPagesFromList(FormName,List1,List2) { 
	//Checking if some value is selected
	List2 = "all"; 
	//alert('document.'+FormName+'.'+List2);
	if(!eval('document.'+FormName+'.'+List2+'.value')=="") {  
		//Checking if selected value already exists in the list
		var ItemExistsInList = false
		for (var i=eval('document.'+FormName+'.'+List1+'.options.length')-1; i>=0; i--) {
			if(eval('document.'+FormName+'.'+List1+'.options['+i+'].value==document.'+FormName+'.'+List2+'.value')) {
				ItemExistsInList = true
				//Removing added item from first list
				//	eval('document.'+FormName+'.'+List2+'.options[document.'+FormName+'.'+List2+'.selectedIndex]=null');
			}
		}

		if(!ItemExistsInList==true) {
			//Item doesnt exist in list
			
			for (var j=eval('document.'+FormName+'.'+List2+'.options.length')-1; j>=0; j--) {
				if(eval('document.'+FormName+'.'+List2+'.options['+j+'].value==document.'+FormName+'.'+List2+'.value')) {
					eval('document.'+FormName+'.'+List1+'.options[document.'+FormName+'.'+List1+'.options.length]=new Option(document.'+FormName+'.'+List2+'.options['+j+'].firstChild.nodeValue,document.'+FormName+'.'+List2+'.value)');
				}
			}
			//Removing added item from first list
			//eval('document.'+FormName+'.'+List2+'.options[document.'+FormName+'.'+List2+'.selectedIndex]=null');
		}
	}
	DisplayListCount();
}

function AddAllPagesToList(FormName,List1,List2) {
	List2 = "all";
	for (var j=eval('document.'+FormName+'.'+List2+'.options.length')-1; j>=0; j--) {
		eval('document.'+FormName+'.'+List2+'.options['+j+'].selected=true')
		//Checking if some value is selected
		if(!eval('document.'+FormName+'.'+List2+'.value')=="") {
			//Checking if selected value already exists in the list
			var ItemExistsInList = false
			for (var i=eval('document.'+FormName+'.'+List1+'.options.length')-1; i>=0; i--) {
				if(eval('document.'+FormName+'.'+List1+'.options['+i+'].value==document.'+FormName+'.'+List2+'.value')) {
					ItemExistsInList = true
					//Removing added item from first list
					//eval('document.'+FormName+'.'+List2+'.options[document.'+FormName+'.'+List2+'.selectedIndex]=null');
				}
			}

			if(!ItemExistsInList==true) {
				//Item doesnt exist in list
				eval('document.'+FormName+'.'+List1+'.options[document.'+FormName+'.'+List1+'.options.length]=new Option(document.'+FormName+'.'+List2+'.options['+j+'].firstChild.nodeValue,document.'+FormName+'.'+List2+'.value)');
				//Removing added item from first list
				//eval('document.'+FormName+'.'+List2+'.options[document.'+FormName+'.'+List2+'.selectedIndex]=null');
			}
		}
	}
	DisplayListCount();
}

function RemoveAllPagesFromList(FormName,List1,List2) {
	List2 = "all";
	for (var j=eval('document.'+FormName+'.'+List1+'.options.length')-1; j>=0; j--) {
		eval('document.'+FormName+'.'+List1+'.options['+j+'].selected=true')
		//Checking if some value is selected
		if(!eval('document.'+FormName+'.'+List1+'.value')=="") {
			//Checking if selected value already exists in the list
			var ItemExistsInList = false
			for (var i=eval('document.'+FormName+'.'+List2+'.options.length')-1; i>=0; i--) {
				if(eval('document.'+FormName+'.'+List2+'.options['+i+'].value==document.'+FormName+'.'+List1+'.value')) {
					ItemExistsInList = true
					//Removing added item from first list
					eval('document.'+FormName+'.'+List1+'.options[document.'+FormName+'.'+List1+'.selectedIndex]=null');
				}
			}

			if(!ItemExistsInList==true) {
				//Item doesnt exist in list
				eval('document.'+FormName+'.'+List2+'.options[document.'+FormName+'.'+List2+'.options.length]=new Option(document.'+FormName+'.'+List1+'.value,document.'+FormName+'.'+List1+'.value)');
				//Removing added item from first list
				eval('document.'+FormName+'.'+List1+'.options[document.'+FormName+'.'+List1+'.selectedIndex]=null');
			}
		}
	}
	DisplayListCount();
}

function RemovePagesFromList(FormName,List1,List2) {
	List2 = "all";
	//Checking if some value is selected
	if(!eval('document.'+FormName+'.'+List1+'.value')=="") {
		//Checking if selected value already exists in the list
		var ItemExistsInList = false
		for (var i=eval('document.'+FormName+'.'+List2+'.options.length')-1; i>=0; i--) {
			if(eval('document.'+FormName+'.'+List2+'.options['+i+'].value==document.'+FormName+'.'+List1+'.value')) {
				ItemExistsInList = true
				//Removing added item from first list
				eval('document.'+FormName+'.'+List1+'.options[document.'+FormName+'.'+List1+'.selectedIndex]=null');
			}
		}		
					
		if(!ItemExistsInList==true) {
			//Item doesnt exist in list
			eval('document.'+FormName+'.'+List2+'.options[document.'+FormName+'.'+List2+'.options.length]=new Option(document.'+FormName+'.'+List1+'.value,document.'+FormName+'.'+List1+'.value)');
			//Removing added item from first list
			eval('document.'+FormName+'.'+List1+'.options[document.'+FormName+'.'+List1+'.selectedIndex]=null');
		}
	}
	DisplayListCount();
}

function SelectAllItemsInList(FormName,ListName) {
	eval('document.'+FormName+'.SelectedEmail.value=""');
	//alert(eval('document.'+FormName+'.SelectedEmail.value'));
	for (var i=eval('document.'+FormName+'.'+ListName+'.options.length')-1; i>=0; i--) {
		if (eval('document.'+FormName+'.SelectedEmail.value==""')) {
			eval('document.'+FormName+'.SelectedEmail.value= document.'+FormName+'.SelectedEmail.value + document.'+FormName+'.'+ListName+'.options['+i+'].value');
		} else {
			eval('document.'+FormName+'.SelectedEmail.value= document.'+FormName+'.SelectedEmail.value + "," + document.'+FormName+'.'+ListName+'.options['+i+'].value');
		}
		eval('document.'+FormName+'.'+ListName+'.options['+i+'].selected=true')
	}	
	//alert(eval('document.'+FormName+'.SelectedEmail.value'));	
}

function DisplayListDetails(FormName,ListName) {
	document.getElementById("SelectedUserDetails").innerHTML = "<a class=SmallBlackText>" + eval('document.'+FormName+'.'+ListName+'.value') + "</a>";
	document.getElementById("frmNewslettersList").NewEmailAddress.value = eval('document.'+FormName+'.'+ListName+'.value');
	//document.getElementById("frmNewslettersList").NewEmailAddress.value = eval('document.'+FormName+'.'+ListName+'.value');
	DisplayListCount();
}

function DisplaySelectedList(FormName,ListName) {
	if (ListName == 'all') {
		all.style.display = '';
		male.style.display = 'none';
		female.style.display = 'none';
	}
	if (ListName == 'male') {
		all.style.display = 'none';
		male.style.display = '';
		female.style.display = 'none';
	}
	if (ListName == 'female') {
		all.style.display = 'none';
		male.style.display = 'none';
		female.style.display = '';
	}
	DisplayListCount();
}
//########## End Newsletter Send Script ###################################################################
//#########################################################################################################


//########## Shadowbox Script ###################################################################
//#########################################################################################################


Shadowbox.init({
    // a darker overlay looks better on this particular site
    overlayOpacity: 0.8
    // setupDemos is defined in assets/demo.js
}, setupDemos);

function setupDemos() {

    Shadowbox.setup("a.mustang-gallery", {
        gallery:        "mustang",
        continuous:     true,
        counterType:    "skip"
    });
}


//########## End Shadowbox Script ###################################################################
//#########################################################################################################



