
function popUpSignInDiv(top,left){
	document.getElementById("signIn_wrapper").style.display="block";
	centerPopup('signIn_wrapper',top,left);	
}

function grayOut(vis, options) {
	  // Pass true to gray out screen, false to ungray
	  // options are optional.  This is a JSON object with the following (optional) properties
	  // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
	  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
	  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
	  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
	  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
	  // in any order.  Pass only the properties you need to set.
	  var options = options || {}; 
	  var zindex = options.zindex || 50;
	  var opacity = options.opacity || 70;
	  var opaque = (opacity / 100);
	  var bgcolor = options.bgcolor || '#000000';
	  var dark=document.getElementById('darkenScreenObject');
	  if (!dark) {
	    // The dark layer doesn't exist, it's never been created.  So we'll
	    // create it here and apply some basic styles.
	    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
	    var tbody = document.getElementsByTagName("body")[0];
	    var tnode = document.createElement('div');           // Create the layer.
	        tnode.style.position='absolute';                 // Position absolutely
	        tnode.style.top='0px';                           // In the top
	        tnode.style.left='0px';                          // Left corner of the page
	        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
	        tnode.style.display='none';                      // Start out Hidden
	        tnode.id='darkenScreenObject';                   // Name it so we can find it later
	    tbody.appendChild(tnode);                            // Add it to the web page
	    dark=document.getElementById('darkenScreenObject');  // Get the object.
	  }
	  if (vis) {
	    // Calculate the page width and height 
	    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
	        var pageWidth = document.body.scrollWidth+'px';
	        var pageHeight = document.body.scrollHeight+'px';
	    } else if( document.body.offsetWidth ) {
	      var pageWidth = document.body.offsetWidth+'px';
	      var pageHeight = document.body.offsetHeight+'px';
	    } else {
	       var pageWidth='100%';
	       var pageHeight='100%';
	    }   
	    //set the shader to cover the entire page and make it visible.
	    dark.style.opacity=opaque;                      
	    dark.style.MozOpacity=opaque;                   
	    dark.style.filter='alpha(opacity='+opacity+')'; 
	    dark.style.zIndex=zindex;        
	    dark.style.backgroundColor=bgcolor;  
	    dark.style.width= pageWidth;
	    dark.style.height= pageHeight;
	    dark.style.display='block';                          
	  } else {
	     dark.style.display='none';
	  }
	}

	function closeSignInDiv(){

		document.getElementById("signIn_wrapper").style.display="none";
			grayOut(false);
	}

	function uncheckAll(field)
	{
		for (i = 0; i < field.length; i++)
		field[i].checked = false ;
	}

	function popUpGoToNextStepDiv(){
		
		document.getElementById("goToNextStep_wrapper").style.display="block";
	}
	
	function popUpGetSeenDiv(){
		document.getElementById("getSeen_wrapper").style.display="block";
	}
	
	function closeGetSeenDiv(){

		document.getElementById("getSeen_wrapper").style.display="none";
			grayOut(false);
	}
	
function centerPopup(divID){
		
		alert("center" +divID);
		//request data for centering
		var windowWidth =  $(window.parent.document.body).width();
		if (navigator.userAgent.indexOf("Firefox")!=-1)
	  	 var windowHeight =  $(window.parent.document.body).height() ;
		else
		   var windowHeight =  $(window.parent.document.body).height(); //for IE
		var popupHeight = 587; //205
		var popupWidth = $("#contentPage").width();
		//centering
		 $("#" +divID, parent.document.body).css({
			"position": "absolute",
			"top": windowHeight/2-popupHeight/2-100,
			"left": windowWidth/2-popupWidth/2-300
		});
			
	}



function centerGetSeen(divID){
	
	
	//request data for centering
	var windowWidth =  $(window.parent.document.body).width();
	if (navigator.userAgent.indexOf("Firefox")!=-1)
  	 var windowHeight =  $(window.parent.document.body).height() ;
	else
	   var windowHeight =  $(window.parent.document.body).height(); //for IE
	var popupHeight = 182; 
	var popupWidth = 442;
	//centering
	 $("#" +divID, parent.document.body).css({
		"position": "absolute",
		"top": 430,
		"left": 200
	});
		
}

function validateEmpty(fld,name) {
    var error = "";
    if (fld.value == "") {
        //.style.background = 'White'; 
        error = "Please enter \t" + name +"\n";
    } else {
        //fld.style.background = 'White';
    }
    return error;  
}

function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}

/* Validate Zip code
 * Format 5 Digits +4 zip code
 * @param field
 * @param type
 * @return
 */
function validateZIP(field,type) {
	var valid = "0123456789-";
	var hyphencount = 0;
	var error = "";
	if (field.length!=5 && field.length!=10) {
	
		 error = "Please enter your "+type+ "5 digit or 5 digit+4 zip code.";	
	}
	for (var i=0; i < field.length; i++) {
	temp = "" + field.substring(i, i+1);
	if (temp == "-") hyphencount++;
	if (valid.indexOf(temp) == "-1") {
		error = "Invalid characters in your "+type+" zip code.  Please try again.";	
	}
	if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
		error = "The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.";
	   }
	}	
	return error;
}
/*
 * This method is used to validate the phone no
 * @param fld
 * @return
 */
function validatePhone(fld,type) {
	   var error = "";
	   var stripped = fld.value.replace(/[\(\)\.\ ]/g, '');
	   if (fld.value == "") {
	        error = "Please enter "+type+"Phone Number.\n";
	        //fld.style.background = 'Yellow';
	    } else if (isNaN(parseInt(stripped)) || isNaN(fld.value) ) {
	        error = "The "+type+"phone number contains illegal characters.\n";
	       // fld.style.background = 'Yellow';
	    } else if (stripped.length <10) {
	        error = "The "+type+"phone number is the wrong length. Make sure you included an area code.\n";
	       // fld.style.background = 'Yellow';
	    }
	  
	    return error;
}

//Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

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 DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	//alert(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)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		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 popUpEditPhotoDiv(photoId,albumid,fav){		
	 //grayOut(true,{'opacity':'45'});	
	
	 if(fav == 1)
		 document.getElementById("editPhotofavPopup").style.display="block";
	 else
		 document.getElementById("editPhotoPopup").style.display="block";
	 	 document.getElementById('iframePhoto').src ="../albums/editphotopopup.cfm?photoid="+photoId+"&albumid="+albumid;
	 	 if(fav == 0)
	 		 centerPopup('editPhotoPopup',100,80);	//top and left before was 275,130
	 	 else
	 		centerPopup('editPhotofavPopup',100,80);	//top and left before was 275,130
}

function popUpFavoriteDiv(albumid,photoId){	
	 document.getElementById("popup").style.display="block";
	 centerPopup('popup',50+$(window).scrollTop(),250);	
	 //centerFavoritePopup('popup');
	 document.getElementById("albumid").value=albumid;
	 document.getElementById("photoid").value=photoId;
	// grayOut(true,{'opacity':'25'});
	//return false;
}
function closePopUpFavoriteDiv(){
	//alert("coming close.....");
	 document.getElementById("popup").style.display="none";	 
	 document.getElementById('editToFavorite').style.display ="block";
	 document.getElementById('newFavorite').style.display ="none";
	 document.getElementById('linkcreate').style.display ="block";
	 document.getElementById('favoriteType').value ="update";
	 grayOut(false);
}

function centerFavoritePopup(divID){	
	
	//request data for centering
	var windowWidth =  $(window.parent.document.body).width();
	if (navigator.userAgent.indexOf("Firefox")!=-1)
  	 var windowHeight =  $(window.parent.document.body).height() ;
	else
	   var windowHeight =  $(window.parent.document.body).height(); //for IE
	var popupHeight = 150; 
	var popupWidth = 272;
	//centering
	 $("#" +divID, parent.document.body).css({
		"position": "absolute",
		"top": 150,
		"left": 300
	});
		
}

function centerPopup(divID,top,left){	
	
	//request data for centering
	var windowWidth =  $(window.parent.document.body).width();
	if (navigator.userAgent.indexOf("Firefox")!=-1)
  	 var windowHeight =  $(window.parent.document.body).height() ;
	else
	   var windowHeight =  $(window.parent.document.body).height(); //for IE
	var popupHeight = 150; 
	var popupWidth = 272;
	//centering
	 $("#" +divID, parent.document.body).css({
		"position": "absolute",
		"top": top,
		"left": left
	});
		
}
/* Switch the breadcrumb based on tab selection */
function breadcrumSwitch(id){  	
	if(id==2){
		//alert("check for 2");
		$('#breadcrumbHeader').attr('class', 'text-profile');	
		document.getElementById("tab2").style.display="block";
		document.getElementById("tab1").style.display="none";
		document.getElementById("tab3").style.display="none";
		document.getElementById("tab4").style.display="none";
	}
	else if(id==3){
		//alert("check for 3");		
		$('#breadcrumbHeader').attr('class', 'text-party-my-albums');
		document.getElementById("tab3").style.display="block";
		document.getElementById("tab1").style.display="none";
		document.getElementById("tab2").style.display="none";
		document.getElementById("tab4").style.display="none";
		
	}
	else if(id==4){
		//alert("check for 4");
		$('#breadcrumbHeader').attr('class', 'clipboard-text');
		document.getElementById("tab4").style.display="block";
		document.getElementById("tab1").style.display="none";
		document.getElementById("tab2").style.display="none";
		document.getElementById("tab3").style.display="none";
		
		
	}
	else
	{
		//alert("check for 1");
	$('#breadcrumbHeader').attr('class', 'text-party');
	document.getElementById("tab1").style.display="block";
	document.getElementById("tab2").style.display="none";
	document.getElementById("tab3").style.display="none";
	document.getElementById("tab4").style.display="none";
		
	}


 }

function prosbreadcrumSwitch(id)
{
	if(id==2){
		
		$('#breadcrumbHeader').attr('class', 'text-companyprofile');	
		$('#breadcrumbHeader').attr('style', 'margin-top:0px');	
		document.getElementById("tab2").style.display="block";
		document.getElementById("tab1").style.display="none";
		document.getElementById("tab3").style.display="none";
		document.getElementById("tab4").style.display="none";
	}
}
/* edit albums switch tabs */
function switcheditAlbumTab(id){ 
	if(id==1){
		document.getElementById("tab-1").style.display="block";
		document.getElementById("tab-2").style.display="none";
		document.getElementById("tab-3").style.display="none";
		document.getElementById("tab-4").style.display="none";
		document.getElementById("tab-5").style.display="none";
	}
	else if(id==2){
		document.getElementById("tab-1").style.display="none";
		document.getElementById("tab-2").style.display="block";
		document.getElementById("tab-3").style.display="none";
		document.getElementById("tab-4").style.display="none";
		document.getElementById("tab-5").style.display="none";
	}
	else if(id==3){
		document.getElementById("tab-1").style.display="none";
		document.getElementById("tab-2").style.display="none";
		document.getElementById("tab-3").style.display="block";
		document.getElementById("tab-4").style.display="none";
		document.getElementById("tab-5").style.display="none";
	}
	else if(id==4){
		document.getElementById("tab-1").style.display="none";
		document.getElementById("tab-2").style.display="none";
		document.getElementById("tab-3").style.display="none";
		document.getElementById("tab-4").style.display="block";
		document.getElementById("tab-5").style.display="none";
	}
	else
	{
		document.getElementById("tab-1").style.display="none";
		document.getElementById("tab-2").style.display="none";
		document.getElementById("tab-3").style.display="none";
		document.getElementById("tab-4").style.display="none";
		document.getElementById("tab-5").style.display="block";
	}

 }



/* This Popup if on the view album page when Save Photo is clicked */
function PopFavDiv(albumid,photoId){	
	 document.getElementById("popup").style.display="block";
	 centerPopup('popup',700,260);	
	 document.getElementById("albumFavId").value=albumid;
	 document.getElementById("photoFavId").value=photoId;
	 document.getElementById('editToFavorite').style.display ="block";
	 document.getElementById('newFavorite').style.display ="none";
	
}
function closeFavDiv(){
	 document.getElementById("popup").style.display="none";	 
	 document.getElementById('editToFavorite').style.display ="block";
	 document.getElementById('newFavorite').style.display ="none";
	 document.getElementById('linkcreate').style.display ="block";
	 document.getElementById('favoriteType').value ="update";

}

 
/* validation for clearStatus function in Status text across the site */
function clearStatus(id){ 
	//alert(id);
	//alert("common fun");
  	document.getElementById("action").value ="2";
  	document.getElementById("statusid").value =id;	
	document.statusForm.submit();
  }

function centerZoomPopup(divID,top,left,popHeight,popWidth){	
	
	
	var windowWidth =  981;
	var popupWidth = popWidth;
	//centering
	 $("#" +divID, parent.document.body).css({
		"position": "absolute",
		"top": 300,
		"left": (windowWidth-popupWidth)/2
	});
		
}
function zoomPhoto(src,width,height)
{
	document.getElementById("zoomDiv").style.display ="block";
	document.getElementById("zoomDiv").width=width;
	document.getElementById("zoomDiv").height=height;
	document.getElementById("zoomSrc").src=src;
	//gray out
	grayOut(true,{'opacity':'45'});
	//center popup
	//centerPopup('zoomDiv',300,22);
	centerZoomPopup('zoomDiv',300,22,height,width);
}

function closeZoomDiv()
{
	document.getElementById("zoomDiv").style.display ="none";
	document.getElementById("zoomSrc").src="/images/pixel.gif";
	grayOut(false);
}

function popUpBulkEditDiv(albumid,tab,set,fav){	
	 // alert("batchedit"+albumid +"tab"+tab+"set"+set);	
	 //grayOut(true,{'opacity':'45'});
	 if(fav == 0)
		 document.getElementById("batcheditPopup").style.display="block";
	 else
		 document.getElementById("batcheditFavPopup").style.display="block";
	 document.getElementById('iframebatchEdit').src ="../albums/batcheditpopup.cfm?albumid="+albumid+"&tab="+tab+"&set="+set+"&fav="+fav;
	// centerPopup('batcheditPopup',120,120);	//top and left before was 275,130	 
}

function popUpBatchEditDiv(type,albumid,tab,set,fav){	
	// alert("batchedit"+albumid +"tab"+tab+"set"+set);	
	//grayOut(true,{'opacity':'45'});
	if(fav == 0) {
		document.getElementById("batcheditPopup").style.display="block";
	} else {
		document.getElementById("batcheditFavPopup").style.display="block";
	}
	document.getElementById('iframebatchEdit').src ="../albums/"+type+".cfm?albumid="+albumid +"&tab="+tab+"&set="+set+"&fav="+fav;
	// centerPopup('batcheditPopup',120,120);	//top and left before was 275,130	 
}

function switchDashBoard(id)
{
	if(id == 3)
	   location.href="/index.cfm?page=accounts/dashboard&tab=3";	
	else
		location.href="/index.cfm?page=accounts/dashboard&tab=2";	
}

/* display the popup for not logged in user */
function popUpMessage(top,left){	
	 document.getElementById("message_wrapper").style.display="block";
	 centerPopup('message_wrapper',top,left);	
	
}
/* close the pop up */
function closeMsgDiv(){	
	 document.getElementById("message_wrapper").style.display="none";
}

function closeMsgPopup(){
	document.getElementById("msgPopup").style.display="none";
	
	}

/* logic to count how many times an album is viewed */
function InvokeMostViewed(albumId)
{
	//alert("most viewed" + albumId);
    window.location.href="/index.cfm?page=albums/most_viewed&albumId="+albumId;


}

function InvokeMostViewedSearch(albumId,categoryId)
{
	//alert("most viewed" + albumId + " "+ categoryId);
    window.location.href="/index.cfm?page=albums/most_viewed&albumId="+albumId+"&categoryid="+categoryId;

}

function validateEmail(fld) {
	var error="";
    var tfld = trim(fld.value);                       
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
    if (fld.value == "") {
     //   fld.style.background = 'Yellow';
        error = "Please enter Email Address \n";
    } else if (!emailFilter.test(tfld)) {
    	//fld.style.background = 'Yellow';
        error = "Please enter a valid email address.\n";
    } else if (fld.value.match(illegalChars)) {
        //fld.style.background = 'Yellow';    	
        error = "The email address contains illegal characters.\n";
    } else {
    	
        //fld.style.background = 'White';
    }
    
    return error;
}

function showScreenshot()
{
	document.getElementById("uploadScreenshot").style.display="block";
	centerPopup('uploadScreenshot',200,80);
}

function closeScreenshot()
{
	document.getElementById("uploadScreenshot").style.display="none";
	
}

function showCreateScreenshot()
{
	document.getElementById("uploadCreateScreenshot").style.display="block";
	centerPopup('uploadCreateScreenshot',110,80);
}

function closeCreateScreenshot()
{
	document.getElementById("uploadCreateScreenshot").style.display="none";
	
}

function createNewsLetter() {
	var reason = "";
	emailId = document.getElementById('emailAddress').value;
	if (emailId == '') {
		alert("Please enter the email address to sign up for the newsletter.")
		return false;
	}
	else {
		reason += validateEmail(document.getElementById('emailAddress'));
		if (reason != "") {
    		alert( reason);
    			return false;
  		}
	}
	
	var privacy_url = "../templates/newsletter_action.cfm?emailid="+emailId;	
	jQuery.ajax({
		url:privacy_url,
		type:"get",
		success:function(msg){
			if (trim(msg) == 'success') {
			alert("You have successfully signed up for our newsletter");				
				/*
				centerPopup('message_wrapper', 510, 260);
				document.getElementById('message_wrapper').style.display = "block";
				message = "<b>You have successfully signed up for our newsletter.</b> ";
				document.getElementById('messageText').innerHTML = message;
				*/
			}
			else {
			alert("You have already signed up for our newsletter.");
				/*
				centerPopup('message_wrapper', 510, 260);
				document.getElementById('message_wrapper').style.display = "block";
				message = "<b>You have already signed up for our newsletter.</b> ";
				document.getElementById('messageText').innerHTML = message;
				*/
			}
			initPlugins();
		},
		error:function(){
			alert("AJAX Error!");
		}
	});
}

function trim(str) {
	return str.replace(/^\s+|\s+$/g,"");
}

function forgotPassword() {
	var reason = "";
	var email = "";
	email = document.getElementById('forgotemail').value;
	if (email == '') {
		alert("Please enter your email address and we will send you a password reminder email.")
		return false;
	}
	else {
		reason += validateEmail(document.getElementById('forgotemail'));
		if (reason != "") {
    		alert( reason);
    			return false;
  		}
	}
	
	var reminder_url = "/accounts/accounts_forgot_password.cfm?email="+email;	
	jQuery.ajax({
		url:reminder_url,
		type:"get",
		success:function(msg){
			if (trim(msg) == 'success') {				
				alert('An email reminder has been sent to you email address.');
				 document.getElementById('reminderBox').style.display = "none";
			}
			else {
				alert('Email not found.')
			}
			initPlugins();
		},
		error:function(){
			//alert("AJAX Error!");
		}
	});
}
function closeProsPopup(id){
		
	 document.getElementById(id).style.display="none";
	 grayOut(false);
}

function numbersonly(e, decimal) {
	var key;
	var keychar;

	if (window.event) {
	   key = window.event.keyCode;
	}
	else if (e) {
	   key = e.which;
	}
	else {
	   return true;
	}
	keychar = String.fromCharCode(key);

	if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) ) {
	   return true;
	}
	else if ((("0123456789").indexOf(keychar) > -1)) {
	   return true;
	}
	else if (decimal && (keychar == ".")) {	
	  return true;
	}
	else
	   return false;
}

function isValidCreditCardType(type) {	
   if (type == "4"){ // Visa: length 16, prefix 4, dashes optional.	      
      var isValid = /^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "5") {
      // Mastercard: length 16, prefix 51-55, dashes optional.
      var isValid = /^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$/;	   		
   } else if (type == "6") {
      // Discover: length 16, prefix 6011, dashes optional.
      var isValid = /^6011-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "3"){
	    // American Express: length 15, prefix 34 or 37.
      var isValid = /^3[4,7]\d{13}$/;
   } else if (type == "Diners") {
      // Diners: length 14, prefix 30, 36, or 38.
      var isValid = /^3[0,6,8]\d{12}$/;
   }
   return isValid;
}
/*
 * returns the array number of the selected radio button or -1 if no button is selected
 * @param buttonGroup
 * @return
 */
function getSelectedRadio(buttonGroup) {	   
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function getSelectedCheckbox(buttonGroup) {
   // Go through all the check boxes. return an array of all the ones
   // that are selected (their position numbers). if no boxes were checked,
   // returned array will be empty (length will be zero)
   var retArr = new Array();
   var lastElement = 0;
   if (buttonGroup[0]) { // if the button group is an array (one check box is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            retArr.length = lastElement;
            retArr[lastElement] = i;
            lastElement++;
         }
      }
   } else { // There is only one check box (it's not an array)
      if (buttonGroup.checked) { // if the one check box is checked
         retArr.length = lastElement;
         retArr[lastElement] = 0; // return zero as the only array value
      }
   }
   	return retArr;
} // Ends the "getSelectedCheckbox" function
/*
 * Copies MasterFields value's to CopiedFields if "Same as Company address" box is checked
 * @param checkedValue
 * @param CopiedFields
 * @param MasterFields
 * @return
 */
function CompanyToBillToSame(checkedValue, CopiedFields, MasterFields){	
	CopiedFieldsNames = CopiedFields.split(",");
	MasterFieldsNames = MasterFields.split(",");
	//loop over all the fields and copy data over
	for (i = 0; i < CopiedFieldsNames.length; ++i) {
		if (checkedValue) {				
			if (CopiedFieldsNames[i] == "bt_state") {				
				for (n = 0; n < document.getElementById("bt_state").options.length; n++) {
					if (document.getElementById("company_state").value.toLowerCase() == document.getElementById("bt_state")[n].value.toLowerCase()) {
						//and select the option
						document.getElementById("bt_state").selectedIndex = n;
						break;
					}
				}
			}
			else 
				if (CopiedFieldsNames[i] == "bt_country") {						
					for (n = 0; n < document.getElementById("bt_country").options.length; n++) {
						if (document.getElementById("company_country").value.toLowerCase() == document.getElementById("bt_country")[n].value.toLowerCase()) {
							//and select the option
							document.getElementById("bt_country").selectedIndex = n;
							break;
						}
					}
				}
				else {					
					//alert("others" + CopiedFieldsNames[i]);
					document.getElementById(CopiedFieldsNames[i]).value = document.getElementById(MasterFieldsNames[i]).value;
				}
		}			
		else {		 
			document.getElementById(CopiedFieldsNames[i]).value = "";
		}
	}// end of for
}	
/*
 * used for display the report popup.
 * @param photoId
 * @param albumid
 * @param commentId
 * @param replyId
 * @param reportFrom - 1 is for view album 0 is for member comments *   
 * @param page
 * @return
 */
function popUpReportDiv(photoId,albumid,commentId,replyId,reportFrom,page){	
	document.getElementById("report_violation").style.display="block";
	 document.getElementById('iframeReport').src ="../albums/report_violation.cfm?photoId="+photoId+"&albumid="+albumid+"&commentId="+commentId+"&replyId="+replyId+"&reportFrom="+reportFrom;
	 if(page == 'single_photo')
		 centerPopup('report_violation',$(window).scrollTop()+150,$(window).scrollLeft()+500);
	 else if (page == 'view_album') 
		 centerPopup('report_violation',$(window).scrollTop()+150,$(window).scrollLeft()+100);	 
	 else if (page == 'pros_membercomments')
		 centerPopup('report_violation',$(window).scrollTop()+120,$(window).scrollLeft()+400);	
	 else
	 	centerPopup('report_violation',$(window).scrollTop()+120, $(window).scrollLeft()+750);
}
function validateReportForm()
{
	var e = document.getElementById('reason');
	var dropdownValue = e.options[e.selectedIndex].value;	
	if (dropdownValue == "") {
		alert("Please select reason ");
		return false;
	}	
}
function closeReportPopup(id){	
	 parent.document.getElementById(id).style.display="none";
	 //parent.document.getElementById('iframeReport').src="";
	 //grayOut(false);
	  parent.document.getElementById('lightbox-overlay').style.display='none';
}

function showAllStatusComments(id){
	
	document.getElementById("showAll_"+id).style.display="block";
	document.getElementById("showTop_" + id).style.display="none";
}

/* delete the status text and associated records */
function deleteStatus(id){ 
  	document.getElementById("action").value ="3";
  	document.getElementById("statusid").value =id;	
	document.statusForm.submit();
  }
  
/** forgot password functionality for dashboard page  **/
function forgotPassword_dashboard() {
	var reason = "";
	var email = "";
	//email = document.getElementById('forgotemail').value;
	email = $('#forgotemail_dashboard').val();
	if (email == '') {
		alert("Please enter your email address and we will send you a password reminder email.")
		return false;
	}
	else {
		reason += validateEmail(document.getElementById('forgotemail_dashboard'));
		if (reason != "") {
    		alert( reason);
    			return false;
  		}
	}	
	var reminder_url = "/accounts/accounts_forgot_password.cfm?email="+email;	
	jQuery.ajax({
		url:reminder_url,
		type:"get",
		success:function(msg){
			if (trim(msg) == 'success') {				
				alert('A password reminder has been sent to your email address.');
				 document.getElementById('reminderBox_dashboard').style.display = "none";
			}
			else {
				alert('Email not found.')
			}
			initPlugins();
		},
		error:function(){
			//alert("AJAX Error!");
		}
	});
}

