<script type="text/javascript" charset="utf-8">
// JQUERY WAY TO PRELOAD IMAGES
// DOES NOT NEED TO BE IN DOCUMENT READY
$.preloadImages = function()
{
for(var i = 0; i<arguments.length; i++)
{
img = new Image();
img.src = arguments[i];
}
}
$.preloadImages(
"path/to/image/1",
"path/to/image/2",
"path/to/image/3"
);
</script>
// this script have dependencies on prototype-1.4.0.js and Browser Detect Lite v2.1
// http://prototype.conio.net/
// http://www.dithered.com/javascript/browser_detect/index.html
// (cc) alvaro isorna
Event.observe(window, 'load', function(){
// this will iterate with each element with the class 'ie-fix-opacity' and add an IE filter,
// replacing the background-image for the filter of that image
document.getElementsByClassName('ie-fix-opacity').each(function(poElement){
// if IE5.5+ on win32, then display PNGs with AlphaImageLoader
if ((browser.isIE55 || browser.isIE6up) && browser.isWin32){
var cBGImg = poElement.currentStyle.backgroundImage;
var cImage = cBGImg.substring(cBGImg.indexOf('"') + 1, cBGImg.lastIndexOf('"'));
poElement.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + cImage + "', sizingMethod='scale')";
poElement.style.backgroundImage = "none";
}
});
}, false);
/**
* Sets a Cookie with the given name and value.
*
* name Name of the cookie
* value Value of the cookie
* [expires] Expiration date of the cookie (default: end of current session)
* [path] Path where the cookie is valid (default: path of calling document)
* [domain] Domain where the cookie is valid
* (default: domain of calling document)
* [secure] Boolean value indicating if the cookie transmission requires a
* secure transmission
*/
function setCookie(name, value, expires, path, domain, secure) {
document.cookie= name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
/**
* Gets the value of the specified cookie.
*
* name Name of the desired cookie.
*
* Returns a string containing value of specified cookie,
* or null if cookie does not exist.
*/
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));
}
/**
* Deletes the specified cookie.
*
* name name of the cookie
* [path] path of the cookie (must be same as path used to create cookie)
* [domain] domain of the cookie (must be same as domain used to create cookie)
*/
function deleteCookie(name, path, domain) {
if (getCookie(name)) {
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}
// ----------------------------------------
// Wrapper function for constructing a request object.
// Parameters:
// reqType: The HTTP request type, such as GET or POST.
// url: The URL of the server program.
// asynch: Whether to send the request asynchronously or not.
// ----------------------------------------
function httpRequest(reqType,url,asynch) {
// Mozilla-based browsers
if (window.XMLHttpRequest) {
request = new XMLHttpRequest();
} else if (window.ActiveXObject) {
request = new ActiveXObject("Msxml2.XMLHTTP");
if (!request) {
request = new ActiveXObject("Microsoft.XMLHTTP");
}
}
// Request could still be null if neither ActiveXObject
// initialization succeeded
if (request) {
// If the reqType param is POST, then the fifth arg is the POSTed data
if (reqType.toLowerCase() != "post") {
initReq(reqType, url, asynch, respHandle);
} else {
// The POSTed data
var args = arguments[4];
if (args != null && args.length > 0) {
initReq(reqType, url, asynch, respHandle, args);
}
}
} else {
alert("Your browser does not permit the use of all " +
"of this application's features!");
}
}
// ----------------------------------------
// Initialize a request object that is already constructed
// ----------------------------------------
function initReq(reqType, url, bool, respHandle) {
try {
// Specify the function that will handle the HTTP response
request.onreadystatechange = handleResponse;
request.open(reqType, url, bool);
// If the reqType param is POST, then the
// fifth argument to the function is the POSTed data
if (reqType.toLowerCase() == "post") {
// Set the Content-Type header for a POST request
request.setRequestHeader("Content-Type", "application/x-ww-form-urlencoded; charset=UTF-8");
request.send(arguments[4]);
} else {
request.send(null);
}
} catch (errv) {
alert("The application cannot contact the server at the moment. " +
"Please try again in a few seconds.\n" +
"Error detail: " errv.message);
}
}
// Check if the browser understands the video element.
function understands_video() {
return !!document.createElement('video').canPlayType; // boolean
}
if ( !understands_video() ) {
// Must be older browser or IE.
// Maybe do something like hide custom
// HTML5 controls. Or whatever...
videoControls.style.display = 'none';
}