/*************** CALL TO ACTION START - [By GVS] *******************/

/* define general parameters */
var inSeconds = 5000;
var pic_width = 392;
var pic_height = 63;
var thenum = 0;

/* define image urls */
var myArr	= new Array();
var myURLs	= new Array(4);
var pics	= new Array();

myArr = p_stCallToAction.split("|");
var numpics = myArr.length;

for(i in myArr)
{
	var myArr1 = new Array();
	myArr1 = myArr[i].split("~");
	
	myURLs[i] = myArr1[1];
		
	if (document.images)
	{
		if(i==0)
		{
			pic1 = new Image(pic_width,pic_height);
			pic1.src = "upload/CallToAction/" + myArr1[0];
		}

		if(i==1)
		{
			pic2 = new Image(pic_width,pic_height);
			pic2.src = "upload/CallToAction/" + myArr1[0];
		}

		if(i==2)
		{
			pic3 = new Image(pic_width,pic_height);
			pic3.src = "upload/CallToAction/" + myArr1[0];
		}
		
		if(i==3)
		{
			pic4 = new Image(pic_width,pic_height);
			pic4.src = "upload/CallToAction/" + myArr1[0];
		}
	}

	if(i==0) pics[0] = pic1.src;
	if(i==1) pics[1] = pic2.src;
	if(i==2) pics[2] = pic3.src;
	if(i==3) pics[3] = pic4.src;
	imgName = "img1";
}

function getCallToAction()
{
	document.write("<div id=\"Layer1\" style=\"left:160px; top:10px; position:absolute;\"><!--<img src=\"Images/Welcome.jpg\" width=\"275\" height=\"28\">--></div>");
	if(p_stCallToAction.length>0)
	{
		if (document.images)
		{
			if (document.images)
			{
				if(myURLs[thenum]=="")
				{
					document.getElementById("Layer1").innerHTML ="<img src='"+pics[0]+"' border='0' width='"+pic_width+"' height='"+pic_height+"' name='img1'>";
				}
				else
				{
					document.getElementById("Layer1").innerHTML ="<a href='"+myURLs[0]+"' border='0' alt='"+myURLs[0]+"' title='"+myURLs[0]+"' target='_blank'><img src='"+pics[0]+"' border='0' width='"+pic_width+"' height='"+pic_height+"' name='img1'></a>";
				}
			}
			setTimeout('change_it2()',inSeconds);
		}
	}
}

function change_it2()
{
	var x = 0;
	thenum += 1;

	if (document.images)
	{
		if(thenum==numpics) thenum1 = 0;
		else thenum1 = thenum;
		
		if(myURLs[thenum1]=="")
		{
			document.getElementById("Layer1").innerHTML ="<img src='"+pics[thenum]+"' border='0' width='"+pic_width+"' height='"+pic_height+"' name='img1'>";
		}
		else
		{	
			document.getElementById("Layer1").innerHTML ="<a href='"+myURLs[thenum1]+"' border='0' alt='"+myURLs[thenum1]+"' title='"+myURLs[thenum1]+"' target='_blank'><img src='"+pics[thenum]+"' border='0' width='"+pic_width+"' height='"+pic_height+"' name='img1'></a>";
		}
	}
	
	if (thenum > numpics - 1)
	{
		thenum = 0
		x = 0
		document[imgName].src = pics[thenum];
		x += 1;
		setTimeout('change_it2()',inSeconds);
	}
	else
	{
		document[imgName].src = pics[thenum];
		x += 1;
		setTimeout('change_it2()',inSeconds);
	}
}
/*************** CALL TO ACTION END *******************/
