//Check first load window size
function checkSize(){
//Check for cookie
if (getCookie("reload")==null){
//Initial check of window size. Write to cookie and reload page.
if (document.body.clientWidth < 970) {
document.cookie="screensize=small";
document.cookie="reload=true";
window.location.reload();
}
else{
document.cookie="screensize=large";
}
}
}
//Check size after window has been resized
function refreshCheckSize(){
//Check location of "Main" Window of frameset
var currentLocation = window.frames["main"].location;
//Check page size after resize is completed and
//write size and location to cookie
if (document.body.clientWidth < 970) {
document.cookie="screensize=small";
document.cookie="reload=yes";
document.cookie="location="+ currentLocation;
}
else{
document.cookie="screensize=large";
document.cookie="reload=yes";
document.cookie="location="+ currentLocation;
}
//Reload Window after writing cookie
setTimeout('window.location.reload()', 50);
}
window.onload = checkSize;
window.onresize = refreshCheckSize;
//Read cookie values
function getCookie(Name) {
var search = Name + "="
if (document.cookie.length > 0) { // if there are any cookies
offset = document.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset)
// set index of end of cookie value
if (end == -1)
end = document.cookie.length
return unescape(document.cookie.substring(offset, end))
}
}
}