//js file to generate Quotes 
//File Name : quotes.js
//location  : http://www.telepoll.net/js/quotes.js

/* #################################################
      ##### START OF EDITABLE SECTION ##### 
################################################### */

/* #### INSTRUCTIONS - Please read this before adding quotes ####

1. The dobule quotes in the quotes must be escaped by adding abackslash before it. For example, the string "My Quote is "Great" "  should be used like " My Quote is \"Great\" ".

2. You can enter any number of quotes, quotes are to be assigned as quote_1, quote_2,......,quote_n 

3. There should be equal number of "whosaid" string.ie, whosaid_1,whosaid_2,................,whosaid_n 

4. The quote strings are then to be assigned to quote array "rotate_txt" as [quote_n, whosaid_n]. This array is used for  quote rotation ( "n" stand for quote number for example  [quote_7, whosaid_7])

5. Change the delay of rotation. Assign the delay in micro seconds to variable "callback_time_in_micro_seconds" [This is optional]

6. Do not edit any statments outside the Editable section.
*/


// ### SECTION FOR ADDING QUOTES START ###

// Quote1
var quote_1 = "We've been working with Telepoll for over a decade now and have the highest regard for their reliability and integrity.";
var whosaid_1 = "Innotech Market Research";

// Quote2
var quote_2 = "We've worked with Telepoll Canada consistently for ten years now since we first learned about them in 2000. We conduct market research studies for clients in Canada, the US and Europe. In our experience Telepoll Canada is the best market research partner we've ever worked with and we've been in business since 1980. Their performance on telephone interview and large focus group recruiting projects, with difficult specifications, has been exceptional. They've earned our respect and trust.";
var whosaid_2 = "Campbell Media Research, Inc.";

// Quote3
var quote_3 = "Telepoll's work is consistently top-notch from the project management, to the programming, to the interviewing, to the supervision. They get things done on schedule and worry-free.  It's not only easy, but a pleasure to work with them time and time again";
var whosaid_3 = "Stanford Alumni Association";

// Quote4
var quote_4 = "I really enjoyed working with Telepoll.  Their professionalism, attention to detail, and solutions-oriented attitude are much appreciated.";
var whosaid_4 = "Persuadable Research Corporation";

// Quote5
var quote_5 = "Telepoll's innovative ideas, dedicated team and timely execution made it possible for our association to connect with literally thousand of members within a few short weeks. As a result of the campaign, the project paid for itself, plus returned a noteable 25%. Thank Telepoll! We'll be using your services again next year";
var whosaid_5 = "A Leading Canadian Not-For-Profit Association";

// Quote5
var quote_6 = "Telepoll has immensely helped us focus our consumer target market research when working with downtowns, shopping centres, and retailer research. [Telepoll] offers excellent service, quick response, speedy interviewing, and most importantly excellent and reliable data.";
var whosaid_6 = "Urban Marketing Collaborative";

//Add new quotes here....( While addin a new quote assign it to a new string variable quote_7 and whosaid_7 ...and so on. Also add the quote variable to array rotate_txt [quote_7, whosaid_7]  )

// ### SECTION FOR ADDING QUOTES END ###



// ### SECTION FOR ADDING QUOTE STRINGS TO QUOTE ARRAY START ###

//Adding the above quotes to an array for rotating.
//New quote string must be assigned to quote array

var rotate_txt=[ 
[quote_1, whosaid_1] ,
[quote_2, whosaid_2] ,
[quote_3, whosaid_3] ,
[quote_4, whosaid_4] ,
[quote_5, whosaid_5] ,
[quote_6, whosaid_6]
];

// ### SECTION FOR ADDING QUOTE STRINGS TO QUOTE ARRAY END ###




// ### SECTION FOR CHANGING TIME DELAY START ###

//setting callback/delay time in micro seconds, you can change this
// eg: for 3 seconds callback_time_in_micro_seconds=3000;
// eg: for 30 seconds callback_time_in_micro_seconds=30000;

var callback_time_in_micro_seconds = 30000; //You can change the delay time here

// ### SECTION FOR CHANGING TIME DELAY END ###

//Do not edit the contents outside the editable section

/* #################################################
      ##### END OF EDITABLE SECTION ##### 
################################################### */




// Do not Edit the following section

//setting index of quote array declared above
var quote_index=0;   //Do not edit this statement


//Function to rotate quote starting from first quote, default quote_index is 0   ------   start
function rotate_quote(quote_index){
		
		//getting count of quotes
		quote_length=rotate_txt.length; 
		
		//if quote_index  is not given, then set it a default 0
		if(!quote_index){ 
		//quote_index=0;
		//generate a random index between 0 and length of the quote array
		quote_index = randomValue( 0 , quote_length );
		}
		
		//if quote_index greater than or equal to count of quotes, 
		//then set it a default 0 to start rotation from first quote
		else if( quote_index >= quote_length ) 
		quote_index=0;
		
		//take the respective quote based on the quote_index
		if(!rotate_txt[quote_index] || typeof(rotate_txt[quote_index]) == "undefined" ){
		//if quote_index is invalid then set it to default index 0
				quote_txt=rotate_txt[0][0];
				who_said =rotate_txt[0][1];
		}else{
		//for valid quote_index value return corresponding quote
				quote_txt=rotate_txt[quote_index][0];
				who_said =rotate_txt[quote_index][1];
		}
		
		//Assign the Quotes to display string, and this string 
		//will be added to the quote display position
		quote_str="<table border=\"0\"  cellspacing=\"0\" ><tr><td colspan=\"3\" height=\"15px\">&nbsp;</td></tr><tr><td width=\"50\" align=\"right\" valign=\"top\" style=\"padding-right:10px\"><img src=\"http://www.telepoll.net/images/quote2.gif\" alt=\"\" width=\"23\" height=\"22\" /></td><td width=\"260\" align=\"left\">"+quote_txt+"</td><td width=\"128\" align=\"left\" valign=\"bottom\" style=\"padding-left:10px\"><img src=\"http://www.telepoll.net/images/quote.gif\" alt=\"\" width=\"23\" height=\"22\" /></td></tr></table></p>	        	        <p style=\"margin-bottom:5px\">&nbsp;</p>	<p align=\"center\" id=\"explainLink\"> ~ "+who_said+"</p>  ";
		
		//increment the quote index to point to the next quote in the array
		quote_index++;
		
		//Assign the quote string to display postion on HTML page
		document.getElementById('rotate_quote').innerHTML = quote_str;
		
		//This is a call back function, the function will be called again after given (callback_time_in_micro_seconds) micro seconds
		setTimeout("rotate_quote("+quote_index+")",callback_time_in_micro_seconds);
}
//Function to rotate quote starting   -----  end




//Function to generate random value between 2 nos   ---- start
function randomValue( minVal,maxVal )
{
var randVal = minVal+(Math.random()*(maxVal-minVal));
return ( Math.round(randVal) );
}
//Function to generate random value between 2 nos   ---- end




//function to shuffle array with out affecting the orginal array, it returns a  new shuffled array  --- start
function arrayShuffle(oldArray) {
	var newArray = oldArray.slice();
 	var len = newArray.length;
	var i = len;
	 while (i--) {
	 	var p = parseInt(Math.random()*len);
		var t = newArray[i];
  		newArray[i] = newArray[p];
	  	newArray[p] = t;
 	}
	return newArray; 
};
//function to shuffle array ---- end




//function to generate quotes on testimonial page   ---   start
function generate_quote(){
	//declaring a new array to store shuffled array
	quote_list = new Array();
	
	//quote array a shuffled
	quote_list = arrayShuffle(rotate_txt);
	for( qInd=0; qInd < quote_list.length; qInd++){
	
		//take the respective quote based on the quote_index
			qte_txt=quote_list[qInd][0];
			wsd_txt =quote_list[qInd][1];
			
			//Assign the Quotes to display string, and this string 
			//will be added to the quote display position
			quote_string="<table border=\"0\"  cellspacing=\"0\" ><tr><td colspan=\"3\" height=\"15px\">&nbsp;</td></tr><tr><td width=\"50\" align=\"right\" valign=\"top\" style=\"padding-right:10px\"><img src=\"http://www.telepoll.net/images/quote2.gif\" alt=\"\" width=\"23\" height=\"22\" /></td><td width=\"260\" align=\"left\">"+qte_txt+"</td><td width=\"128\" align=\"left\" valign=\"bottom\" style=\"padding-left:10px\"><img src=\"http://www.telepoll.net/images/quote.gif\" alt=\"\" width=\"23\" height=\"22\" /></td></tr></table></p>	        	        <p style=\"margin-bottom:5px\">&nbsp;</p>	<p align=\"center\" id=\"explainLink\"> ~ "+wsd_txt+"</p><br>  ";
	
	//writing the quotes on display position
	document.write(quote_string);
	
	}

}
//function to generate quotes on testimonial page   ---   end


