if (!window.CBCG)
	window.CBCG = {};

CBCG.Page = function() 
{
}

CBCG.Page.prototype =
{
	handleLoad: function(control, userContext, rootElement) 
	{
		this.control = control;
		
		// Sample event hookup:	
		rootElement.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleMouseDown));
	},
	
	// Sample event handler
	handleMouseDown: function(sender, eventArgs) 
	{
		// The following line of code shows how to find an element by name and call a method on it.
		// this.control.content.findName("Timeline1").Begin();
	}
}

function ImageLoading1(sender, args) 
{
    if (sender.DownloadProgress == 1) {
    sender.findName("txtTitle").Text = ImageTitle[rand_no];
            if(ImageDesc[rand_no].length >70)
        {
        sender.findName("txtText").Text = ImageDesc[rand_no].substring(0,70)+" ...";
        }
        else
        {
        sender.findName("txtText").Text = ImageDesc[rand_no];
        }
        
        sender.findName("ellipse").Visibility = "Collapsed";

        if (started != 1) {
            sender.findName("FadeAnimation1").begin();
        }
        else {
            started = 2;
            sender.findName("DummyAnimation").begin();
        }
       
      
    }
}
function ImageLoading2(sender, args) {
    if (sender.DownloadProgress == 1) {
    sender.findName("txtTitle").Text = ImageTitle[rand_no];
        if(ImageDesc[rand_no].length >70)
            {
            sender.findName("txtText").Text = ImageDesc[rand_no].substring(0,70)+" ...";
            }
            else
            {
            sender.findName("txtText").Text = ImageDesc[rand_no];
            }
        sender.findName("ellipse").Visibility = "Collapsed";


        sender.findName("FadeAnimation2").begin();


    }
}
var rand_no;
function LoadNext1(sender, args) {
    if (tempImageVal == ImageList.length - 1) {
        tempImageVal = 0;
    }
    else {
        tempImageVal = tempImageVal + 1;
    }
    rand_no = Math.random();
    var aLength = ImageList.length;
    rand_no = rand_no * aLength;
    rand_no = Math.ceil(rand_no);
    
    sender.findName("ellipse").Visibility = "Visible";
    sender.findName("LoadingAnimation").begin();
    sender.findName("ImgDynamicmirror")["Source"] = ImageList[rand_no];
}
function LoadNext2(sender, args) {
    if (tempImageVal == ImageList.length - 1) {
        tempImageVal = 0;
    }
    else {
        tempImageVal = tempImageVal + 1;
    }

    rand_no = Math.random();
    var aLength = ImageList.length;
    rand_no = rand_no * aLength;
    rand_no = Math.ceil(rand_no);
    
    sender.findName("ellipse").Visibility = "Visible";
    sender.findName("LoadingAnimation").begin();
    sender.findName("ImgDynamic")["Source"] = ImageList[rand_no];
}

var currentItem = 1;
//var ImageList = new Array(3);
var tempImageVal = 0;
var started = 1;


function LoadImages(sender, args)
 {

     //ImageList[0] = "http://www.dnnize.net/cheetah.jpg";
     //ImageList[1] = "http://www.dnnize.net/confusing.jpg";
    // ImageList[2] = "http://www.dnnize.net/Portals/90/img1.jpg";
    rand_no = Math.random();
    var aLength = ImageList.length;
    rand_no = rand_no * aLength;
    rand_no = Math.ceil(rand_no);
    var wid;
wid = sWidth.substring(0, sWidth.length-2);
//alert(wid);
sender.findName("canvasImage").Height= sHeight.substring(0, sHeight.length-2);
sender.findName("canvasImage").Width= sWidth.substring(0, sWidth.length-2);

sender.findName("ImgDynamic").Height=parseInt(sHeight.substring(0, sHeight.length-2));
sender.findName("ImgDynamic").Width=parseInt(sWidth.substring(0, sWidth.length-2));
sender.findName("ImgDynamicmirror").Height=parseInt(sHeight.substring(0, sHeight.length-2));
sender.findName("ImgDynamicmirror").Width=parseInt(sWidth.substring(0, sWidth.length-2));


//sender.findName("ImgDynamic").Height=200;
//sender.findName("ImgDynamic").Width=176;

sender.findName("txtTitle")["Width"]=176;
sender.findName("txtText")["Canvas.Top"]=parseInt(sHeight.substring(0, sHeight.length-2))-40;
sender.findName("txtText")["Width"]=176;
     sender.findName("ellipse").Visibility = "Visible";
     sender.findName("LoadingAnimation").begin();
     sender.findName("ImgDynamic")["Source"] = ImageList[rand_no];
}
function Redirect(sender, args)
{
if(tempImageVal != 0)
window.location = jweb1+"/CBC_Pages/EventImages.aspx?Event="+rurl[rand_no];
else
window.location = jweb1+"/CBC_Pages/EventImages.aspx?Event="+rurl[rand_no];
}
/*8888888888888888
var tempImageVal=0;


function LoadImages(sender, args)
{
var wid;
wid = sWidth.substring(0, sWidth.length-2);
//alert(wid);
sender.findName("canvasImage").Height= sHeight.substring(0, sHeight.length-2);
sender.findName("canvasImage").Width= sWidth.substring(0, sWidth.length-2);

sender.findName("ImgDynamic").Height=parseInt(sHeight.substring(0, sHeight.length-2));
sender.findName("ImgDynamic").Width=parseInt(sWidth.substring(0, sWidth.length-2));
sender.findName("ImgDynamicmirror").Height=parseInt(sHeight.substring(0, sHeight.length-2));
sender.findName("ImgDynamicmirror").Width=parseInt(sWidth.substring(0, sWidth.length-2));


//sender.findName("ImgDynamic").Height=200;
//sender.findName("ImgDynamic").Width=176;

sender.findName("txtTitle")["Width"]=176;
sender.findName("txtText")["Canvas.Top"]=parseInt(sHeight.substring(0, sHeight.length-2))-40;
sender.findName("txtText")["Width"]=176;
//sender.findName("txtText")["Canvas.Width"]=parseInt(sHeight.substring(0, sHeight.length-2))-20;
//sender.findName("txtText")["Canvas.Top"]=0;


//alert("hi");
//alert(ImageList.length)

Animation(sender, args);
}


function Animation(sender, args)
{
 sender.findName("ellipse").Visibility = "Visible";
    sender.findName("LoadingAnimation").begin();

sender.findName("ImgDynamicmirror").Visibility = "Visible";


sender.findName("ImgDynamic")["Opacity"] = 0;
sender.findName("ImgDynamic")["Source"]= ImageList[tempImageVal];
 if (tempImageVal == 0) {
        sender.findName("ImgDynamicmirror")["Source"] = ImageList[tempImageVal];
    }
    else {
        sender.findName("ImgDynamicmirror")["Source"] = ImageList[tempImageVal-1];
    }

//sender.findName("ImgDynamic")["MouseLeftButtonDown"]= rurl[tempImageVal];
//sender.findName("FadeAnimation").begin();



}

function ImageLoading(sender, args) 
{
    if (sender.DownloadProgress == 1) {
    sender.findName("ImgDynamic")["Opacity"] = 0;
     sender.findName("ImgDynamicmirror").Visibility = "Collapsed";
     sender.findName("txtTitle").Text = ImageTitle[tempImageVal];
     if(ImageDesc[tempImageVal].length >70)
{
sender.findName("txtText").Text = ImageDesc[tempImageVal].substring(0,70)+" ...";
}
else
{
sender.findName("txtText").Text = ImageDesc[tempImageVal];
}
        sender.findName("ImageAnimation").begin();
		
  sender.findName("ellipse").Visibility = "Collapsed";
    }
    if(tempImageVal == ImageList.length-1)
{
tempImageVal = 0;
}
else
{
tempImageVal = tempImageVal +1;
}
}

function Redirect(sender, args)
{
if(tempImageVal != 0)
window.location = jweb1+"/CBC_Pages/EventImages.aspx?Event="+rurl[tempImageVal-1];
else
window.location = jweb1+"/CBC_Pages/EventImages.aspx?Event="+rurl[ImageList.length-1];
}*/