/*
	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 = window.open( file, winName, 'scrollbars=1,resizable=1,top='+ t +',left='+ l +',height='+ h +',width='+ w);
                newWin.focus();
                if (newWin.opener == null) newWin.opener = self;
    }


	function goToPage(form_name, pagename){
		document[form_name].action = pagename;
		document[form_name].submit();
	}	

	function goPosition(num, objForm, formAction, type ){
		objForm.position.value = num;
		if( formAction )	objForm.action = formAction;
		if( type )	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() ){
				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) {
        document.getElementById(id).src = imgSrc;
    }
