var currentdate = 0;
var randBannerIndex = 0;
var numimages = 10;
var numExcludeImages = 2;
var width='121';
var height='148';

function StringArray (n) {
  this.length = n;
  for (var i =1; i <= n; i++) {
    this[i] = ' ';
  }
}

function NumArray (n) {
  this.length = n;
  for (var i =1; i <= n; i++) {
    this[i] = 0;
  }
}

// Contains list of indexes to exclude from randomized candidates
var excludeImageList = new NumArray(numExcludeImages);
 
var imageList = new StringArray(numimages);
imageList[0] = '/images/banners/ftr_app_devmaint.gif';
imageList[1] = '/images/banners/ftr_busprocout.gif';
imageList[2] = '/images/banners/ftr_e_busconsult.gif';
imageList[3] = '/images/banners/ftr_cc_consolidation.gif';
imageList[4] = '/images/banners/ftr_cc_operation.gif';
imageList[5] = '/images/banners/ftr_it_busprocreeng.gif';
imageList[6] = '/images/banners/ftr_it_consult.gif';
imageList[7] = '/images/banners/ftr_it_outsourc.gif';
imageList[8] = '/images/banners/ftr_it_servmanreeng.gif';
imageList[9] = '/images/banners/ftr_offshore_app_devmaint.gif';

var urlList = new StringArray(numimages);
urlList[0] = '/case_studies/case_study_one.shtml';
urlList[1] = '/case_studies/case_study_eleven.shtml';
urlList[2] = '/case_studies/case_study_four.shtml';
urlList[3] = '/case_studies/case_study_five.shtml';
urlList[4] = '/case_studies/case_study_twelve.shtml';
urlList[5] = '/case_studies/case_study_seven.shtml';
urlList[6] = '/case_studies/case_study_ten.shtml';
urlList[7] = '/case_studies/case_study_eight.shtml';
urlList[8] = '/case_studies/case_study_three.shtml';
urlList[9] = '/case_studies/case_study_two.shtml';

var altList = new StringArray(numimages);
altList[0] = 'offshore application development and maintenance services';
altList[1] = 'business process outsourcing';
altList[2] = 'e-business consulting';
altList[3] = 'contact center consolidation';
altList[4] = 'contact center operation';
altList[5] = 'IT business process re-engineering';
altList[6] = 'IT consulting';
altList[7] = 'IT outsourcing';
altList[8] = 'IT service management re-engineering';
altList[9] = 'offshore application development and maintenance services';

var ran = 60/imageList.length;

/* ------------------------------------------------------
	Check if newly generated candidate image index is
	already in list of images that should be excluded
	from display.
--------------------------------------------------------- */ 
function isIdxInExcludeImageList(idxCandidate) {
	var result = 0;
	
	for (var i = 0; i < excludeImageList.length; i++) {
		if (idxCandidate == excludeImageList[i]) {
			result = 1;
			break;
		}
	}
	return result;
}

/* ------------------------------------------------------
	Continue to generate random candidate image index
	while previously generated candidate image index
	is in list of image indexes to be excluded from
	display.
--------------------------------------------------------- */ 
function getRandomIndex() {
	var idxUnround = 0;
	var idx = -99;
	
	idxUnround = Math.random()*numimages;
	idx = Math.floor(idxUnround);

	while (isIdxInExcludeImageList(idx) == 1) {
		//alert("Index IS in excludeImageList");
		idxUnround = Math.random()*numimages;
		idx = Math.floor(idxUnround);
	}

	return idx;
}

/* ------------------------------------------------------
	Randomizing 2 Case Study banners
	Should not display 2 identical banners or banner from
	same section.
--------------------------------------------------------- */ 
function randomImagesCaseStudies(currentIndex) {
	excludeImageList[0] = currentIndex;
	randBannerIndex = getRandomIndex();
	excludeImageList[1] = randBannerIndex;
	
	document.write('<div id="caseStudiesLeft">');
	document.write('<a href=\"' + urlList[randBannerIndex] + '\" ><img src=\"' + imageList[randBannerIndex] + '\" width=\"' + width + '\" height=\"' + height + '\" alt=\"' + altList[randBannerIndex] + '\" border=0></a>');
	document.write('</div>');
	
	randBannerIndex = getRandomIndex();
	document.write('<div id="caseStudiesRight">');
	document.write('<a href=\"' + urlList[randBannerIndex] + '\" ><img src=\"' + imageList[randBannerIndex] + '\" width=\"' + width + '\" height=\"' + height + '\" alt=\"' + altList[randBannerIndex] + '\" border=0></a>');
	document.write('</div>');
}
