//popup
function popUp(URL)
{
    var day = new Date();
    var id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=yes,width=450,height=460,left=212,top=184');");
} 

function popUp2(URL)
{
    var day = new Date();
    var id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=yes,width=600,height=470,left=212,top=184');");
} 

function popUp3(URL)
{
    var day = new Date();
    var id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=yes,width=400,height=470,left=212,top=184');");
} 

//resize wit n wisdom flash to correct height
function setFlashQuotesHeight(flashQuotesHeight) {		
	var flashQuotesElement = document.getElementById('flashQuotes'); 
	flashQuotesElement.style.height = flashQuotesHeight + 'px';
	//alert(flashQuotesHeight);
} 


//validate reg form
function CheckRegForm() {
	// The fields are checked for blanks
	if (document.pform.firstname.value   == "" ||
	    document.pform.lastname.value   == "" ||
	    document.pform.postcode.value  == "" ||
	    document.pform.Email.value  == "" ) {
	    	alert( "You haven't completed the form.\nPlease ensure that all boxes are filled in.");
		}
		
	// check for valid email address
	else if (document.pform.Email.value.length <= 6 ||
      		 document.pform.Email.value.indexOf ('@', 0) == -1 ||
      		 document.pform.Email.value.indexOf ('.', 0) == -1){
				 alert("Sorry, " + document.pform.Email.value + " is not a valid Email Address.");  
			 }
  	else { 
 		document.pform.submit()
	}
}

//validate reader reviews form
function CheckReaderReviewForm() {
	// The fields are checked for blanks
	if (document.pform.firstname.value   == "" ||
	    document.pform.lastname.value   == "" ||
		document.pform.book-title.value   == "" ||
		document.pform.review.value   == "" ||
	    document.pform.postcode.value  == "" ||
	    document.pform.Email.value  == "" ) {
	    	alert( "You haven't completed the form.\nPlease ensure that all boxes are filled in.");
		}
		
	// check for valid email address
	else if (document.pform.Email.value.length <= 6 ||
      		 document.pform.Email.value.indexOf ('@', 0) == -1 ||
      		 document.pform.Email.value.indexOf ('.', 0) == -1){
				 alert("Sorry, " + document.pform.Email.value + " is not a valid Email Address.");  
			 }
  	else { 
 		document.pform.submit()
	}
}


// *********************************************************
// * Communication to Flash
// ********************************************************* 
function callFlash(p_sFunction)
{
    var oFlashMovie = document.getElementById("header_swf");
    
    switch (p_sFunction)
    {
        case "showBooks":
            oFlashMovie.flashShowBooks();
            break;
        case "hideBooks":
            oFlashMovie.flashHideBooks();
            break;
    }
}

// *********************************************************
// * Change size of flash div
// *********************************************************
function changeFlashSize(p_nSize)
{
    // Safari 1.3 can't handle fading the content in again, for some unknown reason
    // so this code checks to see if user is running safari, if so, then make elements just appear,
    // and not fade them in.  Safari 3+ works fine, though.
    var sAgent = navigator.userAgent.toLowerCase();
    if (sAgent.indexOf(' applewebkit/')!= -1)
    {
        var oFlashDiv = document.getElementById("flash_container");
        oFlashDiv.style.height = p_nSize + 'px';

        // Build must be at least 522 (v3)
        if (sAgent.match( / applewebkit\/(\d+)/ )[1] >= 522 )
        {
            // this conditition is for browsers other than OLD Safaris, less than version 3 (i.e all the original mac only ones)
        } 
        else
        {

        }
    }
    else
    {
        // this conditition is for browsers other than Safari
    } 

    $("#flash_container").animate({ height: (p_nSize + 'px') }, 500 );

}  
