jQuery(function(){
	//inithumbsGallery();
	initPlugins();
	initValidation();
	initPopups();
	fadeGall();
//	hideFormText(); commented out onfocus and onblur events for input type text,textarea
	viewSwitcher();
	selectAjaxSwicther();
	initBrowserDetect();
	initOpenCloseForms();
	ieHover('ul.ul-class > li, div.div-class, span, #box, #nav > li, .registration-box .row', 'hover');
});
function inithumbsGallery(photoInd){
	jQuery('.gallery-area').each(function(){
		var set = jQuery(this);
		var _btnThumbs = set.find('a.btn-thumbnail');
		var _btnPrev = set.find('a.link-prev-nav');
		var _btnNext = set.find('a.link-next-nav');
		
		var _listPrev = set.find('a.link-prev-small');
		var _listNext = set.find('a.link-next-small');
		
		var _imgNext = set.find('a.img-next');
		
		var _numImg = set.find('.link-pagenator');
		var _gallery = set.find('.gallery-large');
		var _thumbsHold = set.find('.gallery-holder').hide();
		var _pauseButton = set.find('.link-pause-nav');
		var _flag = true;
		var _step = false;
		var _sumWidth = 0;
		var _ind = 0;
		var _prev = _ind;
		var _currentStep = 1;
		var _offset, _timer, _top, _left;
		var _autoSlide = false;//disabled the auto rotation for now true before
		var _duration = 200;
		//var _swichTime = 2000;//commented for now
		
		_btnThumbs.bind('click', function(){
			if(_flag){
				_thumbsHold.show();
				_btnPrev.hide();
				_btnNext.hide();
				//_numImg.hide();
				_gallery.hide();
				_flag = false;
				_btnThumbs.parent().addClass('active');
				stopAuto();
			}
			else {
				_thumbsHold.hide();
				_btnPrev.show();
				_btnNext.show();
				//_numImg.show();
				_gallery.show();
				_flag = true;
				_btnThumbs.parent().removeClass('active');
				_autoSlide = true;
				autoSlide();
			}
			return false;
		});
		var _list = set.find('.thumbnails .mask-list > ul').empty();
		var _listThumbs = _thumbsHold.find('>ul').empty();
		var _item = _gallery.find('> ul > li').css({ position: 'absolute', top: 0, left: 0 });
		_item.click(function(){ return false; });

		_item.find('>a').each(function(i, el){
			_left = parseInt((jQuery(this).parent().width()-jQuery(this).find('img').width())/2);
			_top = parseInt((jQuery(this).parent().height()-jQuery(this).find('img').height())/2);
			
			if(jQuery.browser.msie){
				jQuery(this).css({
					marginTop: _top-2,
					marginLeft: _left-2
				});
			}
			else {
				jQuery(this).css({
					marginTop: _top,
					marginLeft: _left
				});
			}
			
			
			
			jQuery(this).attr('meta', jQuery(this).attr('title')).removeAttr('title');
			//_list.append('<li><a href="#" onclick=switchCommentsTab("'+jQuery(this).attr('id')+'");><img src="' + jQuery(this).attr('href') + '" alt="swicher image" width="50" height="50" /></a></li>');
			_list.append('<li><a href="#"><img src="' + jQuery(this).attr('name') + '" alt="swicher image" width="50" height="50" /></a></li>');
			_listThumbs.append('<li><a href="#" onclick=switchBtnThumbnail();switchCommentsTab("'+jQuery(this).attr('id')+'");><img src="' + jQuery(this).attr('meta') + '" alt="thumbs image" width="110" height="101" /></a></li>');
			_sumWidth += _list.children().eq(i).outerWidth(true);
			document.getElementById("view-album-gallery-large").style.opacity=1;
			_btnPrev.show();
			_btnNext.show();
			_numImg.show();
			
			var t=setTimeout("showAd()",3000);
			
		});
	
		
		_list.children().each(function(i, el){
			jQuery(this).bind('click', function(){
				_prev = _ind;
				_ind = i;
				swichSlide();
				return false;
			})
		});

		_listThumbs.children().each(function(i, el){
			jQuery(this).bind('click', function(){
				_prev = _ind;
				_ind = i;
				_thumbsHold.hide();
				_gallery.show()	
				swichPhotoSlide(_ind);							
				_flag = true;
				_autoSlide = true;
				_btnPrev.show();
				_btnNext.show();
				//autoSlide();				
				//testCurrent(_ind);
				//swichSlide();				
				return false;
			})
		});

		var thumbsLength = _listThumbs.children().length > 10 ? true : false;
		
		function swichSlide(){
			//TSS added to switch titles and comments on move of the slideshow
			//global vars located in view_album template
			_photoAlbumString=jsPhotoIdArray[_ind] + '_' + jsAlbumId;
			switchCommentsTab(_photoAlbumString);
			
			//alert(jsPhotoTitlesArray[_ind]);
			if (document.getElementById('photoTitleParagraph') != null) {
				document.getElementById('photoTitleParagraph').innerHTML ="<p>"+ jsPhotoTitlesArray[_ind] + "</p>";
			}
			
			//alert("swichSlide");
			_list.children().removeClass('active');
			_list.children().eq(_ind).addClass('active');
			if(_ind != _prev){
				_item.eq(_prev).fadeOut(_duration);
				_item.eq(_ind).fadeIn(_duration);
				// _gallery.find('> ul').animate({ height: _item.eq(_ind).height() }, { queue: false, duration: 250 });
				_numImg.text('IMAGES ' + (_ind+1) + ' of ' + _list.children().length);
			}
			else {
				_item.hide().eq(_ind).show();
				// _gallery.find('> ul').css({ width:'100%', height: _item.eq(_ind).height() });
				_numImg.text('IMAGES ' + (_ind+1) + ' of ' + _list.children().length);
			}
			autoSlide();
			
			
			
		}
		function recalcOffsets(){
			if(_step) {
				_stepWidth = _list.children().eq(_currentStep).outerWidth(true)*_step;
				_stepCount = Math.ceil((_sumWidth-_list.parent().width())/_stepWidth)+1;
				_offset = -_stepWidth*_currentStep;
				if(_offset < _list.parent().width()-_sumWidth) _offset = _list.parent().width()-_sumWidth;
			} else {
				_stepWidth = _list.parent().width();
				_stepCount = Math.ceil(_sumWidth/_stepWidth);
				_offset = -_stepWidth*_currentStep;
				if(_offset < _stepWidth-_sumWidth) _offset = _stepWidth-_sumWidth;
			}
		}
		if(_btnPrev.length) {
			_btnPrev.bind('click',function(){
				_prev = _ind;
				if(_ind > 0) _ind--;
				else _ind = _list.children().length-1;
				testCurrent(_ind);
				swichSlide();
				return false;
			});
		}
		if(_btnNext.length) {
			_btnNext.bind('click',function(){
				_prev = _ind;
				if(_ind < _list.children().length-1) _ind++;
				else _ind = 0;
				testCurrent(_ind);
				swichSlide();
				return false;
			});
		}
		/* for image */
		if(_imgNext.length) {
			_imgNext.bind('click',function(){
				_prev = _ind;
				if(_ind < _list.children().length-1) _ind++;
				else _ind = 0;
				testCurrent(_ind);
				swichSlide();
				swichPhotoSlide(_ind);
				return false;
			});
		}

		if(_listPrev.length) {
			_listPrev.bind('click',function(){
				prevSlide();
				return false;
			});
		}
		if(_listNext.length) {
			_listNext.bind('click',function(){
				nextSlide();
				return false;
			});
		}
		
		
		function testCurrent(i){
			var _slideEl = 10;
			var _slide = 0;
			var _curSlideSet = Math.ceil( (i + 1) / _slideEl) ;
			_slide = _slideEl * (_curSlideSet - 1);
			if(_slide + _slideEl < _list.children().length) _slide = _slide;
			else _slide = _list.children().length - _slideEl;
			if(thumbsLength && _slide + _slideEl != _slideEl){_list.animate({ marginLeft: _offset },{ duration: 250, queue:false });}
			if(thumbsLength && _ind == 0){_list.animate({ marginLeft: 0 },{ duration: 250, queue:false });}
		}

		function prevSlide() {
			recalcOffsets();
			if(_currentStep > 0) _currentStep--;
			else _currentStep = _stepCount-1;
			if(thumbsLength){_list.animate({ marginLeft: _offset },{ duration: 250, queue:false });}
		}
		function nextSlide() {
			recalcOffsets();
			if(_currentStep < _stepCount-1) _currentStep++;
			else _currentStep = 0;
			if(thumbsLength){_list.animate({ marginLeft: _offset },{ duration: 250, queue:false });}
		}

		function stopAuto(){
			if(_timer) clearTimeout(_timer);
			_autoSlide = false;
		}
		_gallery.hover(stopAuto, function(){
			_autoSlide = true;
			autoSlide();
		});
		
		_pause = false;
		_pauseButton.click(function(){
			_pause = !_pause;
			if(_pause){
				_pauseButton.addClass('paused');
			}else{
				_pauseButton.removeClass('paused');
			}
			autoSlide();
			return false;
		});
		
		function autoSlide(){
			/*if(_autoSlide){
				if(_timer) clearTimeout(_timer);
				_timer = setTimeout(function(){
					if(!_pause){
						_prev = _ind;
						if(_ind < _list.children().length-1) _ind++;
						else _ind = 0;
						testCurrent(_ind);
						swichSlide();
					}
				}, _swichTime);
			}*/
		}
		
		function swichPhotoSlide(photoInd){
			
			_ind = photoInd;
			_prev = _ind;
			_list.children().removeClass('active');
			_list.children().eq(_ind).addClass('active');
			if(_ind != _prev){
				//alert("if con"+_ind);
				//alert("prev"+_prev);
				_item.eq(_prev).fadeOut(_duration);
				_item.eq(_ind).fadeIn(_duration);
				// _gallery.find('> ul').animate({ height: _item.eq(_ind).height() }, { queue: false, duration: 250 });
				_numImg.text('IMAGES ' + (_ind+1) + ' of ' + _list.children().length);
			}
			else {
				
				//alert("else swichSlide"+_ind);
				_item.hide().eq(_ind).show();
				// _gallery.find('> ul').css({ width:'100%', height: _item.eq(_ind).height() });
				_numImg.text('IMAGES ' + (_ind+1) + ' of ' + _list.children().length);
			}
			//autoSlide();
			/*if(_ind > 9)
				
				 nextSlide(); */
			if(_ind > 9 &&  _ind <= 19){
				_currentStep =1;
				 nextSlide();
			}
			
			if(_ind > 19 &&  _ind <= 29){
				_currentStep =2;
				 nextSlide();
			}
				
			if(_ind > 29 &&  _ind <= 39){
				_currentStep =3;
				 nextSlide();
			}
				
			if(_ind > 39 &&  _ind <= 49)	{
				_currentStep =4;
				 nextSlide();
			}
				
		}

		//recalcOffsets();
		//swichSlide();
		swichPhotoSlide(photoInd);
		//switchTopBanner();
	})
}


function initPlugins(){
	if(jQuery('#wysiwyg').length){
		jQuery('#wysiwyg').wysiwyg({
			controls: {
				strikeThrough:{visible:false},
					separator00:{visible:false},
					justifyLeft:{visible:false},
					justifyCenter:{visible:false},
					justifyRight:{visible:false},
					justifyFull:{visible:false},
					separator01:{visible:true},
					indent:{visible:false},
					outdent:{visible:false},
					separator02:{visible:false},
					subscript:{visible:false},
					superscript:{visible:false},
					separator03:{visible:false},
					undo:{visible:false},
					redo:{visible:false},
					separator04:{visible:false},
					insertUnorderedList:{visible:true},
					insertHorizontalRule:{visible:true},
					h1mozilla:{visible:false&&$.browser.mozilla,className:'h1',command:'heading',arguments:['h1'],tags:['h1'],tooltip:"Header1"},
					h2mozilla:{visible:false&&$.browser.mozilla,className:'h2',command:'heading',arguments:['h2'],tags:['h2'],tooltip:"Header2"},
					h3mozilla:{visible:false&&$.browser.mozilla,className:'h3',command:'heading',arguments:['h3'],tags:['h3'],tooltip:"Header3"},
					h1:{visible:false&&!($.browser.mozilla),className:'h1',command:'formatBlock',arguments:['<H1>'],tags:['h1'],tooltip:"Header1"},
					h2:{visible:false&&!($.browser.mozilla),className:'h2',command:'formatBlock',arguments:['<H2>'],tags:['h2'],tooltip:"Header2"},
					h3:{visible:false&&!($.browser.mozilla),className:'h3',command:'formatBlock',arguments:['<H3>'],tags:['h3'],tooltip:"Header3"},
					separator05:{visible:false},
					h4mozilla:{visible:false&&$.browser.mozilla,className:'h4',command:'heading',arguments:['h4'],tags:['h4'],tooltip:"Header4"},
					h5mozilla:{visible:false&&$.browser.mozilla,className:'h5',command:'heading',arguments:['h5'],tags:['h5'],tooltip:"Header5"},
					h6mozilla:{visible:false&&$.browser.mozilla,className:'h6',command:'heading',arguments:['h6'],tags:['h6'],tooltip:"Header6"},
					h4:{visible:false&&!($.browser.mozilla),className:'h4',command:'formatBlock',arguments:['<H4>'],tags:['h4'],tooltip:"Header4"},
					h5:{visible:false&&!($.browser.mozilla),className:'h5',command:'formatBlock',arguments:['<H5>'],tags:['h5'],tooltip:"Header5"},
					h6:{visible:false&&!($.browser.mozilla),className:'h6',command:'formatBlock',arguments:['<H6>'],tags:['h6'],tooltip:"Header6"},
					separator06:{visible:false},
					insertHorizontalRule:{visible:false},
					createLink:{visible:false},
					insertImage:{visible:false},
					separator07:{visible:false},
					separator08:{visible:false},
					cut:{visible:false},
					copy:{visible:false},
					paste:{visible:false},
					separator09:{visible:false},
					removeFormat:{visible:false}
			}
		});
	}
	jQuery('ul.tabset').each(function(){
		var _list = $(this);
		var _links = _list.find('a.tab');

		_links.each(function() {
			var _link = $(this);
			var _href = _link.attr('href');
			var _tab = $(_href);

			if(_link.hasClass('active')) _tab.show();
			else _tab.hide();

			_link.click(function(){
				_links.filter('.active').each(function(){
					$($(this).removeClass('active').attr('href')).hide();
				});
				_link.addClass('active');
				_tab.show();
				return false;
			});
		});
	});
	jQuery('#carusel').gallery({
		duration: 1000,
		autoRotation: false,
		listOfSlides: 'li',
		slideElement: 2
	});
	
jQuery('.blog-gallery').gallery({
		duration: 1000,
		autoRotation: false,
		listOfSlides: '.blog',
		slideElement: 1
	});

	jQuery('.blog-gallery').gallery({
		duration: 1000,
		autoRotation: false,
		listOfSlides: '.blogInspired',
		slideElement: 1
	});
	jQuery('.mix-box').gallery({
		duration: 1000,
		autoRotation: false,
		listOfSlides: '.mixminglelist',
		slideElement: 1
	});
	
	if(jQuery('ul.image-list').length){
		jQuery('ul.image-list').sortable();
	}
	// autocomplete
	$.widget( "custom.catcomplete", $.ui.autocomplete, {
		_renderMenu: function( ul, items ) {
			var self = this,
				currentCategory = "";
			$.each( items, function( index, item ) {
				if ( item.category != currentCategory ) {
					ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" );
					currentCategory = item.category;
				}
				self._renderItem( ul, item );
			});
		}
	});
	
	var field = jQuery('input#member-name');
	var words = jQuery('span#member-base').text();
	words = words.split(/[,]/g);
	var tags = [];
	var label;
	var category;
	for(var i = 0; i < words.length; i+=2){
		if(words[i] != '' && !words[i+1] == ''){
			label = words[i].replace(/[\t^\s]/g, '');
			category = words[i+1].replace(/[\t^\s]/g, '');
			tags.push({label: label, category: category});
		}
	}
	if(field.length){
		field.catcomplete({
			delay: 0,
			source: tags
		});
	}
}

function viewSwitcher(){
	var _holder = jQuery('span.switch');
	_holder.each(function(){
		var _link = jQuery('a', jQuery(this));
		_link.each(function(i){
			if(i > 0){
				jQuery(this).hide()
			}else{
				jQuery(this).trigger('click');
			}
			jQuery(this).click(function(){
				var _index;
				if(jQuery(this).index() < _link.length - 1){
					_index = jQuery(this).index() + 1;
				}else{
					_index = 0;
				}
				jQuery(this).hide();
				_link.eq(_index).show()
			})
		});
	});
}

function initOpenCloseForms(){
	var holder = jQuery('.form-category-list');
	var parent = jQuery('li', holder);
	var activeClass = 'active';
	var speed = 500;
	
	parent.each(function(){
		var _this = jQuery(this);
		var opener = jQuery('>.opener', _this);
		var inputs = jQuery('.opener input:radio, .opener input:checkbox', _this);
		var slider = jQuery('>div.subcategory', _this);
		
		opener.click(checkOptions);
		inputs.focus(checkOptions);
		
		function checkOptions(){
			if(!slider.is(':animated')){
				_this.each(function(){
					var _this = jQuery(this);
					var opener = jQuery('>.opener', _this);
					var inputs = jQuery('.opener input:radio, .opener input:checkbox', _this);
					var slider = jQuery('>div.subcategory', _this);
					
					if(inputs.is(':checked')){
						slider.slideDown(speed);
						if(!inputs.attr('type') == 'radio'){
							inputs.attr('checked', 'checked');
						}
						_this.addClass(activeClass);
					}else{
						slider.slideUp(speed);
						if(!inputs.attr('type') == 'radio'){
							inputs.removeAttr('checked');
						}
						_this.removeClass(activeClass);
					}
				});
			}
		}
		
		if(inputs.attr('checked') == true){_this.addClass(activeClass);}else{_this.removeClass(activeClass);}
		if(!_this.hasClass(activeClass)){slider.hide();}else{slider.show();}
	});
}

function initBrowserDetect(){
	var u = navigator.userAgent.toLowerCase();
	var _html = document.getElementsByTagName("html")[0];

	if (is("safari") && is("version/3")) addClass("safari");
	else if(is("safari") && is("version/4")) addClass("safari");
	else if(is("chrome")) addClass("chrome");
	else if(is("safari")) addClass("safari");

	function is(browser)
	{
		if(u.indexOf(browser) !=-1) return true;
	}
	function addClass(_class)
	{
		_html.className += (" " + _class);
	}
}

function selectAjaxSwicther(){
	var switcherName;
	var holderName;
	var selectObj = jQuery('a.ajax');
	var option;
	
	selectObj.click(function(){
		switcherName = jQuery(this).attr('rel');
		holderName = jQuery(this).attr('target');
		option = jQuery(this);
		ajaxSwitch();
		return false;
	});
	
	function ajaxSwitch(){
		var switcherObj = option.parents(switcherName);
		var holderObj = switcherObj.find(holderName);
		holderObj.css({position: 'relative', height: holderObj.innerHeight()});
		jQuery("<img class='loader'>").appendTo(holderObj);
		holderObj.find('img.loader').attr('src', 'images/ajax-loader.gif').css
		({
			position: 'absolute',
			top: '50%',
			left: '50%',
			marginTop: -holderObj.find('img.loader').innerHeight() / 2,
			marginLeft: -holderObj.find('img.loader').innerWidth() / 2
		});
		jQuery.ajax({
			url:option.attr('href'),
			type:"get",
			success:function(msg){
				holderObj.empty();
				//jQuery("<div>").html(msg).appendTo(holderObj);does nt work for IE
				document.getElementById('view-holder').innerHTML =msg;
				holderObj.css({position: 'static', height: 'auto'});
				initPlugins();
			},
			error:function(){
				alert("AJAX Error!");
			}
		});
	};
}

function hideFormText() {
	var _inputs = document.getElementsByTagName('input');
	var _txt = document.getElementsByTagName('textarea');
	var _value = [];
	
	if (_inputs) {
		for(var i=0; i<_inputs.length; i++) {
			if (_inputs[i].type == 'text' || _inputs[i].type == 'password') {
				
				_inputs[i].index = i;
			_value[i] = _inputs[i].value;
				
				_inputs[i].onfocus = function(){
					if (this.value == _value[this.index])
						this.value = '';
				}
				_inputs[i].onblur = function(){
					if (this.value == '')
						this.value = _value[this.index];
				}
			}
		}
	}
	if (_txt) {
		for(var i=0; i<_txt.length; i++) {
			_txt[i].index = i;
			_value['txt'+i] = _txt[i].value;
			
			_txt[i].onfocus = function(){
				if (this.value == _value['txt'+this.index])
					this.value = '';
			}
			_txt[i].onblur = function(){
				if (this.value == '')
					this.value = _value['txt'+this.index];
			}
		}
	}
}

// jquery ie6 hover pack
function ieHover(obj, hoverClass){
	var elements = obj;
	var hoverClass = hoverClass;
	if($.browser.msie && parseInt($.browser.version) == 6){
		$(elements).hover(function(){
			$(this).addClass(hoverClass);
		}, function(){
			$(this).removeClass(hoverClass);
		});
	}
}

function initValidation(){
	var _errorClass = 'error';
	var _regEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var _regEmails = /^([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,4})+([, ]+[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,4})*$/;
	var _regPhone = /^[0-9\-\ \()]+$/;
	var _regNum = /^[0-9]+$/;
	var _regDay = /^(([0]{1}[1-9]{1})|([1-9]{1})|([1-2]{1}[0-9]{1})|([3]{1}[0-1]{1}))$/;
	var _regMon = /^(([0]{1}[1-9]{1})|([1-9]{1})|([1]{1}[0-2]{1}))$/;
	var _regYear = /^[19]{2}[0-9]{2}$/;
	
	$('#main .registration-form').each(function(){
		var _form = $(this);
		function checkFields() {
			var _flag = false;
			_form.find('.'+_errorClass).removeClass(_errorClass);

			// fields validation
			_form.find('input.required-email').each(function(){
				if(!_regEmail.test($(this).val())) addError($(this));
			});
			
			_form.find('input.required-confirm-email').each(function(){
				var _confPass = $(this).val();
				var _truePass = $(this).parents('div.form-holder').find('input.email').val();
				if(_confPass != _truePass) addError($(this));
			});
			
			_form.find('input.required-length').each(function(){
				if(!$(this).val().length || $(this).val().length > 12) addError($(this));
			});
			
			_form.find('input.required-confirm-password').each(function(){
				var _confPass = $(this).val();
				var _truePass = $(this).parents('div.form-holder').find('input.pass').val();
				if(_confPass != _truePass) addError($(this));
			});
			
			
			_form.find('input.required-day').each(function(){
				if(!_regDay.test($(this).val())) addError($(this));
			});
			_form.find('input.required-mon').each(function(){
				if(!_regMon.test($(this).val())) addError($(this));
			});
			_form.find('input.required-year').each(function(){
				if(!_regYear.test($(this).val())) addError($(this));
			});
			_form.find('textarea.required-many-emails').each(function(){
				if(!_regEmails.test($(this).val())) addError($(this));
			});
			_form.find('input.required-phone').each(function(){
				if(!_regPhone.test($(this).val())) addError($(this));
			});
			_form.find('input.required-num').each(function(){
				if(!_regNum.test($(this).val())) addError($(this));
			});
			_form.find('input.required, textarea.required').each(function(){
				if(!$(this).val().length || $(this).val() == $(this).attr('alt')) addError($(this));
			});
			_form.find('input.required-chek').each(function(){
				if (!$(this).is(':checked')) {
					$(this).parent('div').addClass('error-chk');
					_flag=true;
				}
			});
			_form.find('div.required-radio').each(function(){
				var _test = false;
				$(this).find('input[type=radio]').each(function(){
					if ($(this).is(':checked')) _test = true;
				});
				if (!_test) {
					_flag=true;
				}
			});

			// error class adding
			function addError(_obj) {
				_obj.parents('div.row').addClass(_errorClass);
				_flag=true;
			}
			return _flag;
		}

		// catch form submit event
		_form.submit(function(){
			if(checkFields()) {
				return false;
			}
		});
	});
}

//* jquery tabs *********************************************************************************
jQuery.fn.jqueryTabs = function(_options){
	// defaults options
/*
		event: 'click','mouseover','mouseleave'
*/
	var _options = jQuery.extend({
		event: 'click',
		tabset: 'ul.tabset'
	},_options);

	return this.each(function(){
		var _this = jQuery(this);
		var _tabset = jQuery(_options.tabset,_this);

		_tabset.each(function(){
			var _list = $(this);
			var _links = _list.find('a.tab', _list);
			if(_links.filter('.active').length == 0) _links.eq(0).addClass('active');

			_links.each(function() {
				var _link = $(this);
				var _href = _link.attr('href');
				var _tab = $(_href, _this);

				if(_link.hasClass('active')) _tab.show();
				else _tab.hide();

				_link.bind(_options.event, function(){
					_links.filter('.active').each(function(){
						$($(this).removeClass('active').attr('href')).hide();
					});
					_link.addClass('active');
					_tab.show();
					return false;
				});
			});
		});
	})
}

// popups function
function initPopups() {
	var _zIndex = 1000;
	var _fadeSpeed = 350;
	var _faderOpacity = 0.3;
	var _faderBackground = '#000';
	var _faderId = 'lightbox-overlay';
	var _closeLink = 'a.btn-close, a.close, a.cancel';
	var _fader;
	var _lightbox = null;
	var _ajaxClass = 'ajax';
	var _openers = jQuery('a.with-popup');
	var _page = jQuery(document);
	var _minWidth = jQuery('body').outerWidth();
	var _scroll = false;
	var _ie = true;

	// init popup fader
	_fader = jQuery('#'+_faderId);
	if(!_fader.length) {
		_fader = jQuery('<div />');
		_fader.attr('id',_faderId);
		jQuery('body').append(_fader);
	}
	_fader.css({
		opacity:_faderOpacity,
		backgroundColor:_faderBackground,
		position:'absolute',
		overflow:'hidden',
		display:'none',
		top:0,
		left:0,
		zIndex:_zIndex
	});

	// IE6 iframe fix
	if(jQuery.browser.msie && jQuery.browser.version < 7) {
		if(!_fader.children().length) {
			var _frame = jQuery('<iframe src="javascript:false" frameborder="0" scrolling="no" />');
			_frame.css({
				opacity:0,
				width:'100%',
				height:'100%'
			});
			var _frameOverlay = jQuery('<div>');
			_frameOverlay.css({
				top:0,
				left:0,
				zIndex:1,
				opacity:0,
				background:'#000',
				position:'absolute',
				width:'100%',
				height:'100%'
			});
			_fader.empty().append(_frame).append(_frameOverlay);
		}
	}

	// lightbox positioning function
	function positionLightbox() {
		if(_lightbox) {
			_minWidth = jQuery('body').outerWidth();
			var _windowHeight = jQuery(window).height();
			var _windowWidth = jQuery(window).width();
			var _lightboxWidth = _lightbox.outerWidth();
			var _lightboxHeight = _lightbox.outerHeight();
			var _pageHeight = _page.height();

			if (_windowWidth < _minWidth) _fader.css('width',_minWidth);
				else _fader.css('width','100%');
			if (_windowHeight < _pageHeight) _fader.css('height',_pageHeight);
				else _fader.css('height',_windowHeight);

			_lightbox.css({
				position:'absolute',
				zIndex:(_zIndex+1)
			});

			// vertical position
			if (_windowHeight > _lightboxHeight) {
				if (jQuery.browser.msie && jQuery.browser.version < 7) {
					_lightbox.css({
						position:'absolute',
						top: parseInt(jQuery(window).scrollTop()) + (_windowHeight - _lightboxHeight) / 2
					});
				} else {
					_lightbox.css({
						position:'fixed',
						top: (_windowHeight - _lightboxHeight) / 2
					});
				}
			} else {
				var _faderHeight = _fader.height();
				if(_faderHeight < _lightboxHeight) _fader.css('height',_lightboxHeight);
				if (!_scroll) {
					if (_faderHeight - _lightboxHeight > parseInt(jQuery(window).scrollTop())) {
						_faderHeight = parseInt(jQuery(window).scrollTop())
						_scroll = _faderHeight;
					} else {
						_scroll = _faderHeight - _lightboxHeight;
					}
				}
				_lightbox.css({
					position:'absolute',
					top: _scroll
				});
			}

			// horizontal position
			if (jQuery(window).width() > _lightbox.outerWidth()) _lightbox.css({left:(jQuery(window).width() - _lightbox.outerWidth()) / 2, marginLeft: 0});
			else _lightbox.css({left: _minWidth / 2 - _lightbox.outerWidth() / 2, marginLeft: -jQuery(window).scrollLeft()});
		}
	}

	// show/hide lightbox
	function toggleState(_state) {
		if(!_lightbox) return;
		if(_state) {
			if(_ie && jQuery.browser.msie){
				_fader.show();
				_lightbox.show()
			}else{
				_fader.fadeIn(_fadeSpeed,function(){
					_lightbox.fadeIn(_fadeSpeed);
				});
			}
			_scroll = false;
			positionLightbox();
		} else {
			if(_ie && jQuery.browser.msie){
				_lightbox.hide();
				_fader.hide();
			}else{
				_lightbox.fadeOut(_fadeSpeed,function(){
					_fader.fadeOut(_fadeSpeed);
					_scroll = false;
				});
			}
		}
	}

	// popup actions
	function initPopupActions(_obj) {
		if(!_obj.get(0).jsInit) {
			_obj.get(0).jsInit = true;
			// close link
			_obj.find(_closeLink).click(function(){
				_lightbox = _obj;
				toggleState(false);
				return false;
			});
		}
	}

	// lightbox openers
	_openers.each(function(){
		var _opener = jQuery(this);
		var _target = _opener.attr('href');

		// popup load type - ajax or static
		if(_opener.hasClass(_ajaxClass)) {
			_opener.click(function(){
				// ajax load
				if(jQuery('div[rel*="'+_target+'"]').length == 0) {
					jQuery.ajax({
						url: _target,
						type: "POST",
						dataType: "html",
						success: function(msg){
							// append loaded popup
							_lightbox = jQuery(msg);
							_lightbox.find('img').load(positionLightbox)
							_lightbox.attr('rel',_target).hide().css({
								position:'absolute',
								zIndex:(_zIndex+1),
								top: -9999,
								left: -9999
							});
							jQuery('body').append(_lightbox);

							// init js for lightbox
							initPopupActions(_lightbox);

							// show lightbox
							toggleState(true);
						},
						error: function(msg){
							alert('AJAX error!');
							return false;
						}
					});
				} else {
					_lightbox = jQuery('div[rel*="'+_target+'"]');
					toggleState(true);
				}
				return false;
			});
		} else {
			if(jQuery(_target).length) {
				// init actions for popup
				var _popup = jQuery(_target);
				initPopupActions(_popup);
					// open popup
					_opener.click(function(){
					if(_lightbox) {
						_lightbox.fadeOut(_fadeSpeed,function(){
							_lightbox = _popup.hide();
							toggleState(true);
						})
					} else {
						_lightbox = _popup.hide();
						toggleState(true);
					}
					return false;
				});
			}
		}
	});

	// event handlers
	jQuery(window).resize(positionLightbox);
	jQuery(window).scroll(positionLightbox);
	jQuery(document).keydown(function (e) {
		if (!e) evt = window.event;
		if (e.keyCode == 27) {
			toggleState(false);
		}
	})
	_fader.click(function(){
		if(!_fader.is(':animated')) toggleState(false);
		return false;
	})
}

(function($) {
	function Gallery(el, options) {
		this._hold = $(el);
		this.initOptions(options);
		this._timer = options.autoRotation;
		this._t;
		this.initialize();
	}
	
	$.fn.gallery = function(options) {
		return this.each(function(){
			new Gallery(this, options);
		});
	};
	
	Gallery.prototype = {
		initOptions: function(_obj){
			this.options = {
				duration: 700,
				slideElement: 1,
				autoRotation: false,
				effect: false,
				of: '.of',
				listOfSlides: 'ul > li',
				switcher: false,
				disableBtn: false,
				nextBtn: 'a.link-next, a.btn-next, a.next ,a.btn-right',
				prevBtn: 'a.link-prev, a.btn-prev, a.prev ,a.btn-left',
				circle: true,
				direction: false,
				IE: false
			};
			for(key in _obj) this.options[key] = _obj[key];
		},
		initialize: function(){
			var _this = this;
			var _hold = _this._hold;
			var _speed = _this.options.duration;
			var _timer = _this.options.autoRotation;
			var _el = _hold.find(_this.options.listOfSlides);
			if (_this.options.effect) var _list = _el;
			else var _list = _el.parent();
			var _switcher = _hold.find(_this.options.switcher);
			var _next = _hold.find(_this.options.nextBtn);
			var _prev = _hold.find(_this.options.prevBtn);
			var _of = _hold.find(_this.options.of);
			var _count = _el.index(_el.filter(':last'));
			var _w = _el.outerWidth(true);
			var _h = _el.outerHeight(true);
			if (_this.options.switcher) var _active = _switcher.index(_switcher.filter('.active:eq(0)'));
			else var _active = _el.index(_el.filter('.active:eq(0)'));
			if (_active < 0) _active = 0;
			var _last = _active;
			
			// Installation directions
			if (!_this.options.direction) {
				var _wrapHolderW = Math.ceil(_list.parent().width() / _w);
				if (((_wrapHolderW - 1) * _w + _w / 2) > _list.parent().width()) _wrapHolderW--;
			}
			else{
				var _wrapHolderW = Math.ceil(_list.parent().height()/_h);
				if (((_wrapHolderW-1)*_h + _h/2) > _list.parent().height()) _wrapHolderW--;
			}
			
			// Setting "fade" or "slide" effect
			if (!_this.options.effect) var rew = _count - _wrapHolderW + 1;
			else var rew = _count;
			if (!_this.options.effect) {
				if (!_this.options.direction) _list.css({marginLeft: -(_w * _active)})
				else _list.css({marginTop: -(_h * _active)})
			}
			else {
				_list.css({
					opacity: 0
				}).removeClass('active').eq(_active).addClass('active').css({
					opacity: 1
				}).css('opacity', 'auto');
				_switcher.removeClass('active').eq(_active).addClass('active');
			}
			
			// Disable or enable buttons "prev next"
			if (_this.options.disableBtn) {
				if (_count < _wrapHolderW) _next.addClass(_this.options.disableBtn);
				_prev.addClass(_this.options.disableBtn);
			}
			
			// Function to "fade"
			function fadeElement(){
				if ($.browser.msie && _this.options.IE){
					_list.eq(_last).css({opacity:0});
					_list.removeClass('active').eq(_active).addClass('active').css({opacity:'auto'});
				}
				else{
					_list.eq(_last).animate({opacity:0}, {queue:false, duration: _speed});
					_list.removeClass('active').eq(_active).addClass('active').animate({
						opacity:1
					}, {queue:false, duration: _speed, complete: function(){
						$(this).css('opacity','auto');
					}});
				}
				if (_this.options.switcher) _switcher.removeClass('active').eq(_active).addClass('active');
				_last = _active;
			}
			
			// Function for "slide"
			function scrollEl(){
				var _sum = _active*4+1;
				_of.text(_sum + ' - ' + (_sum+3) +' of 12');
				if (!_this.options.direction) _list.animate({marginLeft: -(_w * _active)}, {queue:false, duration: _speed})
				else _list.animate({marginTop: -(_h * _active)}, {queue:false, duration: _speed})
				if (_this.options.switcher) _switcher.removeClass('active').eq(_active).addClass('active');
			}
			function toPrepare(){
				if ((_active == rew) && _this.options.circle) _active = -_this.options.slideElement;
				for (var i = 0; i < _this.options.slideElement; i++){
					_active++;
					if (_active > rew) {
						_active--;
						if (_this.options.disableBtn &&(_count > _wrapHolderW)) _next.addClass(_this.options.disableBtn);
					}
				};
				if (_active == rew) if (_this.options.disableBtn &&(_count > _wrapHolderW)) _next.addClass(_this.options.disableBtn);
				if (!_this.options.effect) scrollEl();
				else fadeElement();
			}
			_this._hold.bind('runTimer', function(){
				_this._t = setInterval(function(){
					toPrepare();
				}, _this._timer);
			});
			_next.click(function(){
				if(_this._t) clearTimeout(_this._t);
				if (_this.options.disableBtn &&(_count > _wrapHolderW)) _prev.removeClass(_this.options.disableBtn);
				toPrepare();
				if (_this._timer) _this._hold.trigger('runTimer');
				return false;
			});
			_prev.click(function(){
				if(_this._t) clearTimeout(_this._t);
				if (_this.options.disableBtn &&(_count > _wrapHolderW)) _next.removeClass(_this.options.disableBtn);
				if ((_active == 0) && _this.options.circle) _active = rew + _this.options.slideElement;
				for (var i = 0; i < _this.options.slideElement; i++){
					_active--;
					if (_active < 0) {
						_active++;
						if (_this.options.disableBtn &&(_count > _wrapHolderW)) _prev.addClass(_this.options.disableBtn);
					}
				};
				if (_active == 0) if (_this.options.disableBtn &&(_count > _wrapHolderW)) _prev.addClass(_this.options.disableBtn);
				if (!_this.options.effect) scrollEl();
				else fadeElement();
				if (_this._timer) _this._hold.trigger('runTimer');
				return false;
			});
			if (_this.options.switcher) _switcher.click(function(){
				_active = _switcher.index($(this));
				if(_this._t) clearTimeout(_this._t);
				if (!_this.options.effect) scrollEl();
				else fadeElement();
				if (_this._timer) _this._hold.trigger('runTimer');
				return false;
			});
			if (_this._timer) _this._hold.trigger('runTimer');
		},
		stop: function(){
			var _this = this;
			alert(1);
			if (_this._t) clearTimeout(_this._t);
		},
		play: function(){
			var _this = this;
			alert(2);
			if (_this._t) clearTimeout(_this._t);
			if (_this._timer) _this._hold.trigger('runTimer');
		}
	}
}(jQuery));

function fadeGall(){
	var wait_time = 4000; // in ms  // changed the wait time to 2000 to 4000.
	var change_speed = 1200; // in ms
	var _hold = $('div.movie-area');
	if(_hold.length){
		var _t;
		var _f = true;
		var _pauseFlag = false;
		var _list = _hold.find('ul.slider > li');
		var _list1 = _hold.find('ul.slider1 > li'); // added this for spotlight title
		var _btn = $('<ul class="paging"></ul>');
		var _prev = _hold.find('a.prev');
		var _next = _hold.find('a.next');
		var _pause = _hold.find('a.pause');
		_hold.find('div.controls').prepend(_btn);
		_list.each(function(_i){
			_btn.append('<li><a href="#">'+(_i+1)+'</a></li>');
		});
		_btn = _btn.find('a');
		var _a = _list.index(_list.filter('.active:eq(0)'));
		if(_a == -1) _a = 0;
		
		_list.removeClass('active').css('opacity', 0).eq(_a).addClass('active').css('opacity', 1);
		_list1.removeClass('active').css('opacity', 0).eq(_a).addClass('active').css('opacity', 1); // added this for spotlight title
		_btn.eq(_a).parent('li').addClass('active');
		_btn.click(function(){
			changeEl(_btn.index(this));
			return false;
		});
		
		_prev.click(function(){
			if(_a <= 0) changeEl(_list.length-1);
			else changeEl(_a-1);
			return false;
		});
		_next.click(function(){
			if(_a < _list.length - 1) changeEl(_a + 1);
			else changeEl(0);
			return false;
		});
		
		_pause.click(function(){
			if(!$(this).hasClass('play')){
				$(this).addClass('play');
				if(_t) clearTimeout(_t);
				_pauseFlag = true;
			}
			else{
				$(this).removeClass('play');
				if(_t) clearTimeout(_t);
				_pauseFlag = false;
				if(_f && wait_time){
					_t = setTimeout(function(){
						if(_a < _list.length - 1) changeEl(_a + 1);
						else changeEl(0);
					}, wait_time);
				}
			}
			return false;
		});
		
		if(_f && wait_time){
			_t = setTimeout(function(){
				if(_a < _list.length - 1) changeEl(_a + 1);
				else changeEl(0);
			}, wait_time);
		}
		function changeEl(_ind){
			if(_t) clearTimeout(_t);
			if(_ind != _a){
				_list.eq(_a).removeClass('active').animate({opacity: 0}, {queue:false, duration:change_speed});
				_list.eq(_ind).addClass('active').animate({opacity: 1}, {queue:false, duration:change_speed});
				_list1.eq(_a).removeClass('active').animate({opacity: 0}, {queue:false, duration:change_speed}); // added this for spotlight title
				_list1.eq(_ind).addClass('active').animate({opacity: 1}, {queue:false, duration:change_speed}); // added this for spotlight title
				_btn.eq(_a).parents('li').removeClass('active');
				_btn.eq(_ind).parents('li').addClass('active');
				_a = _ind;
			}
			if(!_pauseFlag){
				if(_f && wait_time){
					_t = setTimeout(function(){
						if(_a < _list.length - 1) changeEl(_a + 1);
						else changeEl(0);
					}, wait_time);
				}
			}
		}
	}
}




/* Pop up for Login page */
/*$('a.with-signin-popup').each(function(){		
	var _el = this;
	var _top = $(this).offset().top + 40;
	var _left = $(this).offset().left + 10;
	if(_el.hash && _el.hash.length > 1){
		_el._popup = $(_el.hash);
		if(_el._popup.length){
			_el.onclick = function(){
				if(_el._popup){
					_el._popup.hide();
					_popup = _el._popup;
					showPopup(170, 470);
				}
				$(this).parents('li').addClass('active');
				return false;
			}
			_el._popup.find('a.btn-close').click(function(){
				$('.item-list > li').removeClass('active');
				if($.browser.msie){
					_popup.hide();
					_fader.fadeOut(200);
					_popup = -1;
				}
				else{
					_popup.fadeOut(400, function(){
						_fader.fadeOut(200);
						 _popup = -1;
					});
				}
				return false;
			});
		}
	}
});
_fader.click(function(){
	$('.item-list > li').removeClass('active');
	if(_popup != -1){
		if($.browser.msie){
			_popup.hide();
			_fader.fadeOut(200);
			_popup = -1;
		}
		else{
			_popup.fadeOut(400, function(){
				_fader.fadeOut(200);
				_popup = -1;
			});
		}
	}
	return false;
});
$(document).keydown(function(e){
	if(!e)evt = window.event;
	if(e.keyCode == 27 && _popup != -1){
		if($.browser.msie){
			_popup.hide();
			_fader.fadeOut(200);
			_popup = -1;
		}
		else{
			_popup.fadeOut(400, function(){
				_fader.fadeOut(200);
				_popup = -1;
			});
		}
	}
});
function showPopup(_top, _left){
	_fader.css({
		opacity: 0,
		height: initH(),
		position: 'absolute',
		width: '100%',
		left: 0,
		top: 0,
		zIndex: 998,
		background: '#ccc'
	});
	_popup.css({top: _top, left: _left});
	_fader.fadeTo(400, 0.5, function(){
		if(_popup != -1){
			if($.browser.msie) _popup.show();
			else _popup.fadeIn(200, function(){
				if(initH() < _popup.outerHeight()+_popup.offset().top) _fader.height(_popup.outerHeight()+_popup.offset().top);
			});
			_popup.css({top: _top});
			if(initH() < _popup.outerHeight()+_popup.offset().top) _fader.height(_popup.outerHeight()+_popup.offset().top);
		}
	});
}
function initH(){
	var _h = $('#wrapper').outerHeight();
	if(_h < $(window).height()) _h = $(window).height();
	if(_h < $('body').height()) _h = $('body').height();
	return _h;
}
}*/

/* AJAX logic for the view album page */

function switchCommentsTab(photoId)
{
	var id = photoId.split("_");
    var thePhotoId= id[0];
    var albumId=id[1];
   	var comments_url = "/albums/ajax-comments.cfm?photoId="+thePhotoId+"&albumId="+albumId;
		
	jQuery.ajax({
		url:comments_url,
		type:"get",
		success:function(msg){
 			document.getElementById('tab4').innerHTML = msg;
			initPlugins();
		},
		error:function(){
			alert("AJAX Error!");
		}
	});
	
	
	switchLikeTab(thePhotoId,albumId);
	switchPhotoSectionTab(thePhotoId,albumId);
	//switchPhotoTitleTab(thePhotoId,albumId);
}

function switchLikeTab(photoId,albumId)
{

	//change the content of the div based on photo Id
	var like_url = "/albums/ajax-like.cfm?photoId="+photoId+"&albumId="+albumId;
	
	jQuery.ajax({
		url:like_url,
		type:"get",
		success:function(msg){
 			if (document.getElementById('socialNetworkInclude') != null) {
				document.getElementById('socialNetworkInclude').innerHTML =msg;
			}
			/*if (document.getElementById('likePhotoId') != null) {
 				document.getElementById('likePhotoId').href="index.cfm?page=albums/album_action&photoId="+photoId+"&albumId="+albumId+"&action=14";
			}*/
			initPlugins();
		},
		error:function(){
			alert("AJAX Error!");
		}
	});
	
}

function switchPhotoSectionTab(photoId,albumId)
{

	//change the content of the div based on photo Id
	var photoSection_url = "/albums/ajax-photoSection.cfm?photoId="+photoId+"&albumId="+albumId;
	
	jQuery.ajax({
		url:photoSection_url,
		type:"get",
		success:function(msg){
 			if (document.getElementById('socialNetworkInclude1') != null) {
				document.getElementById('socialNetworkInclude1').innerHTML =msg;
			}
			initPlugins();
		},
		error:function(){
			alert("AJAX Error!");
		}
	});
	
}

function switchPhotoTitleTab(photoId,albumId)
{

	//change the content of the div based on photo Id
	var photoTitle_url = "/albums/ajax-photoTitle.cfm?photoId="+photoId+"&albumId="+albumId;
	
	jQuery.ajax({
		url:photoTitle_url,
		type:"get",
		success:function(msg){
 			document.getElementById('photoTitle').innerHTML =msg;
			initPlugins();
		},
		error:function(){
			alert("AJAX Error!");
		}
	});
	
}

/* method to switch partybuzz tabs using ajax */
function switchPartyBuzzTab(tabname,rows)
{
  //alert("tab"+ tabname);
	//change the content of the div based on photo Id
	var partybuzz_url = "/albums/inc_album_tab1.cfm?partyBuzzfor="+tabname+"&rows="+rows;	
	jQuery.ajax({
		url:partybuzz_url,
		type:"get",
		success:function(msg){
 			document.getElementById('tab1').innerHTML =msg;
 			//document.getElementById('likePhoto').href="index.cfm?page=albums/album_action&photoId="+photoId+"&albumId="+albumId+"&action=9";
			initPlugins();
		},
		error:function(){
			alert("AJAX Error!");
		}
	});
	
}
/* method to switch clipboard tabs using ajax */
function switchClipboardTab(tabname,page)
{
   //alert("tab"+ tabname);
   //alert("page"+ page);
	//change the content of the div based on photo Id
	var clipboard_url = "/albums/clipboard_albums.cfm?albumfor="+tabname+"&page="+page;
	jQuery.ajax({
		url:clipboard_url,
		type:"get",
		success:function(msg){
 			document.getElementById('tab4').innerHTML =msg;
 			//document.getElementById('likePhoto').href="index.cfm?page=albums/album_action&photoId="+photoId+"&albumId="+albumId+"&action=9";
			initPlugins();
		},
		error:function(){
			alert("AJAX Error!");
		}
	});
	
}

/* method to load view album top ad using ajax */
function switchTopBanner()
{
   	//var ad_url = "/ads/728x90.cfm";
	var ad_url = "http://www2.glam.com/app/site/affiliate/viewChannelModule.act?mName=viewAdJs&affiliateId=301841138&adSize=728x90";
	jQuery.ajax({
		url:ad_url,
		type:"get",
		success:function(msg){		
 			document.getElementById('top-banner-div').innerHTML=msg;
			//var the_code=document.getElementById('top-banner-div').innerHTML;
			//var run_the_code=eval(the_code);
 			//document.getElementById('likePhoto').href="index.cfm?page=albums/album_action&photoId="+photoId+"&albumId="+albumId+"&action=9";
			initPlugins();
		},
		error:function(){
			alert("AJAX Error!");
		}
	});
	
}

function switchBtnThumbnail()
{
	$('#btn-thumbnail-Id').removeClass('active');
	//_btnPrev.show();
	//_btnNext.show();
	
}
/* AJAX logic for pros home page search results */ 
function showVendorResults()
{
	var zip= document.getElementById('zip');
	var miles = document.getElementById('miles');
	if(zip != null)
	{
		var results_url = "/pros/ajax-featured-vendor-results.cfm?zip="+ zip.value+"&miles="+miles.value;
		jQuery.ajax(
		{
			url:results_url,
			type:"get",
			success:function(msg){
				document.getElementById('vendor-results').innerHTML = msg;
				//document.getElementById('zip').value = zip.value;
				//document.getElementById('miles').value = miles.value;
			},
			error:function(){
				alert("AJAX Error!");
			}
		}
		)
	}
}

function showMixandMingle()
{
	var zip= document.getElementById('pros_zip');
	
	if(zip != null)
	{
		var results_url = "/accounts/ajax_mix_mingle.cfm?zip="+ zip.value+"&lati=0&long=0";
		jQuery.ajax(
		{
			url:results_url,
			type:"get",
			success:function(msg)
			{		
				document.getElementById('pros_results').innerHTML = msg;
				document.getElementById('pros_zip').value = zip.value;
			},
			error:function()
			{
				alert("AJAX Error!");
			}
		})
	}
	return false;	
}

/* Function to show add on the view album page */
function showAd()
{
	var adframe = document.getElementById("ad_iframe");
	if(adframe)
	adframe.src="/ads/300x250.html";
}
		
