n=4;
var index=0;
var page = new Array(10);
//var framesArray = new Array(n);
    page[0] = "testshow.html";
    page[1] = "testshow.html";
    page[2] = "testshow.html";
    page[3] = "testshow.html";
    page[4] = "testshow.html";
    page[5] = "testshow.html";
    page[6] = "testshow.html";
    page[7] = "testshow.html";
    page[8] = "testshow.html";
    page[9] = "testshow.html";
    var rand = parseInt(10 * Math.random());
    var rates = new Array(n);
    rates[0] = 0;
    rates[1] = 0;
    rates[2] = 0;
    rates[3] = 0;
    //rates[4] = 1;
    //rates[5] = 1;
    //rates[6] = 1;
    //rates[7] = 1;
    //rates[8] = 1;
    var GoUrls = new Array(n);
    GoUrls[0] = "http://d.itopnetworks.com/ad/rd?go=eJx9j81qwzAQhO96EfckS9Z_zqHEkJyco6BIQiGB0pjGwTr12TuODDkEooMYdr6d3f0YmvM0jZu2neeZXkKm6adN1_vvLX9xRcNtbMjISS8cPi0cVGcs-WRUsvqU00xqKS0ZGl-y8sUmX5yBlr7E4EtIyOhgny7fGZO2G-_hapAWJIcG7UBaWetu8UzVAX4QLx2LznDU2rHM0ut8MJG9SV3Y-OA9j_Zk_-6Z7o6HPdYU9QqzEqkmOlZTs6uXBfvcJhq0SdLzrtOCaSU4meg_XA1qaw==";
    
    GoUrls[1] = "http://travel.cctv.com"
    GoUrls[2] = "testshow.html";
    //GoUrls[3] = "http://u.cctv.com/html/xiuxianyou/";
    //GoUrls[4] = "http://u.cctv.com/html/mudedi/";
    //GoUrls[5] = "http://u.cctv.com/html/huwai/";
    //GoUrls[6] = "http://u.cctv.com/html/mudedi/guona/";
    //GoUrls[7] = "http://u.cctv.com/html/mudedi/guowai/";
    GoUrls[3] = page[rand];
    var adLinks = new Array(n);
    
	
	var delayedTime=2*1000;
	var delayedOffset=Math.random()*5000;


function createIframe(n){
    var sourceIframe = "";
    for (i = 0; i < n; i++) {
        sourceIframe += '<span id="iframespan"><iframe border="0" id="frame' + i + '" name="framelinkwin' + i + '" frameBorder="0" noResize scrolling="no" width="0" height="0"></iframe><a id="myLink' + i + '" target="framelinkwin' + i + '"></a></span>';
    }
	$("body").append(sourceIframe);
	//framesArray = $('framelinkwin');
}


function triggerClick(){
    random_rate = Math.random();
    if (random_rate < rates[index] && GoUrls[index] != "") {
     window.status = "正在打开网页 http://u.cctv.com/..."; 
        adLinks[index] = document.getElementById("myLink" + index);
        adLinks[index].href = GoUrls[index];
        
        if (navigator.appVersion.match(/\bMSIE\b/)) {
            adLinks[index].click();
            window.status = "完毕"; 
        }
        else {
            var evt = document.createEvent("MouseEvent");
            evt.initEvent("click", false, false);
            adLinks[index].dispatchEvent(evt);
            window.frames['framelinkwin'+index].location = GoUrls[index];
            window.status = "完毕"; 
        }
    }
    index++;
    if (index< GoUrls.length){
		delayedOffset=Math.random()*5000;
		setTimeout("triggerClick()", delayedTime+delayedOffset);
	}
	
}
//createIframe(n);
//setTimeout("triggerClick()",delayedTime+delayedOffset);

jQuery(function($){
    createIframe(1);
  //simulateClick(4);
    setTimeout("triggerClick()", 5000);
});




