/*
	tarot.inc (replaces reading_options.js)
	file for ftns that opens up new windows in the tarot reading section
	email, print, journal, etc.
	be sure that new_window.js has already been included...
*/


    function newSmWindow( file, w, h, t, l, winName ) {
                if( !t ) var t = 10;
                if( !l ) var l = 10;
                if( !w ) var w = 350;
                if( !h ) var h = 300;
                if( !winName ) var winName = "newWindow";

                newWin =  _proxy_jslib_handle(window, 'open', '', 1, 0)( file, winName, 'scrollbars=1,resizable=1,top='+ t +',left='+ l +',height='+ h +',width='+ w);
                newWin.focus();
                if ( _proxy_jslib_handle(newWin, 'opener', '', 0, 0) == null)  _proxy_jslib_assign('', newWin, 'opener', '=', ( self));
    }


	function goToPage(form_name, pagename) {
		 _proxy_jslib_assign('',  _proxy_jslib_handle(document, (form_name), 0, 0), 'action', '=', ( pagename));
		 _proxy_jslib_handle(document, (form_name), 0, 0).submit();
	}	

	function goPosition(num, objForm, formAction, type ) {
		 _proxy_jslib_assign('', objForm.position, 'value', '=', ( num));
		if( formAction )	 _proxy_jslib_assign('', objForm, 'action', '=', ( formAction));
		if( type )	 _proxy_jslib_assign('', objForm.reading_type, 'value', '=', ( type));
		objForm.submit();
	}


	function deleter( readingId, shared, loggedIn ) {
		if( !loggedIn || shared )
			alert("This option is available only to logged in Tarot.com members with this reading saved in their journal.");
		else{
			if( confirm_delete() ){
				 _proxy_jslib_assign('', window, 'location', '=', ( "/tarot/saved.php?reading_ID=" + readingId + "&delete=yes&confirm=yes"));
		    }
			//refresh the page
		}
	}
	
	function confirm_delete() {
		var message = "You have chosen to delete your Expert reading. This action cannot be undone.  Do you wish to continue?";
		if(confirm(message)){
			return true;
		}
		else{
			return false;
		}
	}

	function spreadInfo( spreadNo, large ) {
		var file = "/tarot/features.php?file=spread-info&long=1";
		if(spreadNo)
			file += "&spreadNo=" + spreadNo;
		if(large)
			file += "&large=1";

		newSmWindow( file, 450, 380, 0, 0, 'MoreInfo' );
	}

	function questionInfo( qKey, large ) {
		var file = "/tarot/features.php?file=";
		if(qKey == "valid")
			file += "question&long=1";
		else if(qKey == "sample")
			file += "sample&long=1";
                else if(qKey == "kcs")
                    file += "kcs";
                else if(qKey == "cosmic_vault")
                    file += "cosmic_vault";
                
		if(large)
			file += "&large=1";

		newSmWindow( file, 450, 380, 0, 0, 'MoreInfo' );
	}

	function select( question ) {
		var file = "/tarot/features.php?file=" + question;
		newSmWindow( file, 450, 380, 0, 0, 'MoreInfo' );
	}

	function question() {
		var file = "/tarot/features.php?file=question";
		newSmWindow( file, 450, 380, 0, 0, 'PhraseQuestion' );
	}
	
        function copyright( deck, usgames_id ) {            
            file = ( usgames_id > 0 ) ? "/tarot/copyright.php?dname=" + deck + "&popup=1&usgames_id="+usgames_id : "/tarot/copyright.php?dname=" + deck + "&popup=1";
            newSmWindow( file, 450, 380, 0, 0, 'DeckCopyright' );
       }

    function imgChange(id, imgSrc) {
         _proxy_jslib_assign('',  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(id), 'src', '=', ( imgSrc));
    }
 ;
_proxy_jslib_flush_write_buffers() ;