//define the variables
var myFirst = 0;
var thisAd = 0;
var make_rand = 0;

//create the image array
myPix = new Array("wp-content/themes/great-ca-weddings/images/partners/mirror_image_home.jpg","wp-content/themes/great-ca-weddings/images/partners/gina_staffiery.jpg");

//create the array with the links
myLix = new Array("http://www.mirrorimagephoto.net/","http://imagesbyg.com/");

//variable to represent current image variable
var currentPic = new Image();
currentPic.src = myPix[thisAd];

//this variable represents the number of images in the image array
var imgCt = myPix.length;

//create an array that randomizes the order of the images and links.
var randomize_it = new Array();

for (i=0; i<imgCt;i++){
randomize_it[i] = i;
}

function randOrd(){
return (Math.round(Math.random())-0.5); }

randomize_it.sort(randOrd);

//function to cycle the images
function cyclePic(){
	if (document.images){
		thisAd = randomize_it[make_rand];
		currentPic.src = myPix[thisAd];
		document.myPicture.src=currentPic.src
		myFirst = 1;
		setTimeout("cyclePic()", 7 * 1000)
		make_rand++
		if (make_rand == imgCt) {
			make_rand = 0
		}
	}}
	
//function to be called by the link tag
function newLocation(){
	if (myFirst == 1){
	window.open (myLix[thisAd])
	//document.location.href="" + myLix[thisAd]
	}else{
	document.location.href=""
	}}