// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
//
//	BEGIN MODULE WHATSNEW SLIDE ROTATION
//

// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor revision of Flash required
var requiredRevision = 0;
// -----------------------------------------------------------------------------


//
//  array of share links for the facebook share functionality... position 0 is for 1st slide, 1 for the 2nd slide, etc...
//
var activeSlideLink = ['http://www.apple.com/go/backtoschool08', 'http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewAlbum?i=281212742&amp;id=281212736&amp;s=143441'];

//
//
//	BEGIN MODULE HEADLINE NEWS
//
var INTheadlines;
var INTheadlinesOpacity;
var iHeadlineCounter = 1;
var iTotalNumberHeadlines = 4;
var boolIsContinuing = false;

// here start running the outer timer, every 6 seconds it cycles between headlines, then calls a quick timer to quickly fade in
INTheadlines = setInterval(advanceHeadlines, 5000);

function advanceHeadlines() {
	
    /// current is iHeadlineCounter
    iHeadlineCounter++;

    if (iHeadlineCounter > iTotalNumberHeadlines && boolIsContinuing == false) {
        //continuemoreheadlines
        $('continuemoreheadlines').show();
        $('headlineblurb' + (iHeadlineCounter-1)).hide();
        //document.getElementById('headlineblurb' + (iHeadlineCounter-1)).visibility = 'hidden';
        clearInterval(INTheadlines);
        return;
    } else if (iHeadlineCounter > iTotalNumberHeadlines && boolIsContinuing == true) {
        iHeadlineCounter = 1;
    }

    for (ii = 1; ii <= iTotalNumberHeadlines; ii++) {
		if (ii == iHeadlineCounter) {
			$('headlineblurb' + ii).show();
			$('headlineblurb' + (ii-1)).hide();
		}
   	}

	new Effect.Opacity('headlineblurb' + iHeadlineCounter, { from: 0, to: 1, duration: 1.0 });
    //iOpacity = 0;

    //$('headlineblurb' + iHeadlineCounter).style.opacity = iOpacity;
    // now we have reset everything into right position set our current hightlight to OPACITY nothing, run timer to increase it to good...
    //clearInterval(INTheadlinesOpacity);
    //INTheadlinesOpacity = setInterval(increaseHiehglightedOpacity, 60);
}
//
//	END MODULE HEADLINE NEWS
//

function alertContents() {
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('myspan').innerHTML = result;
        } else {
            alert('There was a problem with the request.');
        }
    }
}

function getInfo() {
    document.getElementById('search_throbber').src = '/images/searchbox_spinner.gif?f=$stamp';

    resetThumbToZero();
    // make sure thumb is in right position...
    boolHasMadeARequest = true;

    var getUrl = 'interimmer.php?term=' + encodeURIComponent(document.getElementById('searchbox').value);

    var xhr = false;
    if (window.XMLHttpRequest) {
        // Mozilla, Safari,...
        xhr = new XMLHttpRequest();
        if (xhr.overrideMimeType) {
            // set type accordingly to anticipated content type
            xhr.overrideMimeType('text/html');
        }
    } else if (window.ActiveXObject) {
        // IE
        try {
            xhr = new ActiveXObject("Msxml2.XMLHTTP");
        } catch(e) {
            try {
                xhr = new ActiveXObject("Microsoft.XMLHTTP");
            } catch(e) {}
        }
    }
    if (!xhr) {
        alert('Cannot create XMLHTTP instance');
        return false;
    }

    xhr.onreadystatechange = function() {
        if (xhr.readyState == 4) {
            if (xhr.status == 200) {
                //				alert(xhr.responseText);
                document.getElementById('searchResultsInnerContainer').innerHTML = xhr.responseText;
                document.getElementById('search_throbber').src = '/images/searchbox_close.gif?f=$stamp';
            } else {
                alert('Cannot retrieve XMLHTTP data');
            }
        }
    }

    xhr.open('GET', getUrl, true);
    xhr.send(null);

}


//
// END MODULE iTUNES
//