home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
developer.apple.com
/
developer.apple.com.tar
/
developer.apple.com
/
js
/
adc.js
next >
Wrap
Text File
|
2009-11-09
|
6KB
|
195 lines
<!--
function visByClass(className, state)
{
if (document.getElementsByTagName) { //check for obj
var nodes = document.getElementsByTagName("DIV");
for (var i = 0;i < nodes.length;i++) {
var nodeObj = nodes.item(i);
var attrMax = nodeObj.attributes.length
for (var j = 0; j < attrMax; j++) {
if (nodeObj.attributes.item(j).nodeName == 'class') {
if (nodeObj.attributes.item(j).nodeValue == className) {
vista = (state) ? 'block' : 'none';
nodeObj.style.display = vista;
}
}
}
}
}
var nodes = document.getElementsByTagName("SPAN");
var max = nodes.length
for (var i = 0;i < max;i++) {
var nodeObj = nodes.item(i);
for (var j = 0; j < nodeObj.attributes.length; j++) {
if (nodeObj.attributes.item(j).nodeName == 'class') {
if (nodeObj.attributes.item(j).nodeValue == className) {
vista = (state) ? 'block' : 'none';
nodeObj.style.display = vista;
}
}
}
}
}
// Modify the display state of the CSS style with the given class name
var foundStylesheet;
function visByClass2(className, state)
{
var stylesheets = document.styleSheets;
if( stylesheets && stylesheets.length > 0 ) {
// Safari sometimes fails to return any stylesheets here when called
// before the page finishes loading. Flag that we did find a style sheet
// so that we can tell if we should repeat the test after the page loads.
foundStylesheet = 1;
var rules = stylesheets[0].cssRules;
if( rules == null ) {
// IE6/Win uses rules, not cssRules to get style sheet rules
rules = stylesheets[0].rules;
}
for( var i=0; i < rules.length; i++ ) {
if( rules[i].selectorText.indexOf( className ) != -1 ) {
var style = rules[i].style;
vista = (state) ? 'block' : 'none';
style.display = vista;
return;
}
}
} else {
// Falling back to old code
visByClass(className, state);
}
}
// Pop A Window
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
// Redirect user with the item selected with a drop-down menu
function redirect(categoryName, selectedItem)
{
//window.location.href = "http://www.apple.com";
//alert(categoryName);
var q = selectedItem.indexOf("WONoSelectionString");
//alert(q);
if ( q == 0 ) {
//user selected the first item, so take them back to the page listing all docs
//you have to somehow pass in the name of the category
//alert("../" + categoryName + "/" + categoryName + "-date.html");
window.location.href = "../" + categoryName + "/" + categoryName + "-date.html";
} else {
window.location.href = selectedItem;
}
}
function busNav(newPage,defaultIndex) {
newLoc = newPage.options[newPage.selectedIndex].value
if (newLoc != "") {
window.location.href = newLoc;
}
if( typeof defaultIndex != "undefined" && defaultIndex >= 0 ) {
newPage.selectedIndex = defaultIndex;
}
}
// Check whether the descriptions should be hidden based on a cookie
function testDescriptionFlag() {
var value = getCookie("RefLib_Descriptions");
if( value && value == 'off' ) {
// The default setting is to show descriptions, so we only need to
// act if the cookie is set to 'off'
hideDescriptions(0);
}
}
// If we failed to find any stylesheet while the page was loading, repeat the test
function retestDescriptionFlag() {
if( foundStylesheet ) {
return;
}
testDescriptionFlag();
}
// Turn on the descriptions. If the needCookie flag is true, set a cookie
// to remember this flag.
function showDescriptions( needCookie ) {
visByClass2("description", 1);
if( needCookie ) {
// Set expiration date to 20 years in the future
// (Maximum date is ~2038)
var expires = new Date();
expires.setTime( expires.getTime() + 1000*60*60*24*365*20 );
setCookie('RefLib_Descriptions', 'on', expires, '/');
}
var onButton = document.getElementById( 'DescriptionsOn' );
if( onButton ) {
onButton.checked = 1;
}
}
// Turn off the descriptions. If the needCookie flag is true, set a cookie
// to remember this flag.
function hideDescriptions( needCookie ) {
visByClass2("description", 0);
if( needCookie ) {
// Set expiration date to 20 years in the future
// (Maximum date is ~2038)
var expires = new Date();
expires.setTime( expires.getTime() + 1000*60*60*24*365*20 );
setCookie('RefLib_Descriptions', 'off', expires, '/');
}
var offButton = document.getElementById( 'DescriptionsOff' );
if( offButton ) {
offButton.checked = 1;
}
}
// Get a cookie
// Code from: http://www.webreference.com/js/column8/functions.html
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else {
begin += 2;
}
var end = document.cookie.indexOf(";", begin);
if (end == -1) {
end = dc.length;
}
return unescape(dc.substring(begin + prefix.length, end));
}
// Set a cookie
// Code from: http://www.webreference.com/js/column8/functions.html
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
document.cookie = curCookie;
}
//Javascript add 2006-03-09
function closeWatermark() {
if(document.all){
watermark.style.visibility = "hidden";
} else if(document.layers) {
document.watermark.visibility = "hidden";
} else if(document.getElementById && !document.all) {
document.getElementById("watermark").style.visibility = "hidden";
}
}
//-->