 var viewportwidth;
 var viewportheight;
 
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }
 
/**
 * Returns a random integer between min and max
 * Using Math.round() will give you a non-uniform distribution!
 */
function getRandomInt (min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
}
 

function Display(div)
{
	//declare the variables
	var targetDiv = document.getElementById(div);
	
	//get random x and y positions within the range of the viewport.
	var x_position = getRandomInt(0, (viewportwidth));
	var y_position = getRandomInt(0, (viewportheight));
	
	if (x_position > 50 && x_position<=500) {
	    x_position = 100;


	}
	if (x_position > 500 && x_position<900) {
	    x_position = 900;


	}
	if (y_position > 100&& y_position<=200) {
	    y_position = 100;
	}
	if (y_position > 200 && y_position<400) {
	    y_position = 400;
	}
	//assign the new positions to the left and top attributes 
	targetDiv.style.top = y_position + "px";
	targetDiv.style.left = x_position + "px";

	//make the target visible
	targetDiv.style.display = "";
	
}

function GenerateRandomNumber(div_name)
{
	//1 generate a random number
	
	var ran_unrounded=Math.random()*10;
	var ran_number=Math.floor(ran_unrounded/3);

	//2 check to see if it is divisible by 10
	if ($("#defaultpage").attr("value")=="default") {

	    if (ran_number == 2) {
	        this.Display(div_name);
	    }
	    //	else {
	    //	    document.getElementById(div_name).style.display = "none";
	    //	}
	}
	else {
	    document.getElementById(div_name).style.display = "none";
	}
}