function showBox(fullUrl){
	window.open(fullUrl,"showBoxCovers","left=10,top=10,width=875,height=600,resizable=1,status=1,scrollbars=1");
}

function showFeedback(fullUrl) {
	window.open(fullUrl,"showFeedback","left=10,top=10,width=700,height=500,resizable=1,status=1,scrollbars=1");
}

function showTerms(fullUrl) {
    window.open(fullUrl, 'termsAndConditions', 'width=500,height=400,resizable=1,status=1,scrollbars=1');
}

function openLiveHelpBox(cm_re){
	window.open('http://server.iad.liveperson.net/hc/599832/?'+cm_re+'cmd=file&file=visitorWantsToChat&site=599832&skill=AEBN&imageUrl=https://server.iad.liveperson.net/hcp/Gallery/ChatButton-Gallery/English/General/1a/&referrer='+document.location,'chat599832','width=472,height=320');
	return false;
}

function resizeToCovers() {
	var resizerDiv = document.getElementById('resizer');
	var resizerHeight =  resizerDiv.offsetHeight;
	var resizerWidth = resizerDiv.offsetWidth;
	var boxFront;
	var boxBack;
	boxFront = document.getElementById("frontBoxCover");
	boxBack = document.getElementById("backBoxCover");
	var deltaWidth;
	var deltaHeight;
	if (boxFront) {
		deltaWidth = boxFront.width;
		deltaHeight = boxFront.height;
	}
	if (boxBack) {
		deltaWidth += boxBack.width;
		if (boxBack.height > deltaHeight) {
			deltaHeight = boxBack.height;
		}
	}
	deltaWidth = deltaWidth - resizerWidth;
	deltaHeight = deltaHeight - resizerHeight;
	window.resizeBy(deltaWidth, deltaHeight);
	window.focus();
}

function resizeToImage() {
	var resizerDiv = document.getElementById('resizer');
	var resizerHeight =  resizerDiv.offsetHeight;
	var resizerWidth = resizerDiv.offsetWidth;

	var gImage;
	gImage = document.getElementById("galleryImage");
	
	var deltaWidth;
	var deltaHeight;
	
	if (gImage) {
		deltaWidth = gImage.width
		deltaHeight = gImage.height;
	}
	deltaWidth = deltaWidth - resizerWidth;
	deltaHeight = deltaHeight - resizerHeight;
	window.resizeBy(deltaWidth, deltaHeight);
	window.focus();
}

/* cookie functionality by yilong */

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+escape(value)+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length,c.length));
	}
	return null;
}

function deleteCookie(name) {
	createCookie(name,"",-1);
}
/* end cookie functionality by yilong */

// function to pop realtouch search select on realtouch frontdoor
function getRealtouchSearchOptions(link, defaultOption) {
    $.getJSON(link, function(data) {
        var searchOptions = '';
        searchOptions += '<option>' + defaultOption + '</option>';
        for (var i = 0; i < data.options.length; i++) {
            searchOptions += '<option value="' + data.options[i].optionValue + '">' + data.options[i].optionDisplay + '</option>';
        }
        $("select#realtouchSearchItems").html(searchOptions);
    });
}

// add realtouch movies/clips to favs
function addRealtouchToFavorites(id, type, link) {
    $.ajax({
        type: "POST",
        url: link,
        data: {type: type, id: id},
        dataType: "text/html",
        cache: false,
        success: function(html) {
            $("#TB_ajaxWindowTitle").html(html);
        },
        error: function() { //remove me
            alert("Error adding favorite");
        }
    })
}

function applyPNGFix(imgToFix){
	var img = imgToFix;
	var imgName = img.src.toUpperCase();
	if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
		var imgID = (img.id) ? "id='" + img.id + "' " : "";
		var imgClass = (img.className) ? "class='" + img.className + "' " : "";
		var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
		var imgStyle = "display:inline-block;" + img.style.cssText;
		if (img.align == "left") imgStyle = "float:left;" + imgStyle;
		if (img.align == "right") imgStyle = "float:right;" + imgStyle;
		if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
		var imgWidth = (img.width == 0) ? img.style.width : img.width + "px";
		var imgHeight = (img.height == 0) ? img.style.height : img.height + "px";
		var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + imgWidth + "; height:" + imgHeight + ";" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
		img.outerHTML = strNewHTML;
		i = i-1;
	}
}
function requiresPNGFix() {
	var browser = new BrowserDetectVeryLite();
	return (browser.isIE5to6 && browser.isWin32);
}

function applyMultiplePNGFixes(imageIdArray) {
	if (requiresPNGFix()) {
		for (var i = 0; i < imageIdArray.length; i++) {	
			var imgToFix = document.getElementById(imageIdArray[i]);
			applyPNGFix(imgToFix);
		}
	}
}



// Stripped version of Browser Detect Lite  v2.1
// http://www.dithered.com/javascript/browser_detect/index.html
// modified by shannonh to only check for IE 5.5 - 7 and windows
function BrowserDetectVeryLite() {
	var ua = navigator.userAgent.toLowerCase(); 
	this.ua = ua;
	// browser name
	this.isIE = ( (ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1) ); 
	// browser version
	this.versionMinor = parseFloat(navigator.appVersion); 
	// correct version number for IE4+ 
	if (this.isIE && this.versionMinor >= 4) {this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );}
	this.versionMajor = parseInt(this.versionMinor); 
	// platform
	this.isWin   = (ua.indexOf('win') != -1);
	this.isWin32 = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1) );
	this.isIE5to6 = (this.isIE && this.versionMajor >= 5 && this.versionMajor < 7);
}

// hide / show the sort favorites select if it exists
// this is a workaround for the IE6 z-index bug
// We will hide the select so that it doesn't 
// appear with a higher z-index than the bandwidth popup.
function hideSortSelect() {
	if (requiresPNGFix()) {
		// is IE5 to IE6 on Windows
		var sortMoviesSelect = document.getElementById('sortMoviesSelect');
		if (sortMoviesSelect != null) {
			sortMoviesSelect.style.display = 'none';
		}
	}
}
function showSortSelect() {
	if (requiresPNGFix()) {
		// is IE5 to IE6 on Windows
		var sortMoviesSelect = document.getElementById('sortMoviesSelect');
		if (sortMoviesSelect != null) {
			sortMoviesSelect.style.display = 'block';
		}
	}
}
// END hide / show the sort favorites select if it exists

//switch boxcover on the 1024 wide layout frontdoor
function switchBoxCover(divId, itemIndex){
	var boxcoverDivId = "#"+divId+"BoxCover";
	var newBoxcoverDivId = "#"+divId+"BoxCover"+itemIndex;
    $(boxcoverDivId).html($(newBoxcoverDivId).html());
}

function isIE6(){
	if (/\bMSIE 6/.test(navigator.userAgent) && !window.opera) { return true; }
}

//Find PNGs without IDs so that applyPNGFix will work in IE6.
//pageZone narrows the page search area
//function ex.: $(function() { pngNoIdFix('.helpFaq'); });
function pngNoIdFix(pageZone){
	if(isIE6()){
		var imageId = new Array();
		var pngObj = pageZone == undefined ? $("img[src*='png']") : $(pageZone + " img[src*='png']");
		var i = 0;
		
		pngObj.each(function(i){	
			if(!$(this).attr('id')){
				pngHeight = $(this).height();
				pngWidth = $(this).width();
				
				$(this).attr({ 
					height : pngHeight,
					width  : pngWidth,
					id     : function(){return "png" + i;}
				});
				
				imageId.push($(this).attr('id'));
				i++; 
			}
		});
		applyMultiplePNGFixes(imageId);
	}
}

//returns locale and orientation of page
function getLocaleOrientation(){
	localeOrientation = $('body').attr('class').split(' ');
	
	return {locale:localeOrientation[0], orientation:localeOrientation[1]}; 
}

// Generic Popup Object
// Set all style attributes in CSS
var GenericPopup = {};

GenericPopup.Create = (function() {
	
	var uniqueInstance;
		
	function constructor(popUpConfig) {
		var popUpConfig = popUpConfig;
			
		function createSelector(id) {
			var jQuerySelector = $('#' + id);
			return jQuerySelector;
		}

		function popUpKill() {
			createSelector(popUpConfig.popUp.id).remove();
		}
				
		function popUpShow() {
			createSelector(popUpConfig.popUp.id).show();
		}
		
		function popUpOnSubmit() {
			createSelector(popUpConfig.popUp.form.submit.submitId).bind('click',function(event){
				event.stopPropagation();
				if(popUpConfig.popUp.form.submit.onSubmit){
					for(funcs in popUpConfig.popUp.form.submit.onSubmit){
						popUpConfig.popUp.form.submit.onSubmit[funcs]();
					}
				};
				popUpKill();
			})
		}
		
		return {
			popUpBuild: function() {
				var popUpLauncher = createSelector(popUpConfig.launcher.id);
				
				popUpLauncher.bind('click',function(e){
					this.popUpElement = document.createElement('div');
					this.popUpElement.id = popUpConfig.popUp.id;
					
					//Add header to popup					
					if(popUpConfig.popUp.header){
						this.headerElement = document.createElement('div');
						this.headerElement.innerHTML = popUpConfig.popUp.header.html;
						this.headerElement.id = popUpConfig.popUp.header.id;
						this.popUpElement.appendChild(this.headerElement);
					}
					
					//Add body content to popup
					if(popUpConfig.popUp.content){
						this.contentElement = document.createElement('p');
						this.contentElement.innerHTML = popUpConfig.popUp.content.html;
						this.contentElement.id = popUpConfig.popUp.content.id;
						this.popUpElement.appendChild(this.contentElement);
					}
					
					//Add form to popup
					if(popUpConfig.popUp.form){
						this.formElement = document.createElement('form');
						this.formElement.innerHTML = popUpConfig.popUp.form.html;
						this.formElement.id = popUpConfig.popUp.form.id;
						this.popUpElement.appendChild(this.formElement);										
					}

					popUpLauncher.parent().css({position: 'relative'});

					if(popUpConfig.popUp.position.attachTo === 'element'){
						popUpLauncher.after(this.popUpElement);
					}
					else{
						document.body.appendChild(this.popUpElement);
					}
					
					//Adds close button to popup
					if(popUpConfig.popUp.header.closeButton === true){						
						this.closeButton = document.createElement('a');
						this.closeButton.id = popUpConfig.popUp.id + 'Close';
						this.closeButton.href = '#';
						this.closeButton.innerHTML = popUpConfig.popUp.header.closeButtonIcon;
						this.headerElement.appendChild(this.closeButton);
												
						createSelector(this.closeButton.id).bind('click', function(){
							popUpKill();
						});
					};
					
					//Adds help button to popup
					if(popUpConfig.popUp.header.helpButton === true){
						//Functionality needs to be added for SBR or future popups
					};
					
					//Adds other methods that need to be called on popup launch event
					if(popUpConfig.launcher.otherFunctions){
						for(i in popUpConfig.launcher.otherFunctions){
							popUpConfig.launcher.otherFunctions[i]();
						}
					};
										
					popUpShow();
					if(popUpConfig.popUp.form){
						popUpOnSubmit();
					}					
				});
			}
		}
	}
	
	return {
		//instansiate an instance of the popup 
		popUpInstance: function(popUpConfig){
			if(!uniqueInstance){
				uniqueInstance = constructor(popUpConfig);
			}
			return uniqueInstance;
		}
	}
	
})();

// gets query string paramaters from URL
var qsParams = new Array();
function qsParamTheater() {
	var query = window.location.search.substring(1).toLowerCase();
	var params = query.split('&');
	for (var i=0; i<params.length; i++) {
	var pos = params[i].indexOf('=');
		if (pos > 0) {
			var key = params[i].substring(0,pos);
			var val = params[i].substring(pos+1);
			qsParams[key] = val;
		}
	}
}


/**
* PNG FIX IE6
* Example usage:
* aebn_pngFix.fix('.png_bkg');  // argument is a CSS selector
* aebn_pngFix.fixPng( someNode );  // argument is an HTMLDomElement
**/
if(isIE6()){
	aebn_pngFix={ns:"aebn_pngFix",imgSize:{},delay:10,nodesFixed:0,createVmlNameSpace:function(){if(document.namespaces&&!document.namespaces[this.ns]){document.namespaces.add(this.ns,"urn:schemas-microsoft-com:vml")}},createVmlStyleSheet:function(){var b,a;b=document.createElement("style");b.setAttribute("media","screen");document.documentElement.firstChild.insertBefore(b,document.documentElement.firstChild.firstChild);if(b.styleSheet){b=b.styleSheet;b.addRule(this.ns+"\\:*","{behavior:url(#default#VML)}");b.addRule(this.ns+"\\:shape","position:absolute;");b.addRule("img."+this.ns+"_sizeFinder","behavior:none; border:none; position:absolute; z-index:-1; top:-10000px; visibility:hidden;");this.screenStyleSheet=b;a=document.createElement("style");a.setAttribute("media","print");document.documentElement.firstChild.insertBefore(a,document.documentElement.firstChild.firstChild);a=a.styleSheet;a.addRule(this.ns+"\\:*","{display: none !important;}");a.addRule("img."+this.ns+"_sizeFinder","{display: none !important;}")}},readPropertyChange:function(){var b,c,a;b=event.srcElement;if(!b.vmlInitiated){return}if(event.propertyName.search("background")!=-1||event.propertyName.search("border")!=-1){aebn_pngFix.applyVML(b)}if(event.propertyName=="style.display"){c=(b.currentStyle.display=="none")?"none":"block";for(a in b.vml){if(b.vml.hasOwnProperty(a)){b.vml[a].shape.style.display=c}}}if(event.propertyName.search("filter")!=-1){aebn_pngFix.vmlOpacity(b)}},vmlOpacity:function(b){if(b.currentStyle.filter.search("lpha")!=-1){var a=b.currentStyle.filter;a=parseInt(a.substring(a.lastIndexOf("=")+1,a.lastIndexOf(")")),10)/100;b.vml.color.shape.style.filter=b.currentStyle.filter;b.vml.image.fill.opacity=a}},handlePseudoHover:function(a){setTimeout(function(){aebn_pngFix.applyVML(a)},1)},fix:function(a){if(this.screenStyleSheet){var c,b;c=a.split(",");for(b=0;b<c.length;b++){this.screenStyleSheet.addRule(c[b],"behavior:expression(aebn_pngFix.fixPng(this))")}}},applyVML:function(a){a.runtimeStyle.cssText="";this.vmlFill(a);this.vmlOffsets(a);this.vmlOpacity(a);if(a.isImg){this.copyImageBorders(a)}},attachHandlers:function(i){var d,c,g,e,b,f;d=this;c={resize:"vmlOffsets",move:"vmlOffsets"};if(i.nodeName=="A"){e={mouseleave:"handlePseudoHover",mouseenter:"handlePseudoHover",focus:"handlePseudoHover",blur:"handlePseudoHover"};for(b in e){if(e.hasOwnProperty(b)){c[b]=e[b]}}}for(f in c){if(c.hasOwnProperty(f)){g=function(){d[c[f]](i)};i.attachEvent("on"+f,g)}}i.attachEvent("onpropertychange",this.readPropertyChange)},giveLayout:function(a){a.style.zoom=1;if(a.currentStyle.position=="static"){a.style.position="relative"}},copyImageBorders:function(b){var c,a;c={borderStyle:true,borderWidth:true,borderColor:true};for(a in c){if(c.hasOwnProperty(a)){b.vml.color.shape.style[a]=b.currentStyle[a]}}},vmlFill:function(e){if(!e.currentStyle){return}else{var d,f,g,b,a,c;d=e.currentStyle}for(b in e.vml){if(e.vml.hasOwnProperty(b)){e.vml[b].shape.style.zIndex=d.zIndex}}e.runtimeStyle.backgroundColor="";e.runtimeStyle.backgroundImage="";f=true;if(d.backgroundImage!="none"||e.isImg){if(!e.isImg){e.vmlBg=d.backgroundImage;e.vmlBg=e.vmlBg.substr(5,e.vmlBg.lastIndexOf('")')-5)}else{e.vmlBg=e.src}g=this;if(!g.imgSize[e.vmlBg]){a=document.createElement("img");g.imgSize[e.vmlBg]=a;a.className=g.ns+"_sizeFinder";a.runtimeStyle.cssText="behavior:none; position:absolute; left:-10000px; top:-10000px; border:none; margin:0; padding:0;";c=function(){this.width=this.offsetWidth;this.height=this.offsetHeight;g.vmlOffsets(e)};a.attachEvent("onload",c);a.src=e.vmlBg;a.removeAttribute("width");a.removeAttribute("height");document.body.insertBefore(a,document.body.firstChild)}e.vml.image.fill.src=e.vmlBg;f=false}e.vml.image.fill.on=!f;e.vml.image.fill.color="none";e.vml.color.shape.style.backgroundColor=d.backgroundColor;e.runtimeStyle.backgroundImage="none";e.runtimeStyle.backgroundColor="transparent"},vmlOffsets:function(d){var h,n,a,e,g,m,f,l,j,i,k;h=d.currentStyle;n={W:d.clientWidth+1,H:d.clientHeight+1,w:this.imgSize[d.vmlBg].width,h:this.imgSize[d.vmlBg].height,L:d.offsetLeft,T:d.offsetTop,bLW:d.clientLeft,bTW:d.clientTop};a=(n.L+n.bLW==1)?1:0;e=function(b,p,q,c,s,u){b.coordsize=c+","+s;b.coordorigin=u+","+u;b.path="m0,0l"+c+",0l"+c+","+s+"l0,"+s+" xe";b.style.width=c+"px";b.style.height=s+"px";b.style.left=p+"px";b.style.top=q+"px"};e(d.vml.color.shape,(n.L+(d.isImg?0:n.bLW)),(n.T+(d.isImg?0:n.bTW)),(n.W-1),(n.H-1),0);e(d.vml.image.shape,(n.L+n.bLW),(n.T+n.bTW),(n.W),(n.H),1);g={X:0,Y:0};if(d.isImg){g.X=parseInt(h.paddingLeft,10)+1;g.Y=parseInt(h.paddingTop,10)+1}else{for(j in g){if(g.hasOwnProperty(j)){this.figurePercentage(g,n,j,h["backgroundPosition"+j])}}}d.vml.image.fill.position=(g.X/n.W)+","+(g.Y/n.H);m=h.backgroundRepeat;f={T:1,R:n.W+a,B:n.H,L:1+a};l={X:{b1:"L",b2:"R",d:"W"},Y:{b1:"T",b2:"B",d:"H"}};if(m!="repeat"||d.isImg){i={T:(g.Y),R:(g.X+n.w),B:(g.Y+n.h),L:(g.X)};if(m.search("repeat-")!=-1){k=m.split("repeat-")[1].toUpperCase();i[l[k].b1]=1;i[l[k].b2]=n[l[k].d]}if(i.B>n.H){i.B=n.H}d.vml.image.shape.style.clip="rect("+i.T+"px "+(i.R+a)+"px "+i.B+"px "+(i.L+a)+"px)"}else{d.vml.image.shape.style.clip="rect("+f.T+"px "+f.R+"px "+f.B+"px "+f.L+"px)"}},figurePercentage:function(d,c,f,a){var b,e;e=true;b=(f=="X");switch(a){case"left":case"top":d[f]=0;break;case"center":d[f]=0.5;break;case"right":case"bottom":d[f]=1;break;default:if(a.search("%")!=-1){d[f]=parseInt(a,10)/100}else{e=false}}d[f]=Math.ceil(e?((c[b?"W":"H"]*d[f])-(c[b?"w":"h"]*d[f])):parseInt(a,10));if(d[f]%2===0){d[f]++}return d[f]},fixPng:function(c){c.style.behavior="none";var g,b,f,a,d;if(c.nodeName=="BODY"||c.nodeName=="TD"||c.nodeName=="TR"){return}c.isImg=false;if(c.nodeName=="IMG"){if(c.src.toLowerCase().search(/\.png$/)!=-1){c.isImg=true;c.style.visibility="hidden"}else{return}}else{if(c.currentStyle.backgroundImage.toLowerCase().search(".png")==-1){return}}g=aebn_pngFix;c.vml={color:{},image:{}};b={shape:{},fill:{}};for(a in c.vml){if(c.vml.hasOwnProperty(a)){for(d in b){if(b.hasOwnProperty(d)){f=g.ns+":"+d;c.vml[a][d]=document.createElement(f)}}c.vml[a].shape.stroked=false;c.vml[a].shape.appendChild(c.vml[a].fill);c.parentNode.insertBefore(c.vml[a].shape,c)}}c.vml.image.shape.fillcolor="none";c.vml.image.fill.type="tile";c.vml.color.fill.on=false;g.attachHandlers(c);g.giveLayout(c);g.giveLayout(c.offsetParent);c.vmlInitiated=true;g.applyVML(c)}};try{document.execCommand("BackgroundImageCache",false,true)}catch(r){}aebn_pngFix.createVmlNameSpace();aebn_pngFix.createVmlStyleSheet();
};	


//set minute package option display and hidden item type value
var setMinutePackageOptions = function(){
	var itemTypeId;
	var getId;
	var regularMinutePackageSelected;
	var subscriptMinutePackageSelected;

	//set state of radio button when switching between packages
	function setLastRadioStateForPackage() {
		var radioButtonObj; 

		if($('.regularMinutes').css('display') == 'block') {
			radioButtonObj = $('input#' + regularMinutePackageSelected)
			quickBuyChargePrice(radioButtonObj,-1);
		}
		else{
			if(subscriptMinutePackageSelected == undefined) {
				radioButtonObj = $('#newSubscriptionItemPriceId1')
				getId = 'newSubscriptionItemPriceId1';
			}
			else{
				radioButtonObj = $('input#' + subscriptMinutePackageSelected);
			}
			quickBuyChargePrice(radioButtonObj,1);
		}
		radioButtonObj.attr('checked','checked');
	}

	//update willChargePrice display for quick buy
	function quickBuyChargePrice(radioButtonObj,packageType) {
		var getIndex, setPrice;

		if($('#buyItNowSavedPayments').css('display') == 'block'){
			getIndex = radioButtonObj.val();
			if(packageType > 0){
				setPrice = subscriptionPackagePriceLookup[getIndex-1];
			}
			else{
				setPrice = packagePriceLookup[getIndex-1];
			}
			$('#willChargeMessage span').text(setPrice);
		}
	}

	//itemTypeId Setting For Common Minute Packages	
	function setNewItemTypeIdValue() {
		if($('#showMinSubscript').attr('checked') == true){
			itemTypeId.attr('value',15);
			populateText();
		}
		else{
			switch (regularMinutePackageSelected) {
				case 'newItemPriceId-FreeMins':
					itemTypeId.attr('value', 12);
					break;
				case 'newItemPriceId0':
					itemTypeId.attr('value', 0);
					break
				default:
					itemTypeId.attr('value',1);
			}
		};
	}

	//Style Minute Pacakge Text
	function showSubscriptMinutePackages() {
		$('.regularMinutes').css({'display':'none'});
		$('.subscriptionMinutes').css({'display':'block'});
		$('#minSubscriptText').css({'display':'block'}); 
	}
	
	function hideSubscriptMinutePackages() {
		$('.subscriptionMinutes').css({'display':'none'});
		$('#minSubscriptText').css({'display':'none'});
		$('.regularMinutes').css({'display':'block'});
	}

	//Populate pricing info in discount pricing disclaimer text
	function populateText() {
		var setIndex = $('.subscriptionPriceInput:checked').val();
		$('#initialPrice').html(subscriptionPackagePriceLookup[setIndex - 1]);
		$('#recurPrice').html(subscriptionRecurringPackagePriceLookup[setIndex - 1])
	}

	//Listeners
	function setSubscriptMinuteListener() {
		$('#showMinSubscript').click(function(){
			if($('#showMinSubscript').attr('checked') == true) {
				if (getId != subscriptMinutePackageSelected) {
					regularMinutePackageSelected = getId;
				}
				populateText();
				showSubscriptMinutePackages();
			}
			else{
				if (getId != regularMinutePackageSelected) {
					subscriptMinutePackageSelected = getId;
				}
	 			hideSubscriptMinutePackages();
			}
			setLastRadioStateForPackage();
			setNewItemTypeIdValue();
 		});
	}

	function setRadioButtonListener() {
		$('input[name="newItemPriceId"]').click(function() {
			getId = $(this).attr('id');

			switch(getId) {
				case 'newItemPriceId-FreeMins':
				    itemTypeId.attr('value',12);
					break;
				case 'newItemPriceId0':
				    itemTypeId.attr('value',0);
					break
				default: 
					setNewItemTypeIdValue();
			}
		});
	}
		
	$(function(){
		itemTypeId = $('#itemTypeId');
		getId =  $('#buyMinuteTimePackagesList input:checked').attr('id');
		setRadioButtonListener();
		setSubscriptMinuteListener();
		if($('#showMinSubscript').attr('checked')){	
			$('#showMinSubscript').removeAttr('checked');	
		}
	});		
};

//open preview page movies and scenes
function previewPage(link) {
	previewWindow = window.open(link,'previewWindow','scrollbars=0,menubar=0,resizable=1,toolbar=0,location=0,status=0,height=636,width=714');
	previewWindow.focus();
}

