//*********************Variable And Array Declaration Section Begins Here**********************//

var i,j,r;//Counter Variables
var click=0;//Counter To Check The No Of Cards Selected By The User
var cardno=0;//To Store The Selected Card 
var n=78;
var image_url_1=""; 
var image_url_2=""; 
var image_url_3=""; 
var ie4;
var ns4;
var ng5;
var rand;
var choosenNumbers;
var img_array;
rand = new Array(79);
choosenNumbers = new Array ();
img_array = new Array(400,500,600);

//the next 3 lines are browser detection for user-agent DOMS 

ns4 = (document.layers) ? true:false //required for Functions to work 
ie4 = (document.all) ? true:false //required for Functions to work 
ng5 = (document.getElementById) ? true:false //required for Functions to work 


//************ Function To Check The 3 Selected Cards and Store them in an array *************//
   
function image1(num)
	{
		
		if(click==0) shuffle();//On First Click Of A Card The Whole Bunch Is Shuffeled
		

    	if((click<=2)&&(img_array[0]!=num)&&(img_array[1]!=num))//Condition To Check The Number of Cards Selected and there repeatations
	    {
		
		img_array[click]=num;
		cardno = rand[img_array[click]];//Storing The Corresponding Random Number
			
					if(ie4)	
						Get_image(click,cardno);
					else if(ns4)	
						HL(click,cardno);
					

		click=click+1;
		
	    }
	    else alert('You Have Already Selected 3 Cards');
	    
	}//end of image1()


//*********************************************************************************************//
//******************** Function To Check The 1 Selected Cards and Display It ******************//

function single(num)
	{
	
		if(click==0) shuffle();//On First Click Of A Card The Whole Bunch Is Shuffeled
		

    	if(click<1)//Condition To Check The Number of Cards Selected and there repeatations
	    {
				  
		img_array[click]=num;
		cardno = rand[img_array[click]];//Storing The Corresponding Random Number
			
					if(ie4)	
						Get_image(3,cardno);
					else if(ns4)	
						HL(click,cardno);
		click=click+1;
		
	    }
	    else alert('You Have Already Selected 1 Card');
	    
	}//end of single()


//***************************Function To Shuffle The Cards In An Array*************************//

	function Generate_RandomNumber(n) 
	{
	   r = Math.ceil (Math.random() * n);
	   while (choosenNumbers[r]) 
	     r = Math.ceil (Math.random() * n);
	   choosenNumbers[r] = true;
	   return r;
	}
	
	function shuffle()
	{
	    
	    for (j = 1; j <= 78; j++) 
	    {
         	   rand[j] = ((Generate_RandomNumber(n))-1); 
	    }
	}
 
//******************Function To Generate The Url of an image to be displayed*******************//
	
	function HL(no,cno)
{
	if (no==0)
		{
		document.getElementsById(c1).src=".\\images\\cards\\"+cno+".gif"
		}
	else
	if (no==1)
		{ 
		document.getElementsById(c2).src=".\\images\\cards\\"+cno+".gif"
		}
	else
	if (no == 2)
		{
		document.getElementsById(c3).src=".\\images\\cards\\"+cno+".gif"
		 
		}
}


//*********************************************************************************************//
//******************Function To Generate The Url of an image to be displayed*******************//


	function Get_image(no,cno)
	{
	if(no==0)		
		{
			image_url_1=".\\tarot\\images\\cards\\" + cno + ".gif";
			card79.innerHTML="<IFRAME src=http://www.astroiq.com/prashana/tarot/tarot.asp?cardno="+cno+"&table=past&browser=1&prediction=3 Width=200 Height=480 frameborder=no ></iframe>"
	//		card79.innerHTML="<IFRAME src=http://localhost/astroiq/prashana/tarot/tarot.asp?cardno="+cno+"&table=past&browser=1&prediction=3 Width=200 Height=480 frameborder=no ></iframe>"

			document.all['card79'].style.left = 150;
		}
		else if(no==1)
		{
			image_url_2=".\\tarot\\images\\cards\\" + cno + ".gif";
			card80.innerHTML="<IFRAME src=http://www.astroiq.com/prashana/tarot/tarot.asp?cardno="+cno+"&table=present&browser=1&prediction=3 Width=200 Height=480 frameborder=no></iframe>"
//			card80.innerHTML="<IFRAME src=http://localhost/astroiq/prashana/tarot/tarot.asp?cardno="+cno+"&table=present&browser=1&prediction=3 Width=200 Height=480 frameborder=no></iframe>"

			document.all['card80'].style.left = 340;
		}
		else if(no==2)
		{
			image_url_3=".\\tarot\\images\\cards\\" + cno + ".gif";
			card81.innerHTML="<IFRAME src=http://www.astroiq.com/prashana/tarot/tarot.asp?cardno="+cno+"&table=future&browser=1&prediction=3 Width=200 Height=480 frameborder=no></iframe>"
//			card81.innerHTML="<IFRAME src=http://localhost/astroiq/prashana/tarot/tarot.asp?cardno="+cno+"&table=future&browser=1&prediction=3 Width=200 Height=480 frameborder=no></iframe>"

			document.all['card81'].style.left = 540;

		}
		else if(no==3)
		{

			image_url_3=".\\tarot\\images\\cards\\" + cno + ".gif";
			document.all['card82'].style.left = 150;
			card82.innerHTML="<IFRAME src=http://www.astroiq.com/prashana/tarot/tarot.asp?cardno="+cno+"&table=future&browser=1&prediction=1 Width=580 Height=220 frameborder=no></iframe>"		
		//	card82.innerHTML="<IFRAME src=http://localhost/astroiq/prashana/tarot/tarot.asp?cardno="+cno+"&table=future&browser=1&prediction=1 Width=580 Height=220 frameborder=no></iframe>"		

		}
	}

	
