// Script Name: header.js
// Author: Martin Ma
// Purpose: Global Navigation for ABC.com

// define abc package
if (typeof com == "undefined") {
	com = {};
}
if (typeof com.abc == "undefined") {
	com.abc = {};
}
if (typeof com.abc.nav == "undefined") {
	com.abc.nav = {};
}
if (typeof CDNRoot == "undefined") {
	CDNRoot = 'http://a.abc.com';
}

com.abc.nav = {
	sNavImagePath: '/media/_global/images/nav/header/',
	oPreloadImages: {
		aInternal: $w( 'whatson shows fullepisodes community' ),
		aExternal: $w( 'mobile news espn shop' ),
		aOther: $w( 'global/close_rollover.jpg global/bkgd.jpg  global/black_bkgd.jpg  global/tonightonabc_module.jpg grid/orange_grid_thisfall.jpg grid/red_grid_nextweek.jpg grid/red_grid_thisweek.jpg' )
	},
	//aCookiesToDelete: $w( 'GREEN BLUE LOGIN regCookie' ),
	sLogoutURL: 'https://register.go.com/abc/heliumapi/logout?appRedirect=',
	aImageCache: [],
	loggedInUser: '',
	oDropDownManager: null,
	nSignin: null,
	nUsername: null,
	
	setup: function() {
		var aNodeList = $$( 'ul.nav li a img' );
		if( aNodeList.length > 0 ) {
		    //aNodelist.each( function(){} ).bind(this) does not work in this version of prototype js
		    for( var i=0; i<aNodeList.length; i++ ) {
			    Event.observe( aNodeList[i], 'mouseover', this.onNavMouse.bindAsEventListener(this, 'mouseover') );
			    Event.observe( aNodeList[i], 'mouseout', this.onNavMouse.bindAsEventListener(this, 'mouseout') );
		    }
			
			this.imagePreload();		
			this.setupDropDownManager();
		} 
	},
	
	imagePreload: function() {
		for( var i = 0; i < this.oPreloadImages.aInternal.length; i++ ) {	
			var oImage = new Image;
			oImage.src = CDNRoot + this.sNavImagePath + this.oPreloadImages.aInternal[i] + '_rollover.gif';
			this.aImageCache.push( oImage );
			
			
			oImage = new Image;
			oImage.src = CDNRoot + this.sNavImagePath + this.oPreloadImages.aInternal[i] + '_selected.gif';
			this.aImageCache.push(oImage);
		}
		for( var i = 0; i < this.oPreloadImages.aExternal.length; i++ ) {		
			var oImage = new Image;
			oImage.src = CDNRoot + this.sNavImagePath + this.oPreloadImages.aExternal[i] + '_rollover.gif';
			this.aImageCache.push( oImage );
		}
		for( var i = 0; i < this.oPreloadImages.aOther.length; i++ ) {
			var oImage = new Image;			
			oImage.src = CDNRoot + '/media/_global/images/nav/' + this.oPreloadImages.aOther[i];
			this.aImageCache.push( oImage );
		}		
	},
	
	onNavMouse: function( e, eventType ) {
        if( e ) Event.stop(e);
	    var target = Event.findElement( e, 'img' );
		var sImageName = target.id.substring( 3, target.id.length ).toLowerCase();
		
		if( eventType == 'mouseover' ) {
			target.preImageSource = target.src;
			target.src = CDNRoot + this.sNavImagePath + sImageName + '_rollover.gif';
		}
		if( eventType == 'mouseout' ) {
			target.src = target.preImageSource || CDNRoot + this.sNavImagePath + sImageName + '_normal.gif';
			target.preImageSource = null;
		}

	},
	
	setNavSelected: function( aTarget, bIsSelected ) {
		var sImageName = aTarget.id.substring( 1, aTarget.id.length ).camelize();
		var target = $( 'img' + sImageName );
		if( target ) {
			target.src = bIsSelected ? CDNRoot + this.sNavImagePath + sImageName + '_selected.gif' : CDNRoot + this.sNavImagePath + sImageName + '_normal.gif';		
			target.preImageSource = target.src;		
		}
	},
	
	ieFlickerFix: function() {
		try { 
			document.execCommand( 'BackgroundImageCache', false, true ); 
		} catch(e) {} 
	},
	
	setupDropDownManager: function() {		
		new com.abc.nav.DropDownManager( this );
	},
	
	injectHTML: function(container,callback,url,transport) {
		if (!container) return;
		
		var text;
		
		try {
			text = transport.responseText;
			// strip out any <script> tags
			text.stripScripts();
		} catch (e) {
			this.loadFailure();
		}
		if( this.oDropDownManager ) 
			this.oDropDownManager.contentCache[url] = text;
		container.innerHTML = text;
		
		this.ieFlickerFix(); //fix lte IE6 Flicker
		if (callback && typeof(callback) == 'function'){
			callback();
		}
	},
	
	loadHTML: function( url,container,callback ) {
		if (!url || !container) return;
		url = this.cacheBuster( url );
		
		if (this.oDropDownManager && this.oDropDownManager.contentCache[url]) {
			container.innerHTML = this.oDropDownManager.contentCache[url];
			if (callback && typeof(callback) == 'function'){
				callback();
			}
		} else {
 			// load the html
			var request = new Ajax.Request(url,{ method: 'get', onSuccess: this.injectHTML.bind(this,container,callback,url), onFailure: this.loadFailure.bind(this) });
		}
	},

	loadFailure: function() {
		console.log('failed to load html');
	},
	
	cacheBuster: function( url ) {
		var iTTL = 300000;
		var sCacheBuster = 'ttl=';
		
		iTTL = parseInt( new Date().getTime() / iTTL );
		sCacheBuster += iTTL.toString();
		url = url.indexOf('?')!=-1 ? url+'&'+sCacheBuster : url+'?'+sCacheBuster;
		return url;
	},	
	
	getCookie: function( name ) {
		var start = document.cookie.indexOf( name + "=" );
		var len = start + name.length + 1;
		if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
			return null;
		}
		if ( start == -1 ) return null;
		var end = document.cookie.indexOf( ';', len );
		if ( end == -1 ) end = document.cookie.length;
		return unescape( document.cookie.substring( len, end ) );
 	},

	setCookie: function( name, value, expires, path, domain, secure ) {
		var today = new Date();
		today.setTime( today.getTime() );
		if( expires ) {
			expires = expires * 1000 * 60 * 60 * 24;
		}
		var expires_date = new Date( today.getTime() + (expires) );
		document.cookie = name+'='+escape( value ) +
			( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + 
			( ( path ) ? ';path=' + path : '' ) +
			( ( domain ) ? ';domain=' + domain : '' ) +
			( ( secure ) ? ';secure' : '' );
	},

	deleteCookie: function( name, path, domain ) {
		if( this.getCookie(name) )
			document.cookie = name + '=' +
				( ( path ) ? ';path=' + path : '') +
				( ( domain ) ? ';domain=' + domain : '' ) +
				';expires=Thu, 01-Jan-1970 00:00:01 GMT';
	},
		
	setupLogin: function( success, session, errors ) {
		this.nSignin = $( 'aSignin' );
		this.nUsername  = $( 'spanUsername' );
		var sUsername = this.getUsername();
		this.setLogIn();
		
		if( !this.nSignin || !this.nUsername || sUsername=='' ) return;
		this.setLogOut( sUsername );
	},
	
	getUsername: function() {
		var regCookie = this.getCookie('regCookie');
		var sUsername = '';

		if( regCookie ) {
			regCookie = regCookie.toQueryParams( ',' );
			if( regCookie.isLoggedIn && regCookie.username ) {
				sUsername = regCookie.username;
			}
		}
		return sUsername;
	},

	setLogIn: function() {
		this.nSignin.innerHTML = 'Sign in';
		this.nUsername.innerHTML = '';
		this.loggedInUser = '';
	},
	
	setLogOut: function( name ) {
		this.nSignin.innerHTML = 'Sign out'
		this.nUsername.innerHTML = 'Welcome ' + name + '!';
		this.loggedInUser = name;
	},
	
	logout: function() {
		/*
		for( var i=0; i<this.aCookiesToDelete.length; i++ ) {
			this.deleteCookie( this.aCookiesToDelete[i], '', 'go.com' );
		}
		if (callback && typeof(callback) == 'function') {
				callback();
		}
		*/
		window.location.href = this.sLogoutURL + encodeURIComponent(window.location.href);
	},
	
	//flash call this function to close dropdown and update login info
	loginCallback: function( success ) {
		if( success==true || success=='true' ) {
			Event.broadcast( window, 'userLoggedIn' );
			com.abc.nav.oDropDownManager.oOpenDropDown.close();
			com.abc.nav.setupLogin();
		} else {
			//TODO: handle login failed
			console.log( 'login failed... ');
		}
	},
	
	flashViewSchedule: function() {
		this.oDropDownManager.dropDownCache[0].contentURL = this.oDropDownManager.dropDownCache[0].oRequestURLs[ 'thisWeek' ];
		com.abc.DeepLink.setVariable( 'navTabId', 'thisWeek' );
		this.oDropDownManager.dropDownCache[0].open();
	},
	
	flashViewFall: function() {
		this.oDropDownManager.dropDownCache[0].contentURL = this.oDropDownManager.dropDownCache[0].oRequestURLs[ 'fall' ];
		com.abc.DeepLink.setVariable( 'navTabId', 'fall' );
		this.oDropDownManager.dropDownCache[0].open();
	},
	
	flashOpenLogin: function( regType, sweepstakesName, connectionName, connectionFunction ) {
		this.oDropDownManager.dropDownCache[4].connectionName = connectionName;
		this.oDropDownManager.dropDownCache[4].connectionFunction = connectionFunction;
		this.oDropDownManager.dropDownCache[4].regType = regType ? regType : 'lite';
		this.oDropDownManager.dropDownCache[4].sweepstakesName = sweepstakesName;
		
		this.oDropDownManager.dropDownCache[4].open();
	},
	
	flashCloseLogin: function( success ) {
		if( success==true || success=='true' ) {
			Event.broadcast( window, 'userLoggedIn' );
		}
		this.oDropDownManager.dropDownCache[4].close();
	}
};

Event.onDOMReady(com.abc.nav.setup.bind(com.abc.nav));

com.abc.nav.DropDownManager = new Class.create();
com.abc.nav.DropDownManager.prototype = {
	oOpenDropDown: null,
	dropDownCache: [],
	contentCache: [],
	
	initialize: function( base ){
		base.oDropDownManager = this;
		this.setupDropDowns();
		
		this.deeplink();
		Event.broadcast( window, 'navReady' );
	},
	
	setupDropDowns: function(){
		var oDropDown = null;
		
		oDropDown = new com.abc.nav.Schedule( 'dropDownContent', 'aWhatson', '/abc/ajax/nav/getSchedule?startDateOffset=0', null );
		this.dropDownCache.push(oDropDown);
				
		oDropDown = new com.abc.nav.Shows( 'dropDownContent', 'aShows', '/abc/ajax/nav/getShows', null );
		this.dropDownCache.push(oDropDown);
				
		oDropDown = new com.abc.nav.FEP( 'dropDownContent', 'aFullepisodes', '/abc/ajax/nav/getFEP', null );
		this.dropDownCache.push(oDropDown);
				
		oDropDown = new com.abc.nav.Community( 'dropDownContent', 'aCommunity', '/abc/ajax/nav/getCommunity', null );
		this.dropDownCache.push(oDropDown);
			
		oDropDown = new com.abc.nav.Signin( 'dropDownContent', 'aSignin', '/abc/ajax/nav/getSignIn', null );
		this.dropDownCache.push(oDropDown);
		com.abc.nav.setupLogin();
		
		console.log( this.dropDownCache );
	},
	
	deeplink: function() {
		if( navTabId = com.abc.DeepLink.getVariable('navTabId') ) {
			this.dropDownCache[0].contentURL = this.dropDownCache[0].oRequestURLs[ navTabId ];
			this.dropDownCache[0].open();
		}
	}
};

com.abc.nav.Base = function() {};
com.abc.nav.Base.prototype = {
	activator: null,
	contentURL: null,
	element: null,
	baseHeight: 0,
	nOnABCBox: null,
	
	initialize: function( element, activator, contentURL, options ){
		this.activator = $(activator);
		this.contentURL = contentURL;
		this.element = $(element);
		
		// default options
		this.options = {
			height: 250,
			duration: .2,
			setupDropdown: null
		}
		Object.extend( this.options, options || {} );
		
		Event.observe(this.activator, 'click', this.toggle.bindAsEventListener(this));
		Event.observe('aClose', 'click', this.close.bindAsEventListener(this));
		
		com.abc.nav.ieFlickerFix(); //fix lte IE6 Flicker
		this.baseHeight = this.element.parentNode.parentNode.offsetHeight || 0;
		this.element.parentNode.style.overflow = 'hidden';
		
		this.setup();
	},
	
	setup: function() {
		//console.log( 'setup in base class, should never show up....' );
	},
	
	toggle: function(e){
		if (typeof e != 'undefined') 
			Event.stop(e);
		
		if (com.abc.nav.oDropDownManager.oOpenDropDown === this) {
			this.close();
		}
		else {
			this.open();
		}
	},
	
	close: function(e){
		if (typeof e != 'undefined') 
			Event.stop(e);
		
		com.abc.nav.oDropDownManager.oOpenDropDown = null;
		new Effect.Morph(this.element.parentNode.parentNode, {
			style: 'height: ' + this.baseHeight + 'px',
			duration: this.options.duration,
			transition: Effect.Transitions.linear,
			afterFinish: this.clearContents.bind(this)
		});
		new Effect.Morph(this.element.parentNode, {
			style: 'margin-top: -' + this.options.height + 'px',
			duration: this.options.duration,
			transition: Effect.Transitions.linear
		});
		com.abc.nav.setNavSelected(this.activator, false);
	},
	
	open: function(){
		
		if (com.abc.nav.oDropDownManager.oOpenDropDown) 
			com.abc.nav.setNavSelected(com.abc.nav.oDropDownManager.oOpenDropDown.activator, false);
		
		com.abc.nav.oDropDownManager.oOpenDropDown = this;
		com.abc.nav.loadHTML( this.contentURL, this.element, this.ajaxCallback.bind(this) );
		
		new Effect.Morph(this.element.parentNode.parentNode, {
			style: 'height: ' + (this.baseHeight + this.options.height) + 'px',
			duration: this.options.duration,
			transition: Effect.Transitions.linear
		});
		new Effect.Morph(this.element.parentNode, {
			style: 'margin-top: 0; height: ' + this.options.height + 'px',
			duration: this.options.duration,
			transition: Effect.Transitions.linear
		});
		
		com.abc.nav.setNavSelected(this.activator, true);
		try { 
			com.abc.analytics.vendors.Omniture.logLink( {id:this.activator.id+'OnGlobalNav'} );
		} catch(e) {
			//console.log( e );
		} 
	},
	
	ajaxCallback: function(){
		//console.log('inside base class addCloseEvent');
	},
	
	clearContents: function(){
		this.element.innerHTML = '';
	}
};


com.abc.nav.Schedule = new Class.create();
Object.extend( Object.extend(com.abc.nav.Schedule.prototype, com.abc.nav.Base.prototype), {
	nScheduleBox: null,
	nTabContainer: null,
	oRequestURLs: {
		thisWeek: '/abc/ajax/nav/getSchedule?startDateOffset=0',
		nextWeek: '/abc/ajax/nav/getSchedule?startDateOffset=7',
		fall: '/abc/ajax/nav/getSchedule?startDateOffset=-1'
	},
	iPreviewTimer: 0,
	iTonightTimer: 0,
	
	setup: function() {
		//console.log( 'scheduel class setup' );
	},
	
	ajaxCallback: function(){
		this.nOnABCBox = $( 'onabc' );
		this.nScheduleBox = $( 'ulSchedule' );
		this.nTabContainer = $( 'ulFootTab' );
		
		var navTabId = com.abc.DeepLink.getVariable( 'navTabId' ) || 'thisWeek';
		Element.addClassName( $(navTabId), 'on' );
		Element.addClassName( this.nScheduleBox, navTabId );
		
	    var aNodeList = this.nScheduleBox.getElementsByTagName( 'a' );
	    //fixed for the js scope:
	    //aNodelist.each( function(){} ).bind(this) does not work in this version of prototype js
	    for( var i=0; i<aNodeList.length; i++ ) {
		    Event.observe( aNodeList[i], 'mouseover', this.onShowMouseover.bindAsEventListener(this) );
		    Event.observe( aNodeList[i], 'mouseout', this.onShowMouseout.bindAsEventListener(this) );
	    }
        Event.observe( this.nScheduleBox, 'mouseout', this.onMainMouseout.bindAsEventListener(this) );
		
	    aNodeList = this.nTabContainer.getElementsByTagName( 'a' );
	    for( var i=0; i<aNodeList.length; i++ ) {
		    Event.observe( aNodeList[i], 'click', this.onTabClick.bindAsEventListener(this) );
	    }
	},
	
	onShowMouseover: function( e ) {
	    if( e ) Event.stop(e);
        var target = Event.findElement( e, 'a' );
		
        //delay mouseover event
        if( this.iPreviewTimer )
            clearTimeout( this.iPreviewTimer );
        this.iPreviewTimer = setTimeout( this.loadShowDetails.bind(this, target), '200' );
	},
	
	onShowMouseout: function( e ) {
        var target = Event.findElement( e, 'a' );
        var aNodeList = document.getElementsByClassName( 'rollover', target.parentNode );
        for( var i=0; i<aNodeList.length; i++ ) {
            target.parentNode.removeChild( aNodeList[i] );
        }
	},
	
	onMainMouseout: function() {
        if( this.iPreviewTimer )
            clearTimeout( this.iPreviewTimer );
        if( this.iTonightTimer )
            clearTimeout( this.iTonightTimer );			
		this.iTonightTimer = setTimeout( this.loadTonightDetails.bind(this), '3000' );
	},
	
	loadShowDetails: function( target ) {
	    if( target.hasClassName('newIcon') )
	        this.createRollover( target );
		
        $A( document.getElementsByClassName( 'wrapper', this.nOnABCBox ) ).invoke( 'hide' );
        $( 'showWrapper' + target.id ).show();
		
        if( this.iTonightTimer )
            clearTimeout( this.iTonightTimer );
	},
	
	loadTonightDetails: function() {
        $A( document.getElementsByClassName( 'wrapper', this.nOnABCBox ) ).invoke( 'hide' );
		var tonight = $( 'tonight' );
		if( tonight )
	        tonight.show();
	},
	
	createRollover: function( target ) {
		if( !target ) return false;
		
        var rollover = null;
        var slotWidth = target.getWidth();
        var slotLeft = parseInt( target.getStyle('left') );
        
	    //create rollover span
	    obj = document.createElement( 'span' );
	    obj.className = 'rollover';

	    obj.style.bottom = '0';
	    obj.style.left = slotWidth + slotLeft + 'px';
	    obj.appendChild( document.createTextNode(target.name) );
	    target.parentNode.appendChild( obj );
	},
	
	onTabClick: function( e ) {
	    if( e ) Event.stop(e);
        var target = Event.findElement( e, 'li' );
		
		com.abc.DeepLink.setVariable( 'navTabId', target.id );
		com.abc.nav.loadHTML( this.oRequestURLs[target.id], this.element, this.ajaxCallback.bind(this) );
	}

});

com.abc.nav.Sub = new Class.create();
Object.extend( Object.extend(com.abc.nav.Sub.prototype, com.abc.nav.Base.prototype), {
	sSubNavImagePath: '/media/_global/images/nav/shows/',
	oSubs: {
		aIds: $w( 'Primetime Daytime Original Movie' ),
		aImages: [],
		aContent: []
	},
	aImageCache: [],
	iCurrentSubId: 0,
	
	setup: function() {
	},
	
	ajaxCallback: function() {
		this.oSubs.aImages = this.oSubs.aIds.collect( function(item) {
			return 'img' + item;
		});
		this.oSubs.aContent = this.oSubs.aIds.collect( function(item) {
			return $( 'divWrapper' + item );
		});
		
		this.iCurrentSubId = 0;
		$( this.oSubs.aImages[0] ).src = CDNRoot + this.sSubNavImagePath + this.oSubs.aIds[0].toLowerCase() + '_selected.gif';
		$( this.oSubs.aImages[0] ).preImageSource = $( this.oSubs.aImages[0] ).src;		
		
	    for( var i=0; i<this.oSubs.aIds.length; i++ ) {		
			var oImage = new Image;
			oImage.src = CDNRoot + this.sSubNavImagePath + this.oSubs.aIds[i].toLowerCase() + '_rollover.gif';
			this.aImageCache.push( oImage );
			oImage.src = CDNRoot + this.sSubNavImagePath + this.oSubs.aIds[i].toLowerCase() + '_selected.gif';
			this.aImageCache.push(oImage);	
			
		    Event.observe( this.oSubs.aImages[i], 'mouseover', this.onNavMouse.bindAsEventListener(this, 'mouseover') );
		    Event.observe( this.oSubs.aImages[i], 'mouseout', this.onNavMouse.bindAsEventListener(this, 'mouseout') );
		    Event.observe( this.oSubs.aImages[i], 'click', this.onSubClick.bindAsEventListener(this) );
	    }

	},
	
	onNavMouse: function( e, eventType ) {
		if( e ) Event.stop(e);
		var target = Event.findElement(e, 'img');
		var iSubId = this.oSubs.aImages.indexOf( target.id );
		
		if (eventType == 'mouseover') {
			target.preImageSource = target.src;
			target.src = CDNRoot + this.sSubNavImagePath + this.oSubs.aIds[ iSubId ] + '_rollover.gif';
		}
		if (eventType == 'mouseout') {
			target.src = target.preImageSource || CDNRoot + this.sSubNavImagePath + this.oSubs.aIds[ iSubId ] + '_normal.gif';
			target.preImageSource = null;
		}
	},
	
	onSubClick: function( e ) {
		if( e ) Event.stop(e);
		var target = Event.findElement(e, 'img');
		var oCurrentSub = $( this.oSubs.aImages[this.iCurrentSubId] );
		
		oCurrentSub.src = CDNRoot + this.sSubNavImagePath + this.oSubs.aIds[ this.iCurrentSubId ].toLowerCase() + '_normal.gif';
		oCurrentSub.preImageSource = oCurrentSub.src;
		
		this.iCurrentSubId = this.oSubs.aImages.indexOf( target.id );
		target.src = CDNRoot + this.sSubNavImagePath + this.oSubs.aIds[ this.iCurrentSubId ].toLowerCase() + '_selected.gif';
		target.preImageSource = target.src;
		
		this.loadSubContent();
	},
	
	loadSubContent: function() {
		this.oSubs.aContent.invoke( 'hide' );
		$( this.oSubs.aContent[this.iCurrentSubId] ).show();
	}
	
});

com.abc.nav.Shows = new Class.create();
Object.extend( Object.extend(com.abc.nav.Shows.prototype, com.abc.nav.Sub.prototype), {

});

com.abc.nav.FEP = new Class.create();
Object.extend( Object.extend(com.abc.nav.FEP.prototype, com.abc.nav.Base.prototype), {
	ajaxCallback: function() {
	}
});

com.abc.nav.Community = new Class.create();
Object.extend( Object.extend(com.abc.nav.Community.prototype, com.abc.nav.Sub.prototype), {
	sSubNavImagePath: '/media/_global/images/nav/community/',
	oSubs: {
		aIds: $w( 'Blogs MB Widgets Games' ),
		aImages: [],
		aContent: []
	}
});

com.abc.nav.Signin = new Class.create();
Object.extend( Object.extend(com.abc.nav.Signin.prototype, com.abc.nav.Base.prototype), {
	regType: 'lite',
	connectionName: '',
	connectionFunction: '',
	sweepstakesName: '',
	
	toggle: function(e){
		if (typeof e != 'undefined') 
			Event.stop(e);
		
		if( com.abc.nav.oDropDownManager.oOpenDropDown === this ) {
			this.close();
		} else if( com.abc.nav.loggedInUser == '' ) {
			this.open();
		} else {
			//com.abc.User.logout( com.abc.nav.setLogIn.bind(com.abc.nav) );
			com.abc.nav.logout();
		}
	},
	
	ajaxCallback: function() {
		console.log('reg type:' + this.regType);
		console.log('connectionName: ' + this.connectionName);
		console.log('connectionFunction: ' + this.connectionFunction);
		var bRegIsPreview = CDNRoot.indexOf('abcpreview')!=-1;
		var FP = { id: "registration_swf",
			movie: CDNRoot + "/media/_global/swf/registration/registration.swf?v2.0",
			width: "740", height: "200", majorversion: "9", build: "0", wmode: "transparent", majorversion: "9", allowscriptaccess: "always",
			flashvars: "regType=" + this.regType + "&sweepstakesName=" + this.sweepstakesName + "&connectionName=" + this.connectionName + "&connectionFunction=" + this.connectionFunction + "&isPreview=" + bRegIsPreview };
		UFO.create(FP,"divReg");
	}
});
