var arr=null;
var req=null;
var response = null;
var Synonyms1;
var Synonyms2;
var Antonyms;
var WordName;
var clickToStart=false;
var currentIndex=-1;
var maxRange = -1;
var minRange = -1;
function init(){
	arr= new Array(26);
	arr[0]=484;
	arr[1]=186;
	arr[2]=459;
	arr[3]=399;
	arr[4]=308;
	arr[5]=196;
	arr[6]=110;
	arr[7]=107;
	arr[8]=450;
	arr[9]=30;
	arr[10]=17;
	arr[11]=160;
	arr[12]=269;
	arr[13]=104;
	arr[14]=165;
	arr[15]=561;
	arr[16]=28;
	arr[17]=276;
	arr[18]=385;
	arr[19]=190;
	arr[20]=84;
	arr[21]=121;
	arr[22]=49;
	arr[23]=4;
	arr[24]=5;
	arr[25]=5;
}


function loadXMLDoc(url) 
{
	//alert("Ajax Call"+clickToStart)
	if(clickToStart==false){
		//alert("1111Ajax Call"+clickToStart)
		 if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
			req.onreadystatechange = processReqVocabAlphabet;
			req.open("GET", url, true);
			req.send(null);
		  } else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
			if (req) {
				req.onreadystatechange = processReqVocabAlphabet;
				req.open("GET", url, true);
				req.send();
			}
		}
		document.getElementById("placeForWord").innerHTML ="<p class='word'><img src='images/progress.gif' /></p>";
	}
}

function processReqVocabAlphabet(){
    var Usages1;
    var Usages2;
    var Usages3;
    var WordId;
       
    if (req.readyState == 4)
	{
       if (req.status == 200)
		{
		 	response = req.responseXML.documentElement;
 			WordName = response.getElementsByTagName('WordName')[0].firstChild.data;
			WordName = WordName.substring(1,WordName.length-1);
			document.getElementById("placeForWord").innerHTML ="<p class='word'>"+WordName+"</p>";			
			//document.getElementById("placeForSA").innerHTML ="<table id='saTable'><tr><td><p class='gtxt11_ta'><a href='#'>Antonym : </a>&nbsp;&nbsp;</p></td><td id='placeForS1'><p class='gtxt11_ta'><a href='#'>Synonym1 : </a>&nbsp;&nbsp;</p></td><td id='placeForS2'><p class='gtxt11_ta'><a href='#'>Synonym2 : </a>&nbsp;&nbsp;</p></td><td onmouseover='makeHandForNextPrevRandom(this)'><p id='showHideSA' class='gtxt11_ta'  onclick='showHideTable()'><a href='#'>SHOW</a></p></td></tr></table>";		
			document.getElementById("placeForSA").innerHTML ="<table id='saTable' class='gtxt11_ta' style='color:#12609d'><tr><td id='showHideSA' style='cursor:pointer' onclick='showHideTable()'><p><u><b>Show Antonym &amp; Synonyms</b></u></p></td></tr></table>";		
		}	
    }
}

function showHideTable(){
	//alert((document.getElementById('showHideSA').innerHTML));
	if((document.getElementById('showHideSA').innerHTML).indexOf('>Show Antonym &amp; Synonyms<')>-1){
		response = req.responseXML.documentElement;
		//alert("if");
		Synonyms1 = response.getElementsByTagName('Synonyms1')[0].firstChild.data;
		Synonyms2 = response.getElementsByTagName('Synonyms2')[0].firstChild.data;
		Antonyms = response.getElementsByTagName('Antonyms')[0].firstChild.data;
		Synonyms1 = Synonyms1.substring(1,Synonyms1.length-1);
		Synonyms2 = Synonyms2.substring(1,Synonyms2.length-1);
		Antonyms = Antonyms.substring(1,Antonyms.length-1);		
		//document.getElementById('showHideSA').innerHTML="<p id='showHideSA' class='gtxt11_ta' onclick='showHideTable()'><a href='#'>HIDE</a></p>";
		//alert(document.getElementById('showHideSA').innerHTML);
		document.getElementById("placeForSA").innerHTML ="<table id='saTable' style='color:#000'><tr><td><p><b>Antonym:</b> <u id='antGoogle' style='cursor:pointer' onclick='callGoogleSearch(this)'>"+Antonyms+"</u> &nbsp;&nbsp;|&nbsp;&nbsp;</p></td><td id='placeForS1'><p><b>Synonyms:</b> <u id='synGoogle1' style='cursor:pointer' onclick='callGoogleSearch(this)'>"+Synonyms1+"</u>&nbsp;,&nbsp;&nbsp; <u id='synGoogle2' style='cursor:pointer' onclick='callGoogleSearch(this)'>"+Synonyms2+"</u>&nbsp;&nbsp;|&nbsp;&nbsp;</p></td><td id='showHideSA'  onclick='showHideTable()' onmouseover='makeHandForNextPrevRandom(this)'><p style='color:#12609d; cursor:pointer'><b><u>Hide This</u></b></p></td></tr></table>";		
	}else{
		//document.getElementById('showHideSA').innerHTML="<p id='showHideSA' class='gtxt11_ta'  onclick='showHideTable()'><a href='#'>SHOW</a></p>";
		//alert("else");
		//document.getElementById("placeForSA").innerHTML ="<table id='saTable'><tr><td><p class='gtxt11_ta' style='color:#000'><a href='#'>Antonym : </a>&nbsp;&nbsp;</p></td><td id='placeForS1'><p class='gtxt11_ta'><a href='#'>Synonym1 : </a>&nbsp;&nbsp;</p></td><td id='placeForS2'><p class='gtxt11_ta'><a href='#'>Synonym2 : </a>&nbsp;&nbsp;</p></td><td onmouseover='makeHandForNextPrevRandom(this)'><p id='showHideSA' class='gtxt11_ta'  onclick='showHideTable()'><a href='#'>SHOW</a></p></td></tr></table>";		
		document.getElementById("placeForSA").innerHTML ="<table id='saTable' class='gtxt11_ta' style='color:#12609d'><tr><td id='showHideSA' style='cursor:pointer' onclick='showHideTable()'><p><u><b>Show Antonym &amp; Synonyms</b></u></td></tr></table>";		
	}

}

function callGoogleSearch(obj){
	//alert(obj.id);
	var objId = obj.id; 
	var googleURL = 'http://www.google.co.in/search?hl=en&q=';
	if(objId.indexOf('antGoogle')>-1){
		//alert("111")
		if(Antonyms.toLowerCase().indexOf('not available')>-1){
			//alert('NOT AVAILABLE');
			document.getElementById('googleWordsSearch').innerHTML = '<p class="btxt16" style="font-size:22px;"><strong>'+WordName+'</strong> in context with <img src="images/google.gif" border="0" alt="Google" title="Google" style="vertical-align:middle" /></p>';
			document.getElementById('googleExSearch').src = googleURL+WordName+'+Antonyms&meta=';

		}else{
			document.getElementById('googleWordsSearch').innerHTML = '<p class="btxt16" style="font-size:22px;"><strong>'+Antonyms+'</strong> in context with <img src="images/google.gif" border="0" alt="Google" title="Google" style="vertical-align:middle" /></p>';
			document.getElementById('googleExSearch').src = googleURL+Antonyms+'+Antonyms&meta=';
		}
	}else if(objId.indexOf('synGoogle1')>-1){
		if(Synonyms1.toLowerCase().indexOf('not available')>-1){
			//alert('NOT AVAILABLE');
			document.getElementById('googleWordsSearch').innerHTML = '<p class="btxt16" style="font-size:22px;"><strong>'+WordName+'</strong> in context with <img src="images/google.gif" border="0" alt="Google" title="Google" style="vertical-align:middle" /></p>';
			document.getElementById('googleExSearch').src = googleURL+WordName+'+Synonyms&meta=';

		}else{
			document.getElementById('googleWordsSearch').innerHTML = '<p class="btxt16" style="font-size:22px;"><strong>'+Synonyms1+'</strong> in context with <img src="images/google.gif" border="0" alt="Google" title="Google" style="vertical-align:middle" /></p>';
			document.getElementById('googleExSearch').src = googleURL+Synonyms1+'+Synonyms&meta=';
		}
	}else{
		if(Synonyms2.toLowerCase().indexOf('not available')>-1){
			//alert('NOT AVAILABLE');
			document.getElementById('googleWordsSearch').innerHTML = '<p class="btxt16" style="font-size:22px;"><strong>'+WordName+'</strong> in context with <img src="images/google.gif" border="0" alt="Google" title="Google" style="vertical-align:middle" /></p>';
			document.getElementById('googleExSearch').src = googleURL+WordName+'+Synonyms&meta=';

		}else{
			document.getElementById('googleWordsSearch').innerHTML = '<p class="btxt16" style="font-size:22px;"><strong>'+Synonyms2+'</strong> in context with <img src="images/google.gif" border="0" alt="Google" title="Google" style="vertical-align:middle" /></p>';
			document.getElementById('googleExSearch').src = googleURL+Synonyms2+'+Synonyms&meta=';
		}
	}
	
}

function onPageLoadPopulateOptions(){	
	document.getElementById("googleExSearch").src ='http://www.google.com';
	init();
	var seclectRandomFrom = document.getElementById("RandomSelectFrom");
	var seclectRandomTo = document.getElementById("RandomSelectTo");
	seclectRandomFrom.disabled=true;
	seclectRandomTo.disabled=true;
	var aKeyIdLi = document.getElementById("keyboard");
	var htmlStr4LineEle = "";
	var idForKeyBoardLi = 1;
	for(var count=0;count<26;count++){
		var val = eval("String.fromCharCode(" + (count+65) + ")");
		//alert(val);
		var ranFromOpt = new Option(val);
		var ranToOpt = new Option(val);
		ranFromOpt.id="from"+count;
		ranToOpt.id="to"+count;
		seclectRandomFrom.options[count]= ranFromOpt;
		seclectRandomTo.options[count]= ranToOpt;
		if(count >0){
			idForKeyBoardLi = (idForKeyBoardLi+arr[count-1]);
		}
		if(count==10){			
			htmlStr4LineEle = htmlStr4LineEle +"<li onmouseover='makeHand(this)' onmouseout='removeHand(this)' onclick='makeActiveInActive(this)' id="+(idForKeyBoardLi)+" class='secondrow'><p>"+val+"</p></li>";
		}else if(count==19){
			htmlStr4LineEle = htmlStr4LineEle +"<li onmouseover='makeHand(this)' onmouseout='removeHand(this)' onclick='makeActiveInActive(this)' id="+(idForKeyBoardLi)+" class='thirdrow'><p>"+val+"</p></li>";
		}else{
			htmlStr4LineEle = htmlStr4LineEle +"<li onmouseover='makeHand(this)' onmouseout='removeHand(this)' onclick='makeActiveInActive(this)' id="+(idForKeyBoardLi)+"><p>"+val+"</p></li>";
		}
		//document.getElementById("divfoc").scrollIntoView();
		//alert(idForKeyBoardLi)
	}
	aKeyIdLi.innerHTML = htmlStr4LineEle;
	//alert(htmlStr4LineEle);
	// Condition To Check For First Time Or By Cookie
	var cookieId = checkCorrectIDCookie();
	var objAlphaRadio = document.getElementById("alphaBaticRadio");
	var objRanRadio = document.getElementById("randomRadio");
	//alert("cookieId   "+cookieId)
	if(cookieId==""|| cookieId==null){
		clickToStart=true;
		objAlphaRadio.checked=true;
		objAlphaRadio.disabled=true;
		objRanRadio.disabled=true;
		var objPlace4Word = document.getElementById("placeForWord");
		document.getElementById('defineInGoogle').style.visibility = 'hidden';	
		objPlace4Word.innerHTML = "<p id='clickStart' style='cursor:pointer' onclick='clickOnStart(this.id)' class='word'>Please Click Here To Start Vocab</p>";
	}else {
		clickToStart=false;
		objAlphaRadio.checked=true;
		objAlphaRadio.disabled=false;
		objRanRadio.disabled=false;
		var firstKeyRowId = getFirstKeyRowId(cookieId); 
		//alert("111111   "+firstKeyRowId);
		makeActiveInActiveForCookie(document.getElementById(firstKeyRowId),cookieId);
	}	
	setTimeout('document.getElementById("vocabdiv").scrollIntoView();','6000');
	
	//alert("1");
	//alert(objSelectedRadio.checked);
	
}
function getFirstKeyRowId(cookieId){
	//alert(cookieId)
	var cnt=1;
	var maxRange = 1;
	for(cnt;cnt<27;cnt++){		
		if(cnt>1){
			maxRange = maxRange+arr[cnt-2];
			//alert("cookieId  "+cookieId+"   maxRange  "+maxRange+ "   cnt "+cnt)
			if(cookieId < maxRange-1){
				break;
			}
		}
	}
	//alert("26====  "+cnt)
	if(parseInt(cnt)==27){
		//alert("26====")
		//alert("maxRange   "+maxRange)
		return maxRange;
	}else{
		return maxRange-arr[cnt-2];
	}
}

function clickOnStart(objid){
	document.getElementById(objid).style.visibility = 'hidden';
	document.getElementById('defineInGoogle').style.visibility = 'visible';
	clickToStart = false;
	var objAlphaRadio = document.getElementById("alphaBaticRadio");
	var objRanRadio = document.getElementById("randomRadio");
	objAlphaRadio.disabled=false;
	objRanRadio.disabled=false;	
	var startAphabet = document.getElementById('1');
	//alert(startAphabet.innerHTML);
	makeActiveInActive(startAphabet);
}

function callTheServerRandom(){
	
	
}

function callingPrevious(){
	if(document.getElementById("alphaBaticRadio").checked){		//case for alpahbetic
		//alert("Prev  currentIndex "+currentIndex+"  minRange   "+minRange+"  maxRange  "+maxRange);
		if(currentIndex>minRange){
			currentIndex = (currentIndex-1);
			var url = "GWS?alphabet="+currentIndex;
			loadXMLDoc(url);
		}else{
			currentIndex = maxRange;
			var url = "GWS?alphabet="+currentIndex;
			loadXMLDoc(url);
		}
		//alert("callingPrevious Calling Set Cookie ");
		setCookie('correctID',currentIndex,365);
	}else{													//case for Random						
		callToChangeKeyRow('false');
	}
	
}
function callingNext(){	
	if(document.getElementById("alphaBaticRadio").checked){		//case for alpahbetic
		//alert("Next   currentIndex "+currentIndex+"  minRange   "+minRange+"  maxRange  "+maxRange);
		if(currentIndex < maxRange){			
			currentIndex = (currentIndex * 1) + 1;
			//alert("Index    "+currentIndex);
			var url = "GWS?alphabet="+currentIndex;
			loadXMLDoc(url);
		}else{
			currentIndex = minRange;
			var url = "GWS?alphabet="+currentIndex;
			loadXMLDoc(url);
		}
		//alert("callingNext Calling Set Cookie ");
		setCookie('correctID',currentIndex,365);
	}else{														// Random
		callToChangeKeyRow('false');
	}
}
function makeActiveInActive(obj){
	//alert("Helllo----  "+obj.id)	
	if(clickToStart==false){
		if(document.getElementById("alphaBaticRadio").checked){	
			deActivateAll();
			//alert("makeActiveInActive Calling Set Cookie ");
			var innerHTMLVal  = document.getElementById(obj.id).innerHTML;
			var browser=navigator.appName;
			var b_version=navigator.appVersion;
			var version=parseFloat(b_version);
			//alert("ID == "+obj.id);
			if (browser=="Microsoft Internet Explorer"){
				if(innerHTMLVal.indexOf("K")>-1){
					//alert("Find K")
					document.getElementById(obj.id).setAttribute("className", "active secondrow");
					//document.getElementById(obj.id).setAttribute("className", "secondrow");
				}else if(innerHTMLVal.indexOf("T")>-1){
					//alert("Find T")
					document.getElementById(obj.id).setAttribute("className", "active thirdrow");
					//document.getElementById(obj.id).setAttribute("className", "secondrow");
				}else{
					document.getElementById(obj.id).setAttribute("className", "active");
				}
			}else if(browser=="Netscape"){
				//alert("innerHTMLVal "+innerHTMLVal);
				if(innerHTMLVal.indexOf("K")>-1){
					//alert("Find K")
					document.getElementById(obj.id).setAttribute("class", "active secondrow");
					//document.getElementById(obj.id).setAttribute("className", "secondrow");
				}else if(innerHTMLVal.indexOf("T")>-1){
					//alert("Find T")
					document.getElementById(obj.id).setAttribute("class", "active thirdrow");
					//document.getElementById(obj.id).setAttribute("className", "secondrow");
				}else{
					document.getElementById(obj.id).setAttribute("class", "active");
				}
			}else{
				document.getElementById(obj.id).setAttribute("class", "active");
			}
			innerHTMLVal = innerHTMLVal.substring(3,4);
			//alert("id == "+obj.id)
			currentIndex = obj.id;				
			var selectedCharCode = findTheCharCode(innerHTMLVal);
			//alert(selectedCharCode +"   "+innerHTMLVal);
			maxRange = parseInt(obj.id) + arr[selectedCharCode-65]-1;
			minRange = obj.id;
			setCookie('correctID',currentIndex,365);	
			//alert("char code "+selectedCharCode)
			var url = "GWS?alphabet="+obj.id;
			loadXMLDoc(url);
		}
	}
}
function findTheCharCode(str){
	var size = str.length;
	var retVal = -1;
	for(var k=0; k<size; k++){
		//alert("size "+size+" code  "+str.charCodeAt(k) +" counter  "+k );
		if(str.charCodeAt(k) > 64 && str.charCodeAt(k) <92){
			retVal =str.charCodeAt(k);
			break;
		}
	}
	return retVal;
}

function deActivateAll(){
	if(clickToStart==false){
		var arrLength = arr.length;
		var htmlStr4LineEle = "";
		var idForKeyBoardLi = 1;
		var aKeyIdLi = document.getElementById("keyboard");
		//alert("length = "+arrLength)
		for(var count=0;count<arrLength;count++){
			var val = eval("String.fromCharCode(" + (count+65) + ")");
			//alert(val);
			if(count >0){
				idForKeyBoardLi = (idForKeyBoardLi+arr[count-1]);
			}
			if(count==10){			
				htmlStr4LineEle = htmlStr4LineEle +"<li onmouseover='makeHand(this)' onmouseout='removeHand(this)' onclick='makeActiveInActive(this)' id="+(idForKeyBoardLi)+" class='secondrow'><p>"+val+"</p></li>";
			}else if(count==19){
				htmlStr4LineEle = htmlStr4LineEle +"<li onmouseover='makeHand(this)' onmouseout='removeHand(this)' onclick='makeActiveInActive(this)' id="+(idForKeyBoardLi)+" class='thirdrow'><p>"+val+"</p></li>";
			}else{
				htmlStr4LineEle = htmlStr4LineEle +"<li onmouseover='makeHand(this)' onmouseout='removeHand(this)' onclick='makeActiveInActive(this)' id="+(idForKeyBoardLi)+"><p>"+val+"</p></li>";
			}
			//alert(idForKeyBoardLi)
		}
		aKeyIdLi.innerHTML = htmlStr4LineEle;
	}
	//alert(htmlStr4LineEle)
}

function makeHand(obj){
	if(clickToStart==false){
		//alert("hello");
		if(document.getElementById("alphaBaticRadio").checked){
			obj.style.cursor = "pointer";
		}
	}
}
function makeHandForNextPrevRandom(obj){
	if(clickToStart==false){		
		obj.style.cursor = "pointer";
	}
}

function removeHand(obj){
	if(clickToStart==false){
		if(document.getElementById("alphaBaticRadio").checked){
			obj.style.cursor="auto";	
		}
	}
}

function changeState(obj){
	if(clickToStart==false){
		var seclectRandomFrom = document.getElementById("RandomSelectFrom");
		var seclectRandomTo = document.getElementById("RandomSelectTo");
		if(document.getElementById("alphaBaticRadio").checked){
			deActivateAll();
			var obj1 = document.getElementById("RandomSelectFrom"); 
			var sel1 = obj1.selectedIndex +1;
			var correctId = 1;			
			for(var k=0;k <sel1;k++){
				if(k > 0){
					correctId = correctId + arr[k-1] ;
				}
			}
			var obj = document.getElementById(correctId); 
			makeActiveInActive(obj);
			seclectRandomFrom.disabled=true;
			seclectRandomTo.disabled=true;
			document.getElementById('randomToFrom').style.visibility='hidden';
		}
		if(document.getElementById("randomRadio").checked){			
			deActivateAll();
			currentIndex=-1;
			callToChangeKeyRow('true');
			seclectRandomFrom.disabled=false;
			seclectRandomTo.disabled=false;
			document.getElementById('randomToFrom').style.visibility='visible';
		}
	}
}

function getCorrectIdForKeyRow(size){
	var correctId = 1;			
	for(var k=0;k <size;k++){
		if(k > 0){
			correctId = correctId + arr[k-1] ;
		}
	}
	return correctId;
}

function callToChangeKeyRow(isFormatReq){
	if(clickToStart==false){
		if(isFormatReq=="true"){
			deActivateAll();
		}
		//alert(obj[obj.selectedIndex].value);
		var innerHTMLVal  = "";
		var browser=navigator.appName;
		var b_version=navigator.appVersion;
		var version=parseFloat(b_version);
		var obj1 = document.getElementById("RandomSelectFrom"); 
		var obj2 = document.getElementById("RandomSelectTo");
		var sel1 = obj1.selectedIndex ;
		var sel2 = obj2.selectedIndex;
		var min =-1;
		var max=-1;
		//alert("len == "+len);
		
		//alert("1  "+(obj1.options[obj1.selectedIndex]).innerHTML)
		//alert("2  "+(obj2.options[obj2.selectedIndex]).innerHTML)
		//alert("correctId == "+correctId);
		//alert("innerHTMLVal == "+innerHTMLVal);
		var size = -1;
		var cnt = -1;
		if(sel1 >sel2){
			size = sel1;
			cnt = sel2;
		}else{
			size = sel2;
			cnt = sel1;
		}
		//alert("size  "+size);
		//alert("cnt  "+cnt);
		for(var count = cnt; count<size+1; count++){
			innerHTMLVal = eval("String.fromCharCode(" + (count+65) + ")");
			//alert("innerHTMLVal  "+innerHTMLVal)
			correctId =1;
			for(var k=0;k <count;k++){				
				correctId = correctId + arr[k] ;				
			}
			if(count==cnt){
				min = correctId;
			}
			//alert("correctId  "+correctId);
			if(isFormatReq=="true"){
				if (browser=="Microsoft Internet Explorer"){
					//alert("innerHTMLVal  "+innerHTMLVal)
					if(innerHTMLVal.indexOf("K")>-1){
						//alert("IE  Find K")
						document.getElementById(correctId).setAttribute("className", "active secondrow");
						//document.getElementById(obj.id).setAttribute("className", "secondrow");
					}else if(innerHTMLVal.indexOf("T")>-1){
						//alert("IE  Find T")
						document.getElementById(correctId).setAttribute("className", "active thirdrow");
						//document.getElementById(obj.id).setAttribute("className", "secondrow");
					}else{
						//alert("IE Else Find ")
						document.getElementById(correctId).setAttribute("className", "active");
					}
				}else if(browser=="Netscape"){
					//alert("innerHTMLVal "+innerHTMLVal);
					//alert("Mozila  Find T")
					if(innerHTMLVal.indexOf("K")>-1){
						//alert("Mozila  Find K")
						document.getElementById(correctId).setAttribute("class", "active secondrow");
						//document.getElementById(obj.id).setAttribute("className", "secondrow");
					}else if(innerHTMLVal.indexOf("T")>-1){
						//alert("Mozila  Find T")
						//alert("Find T")
						document.getElementById(correctId).setAttribute("class", "active thirdrow");
						//document.getElementById(obj.id).setAttribute("className", "secondrow");
					}else{
						//alert("Else  Find T")
						document.getElementById(correctId).setAttribute("class", "active");
					}
				}else{
					//alert("Else  Else  Find T")
					document.getElementById(correctId).setAttribute("class", "active");
				}
			}
		}
		max=correctId+arr[size]-1;
		//alert("min  "+min);
		//alert("max  "+max);
		var random = min + parseInt(Math.random()*(max-min));
		//alert("ran "+random);		
		var url = "GWS?alphabet="+random;
		loadXMLDoc(url);
	}	
}


function getCookie(correct_Id){
	if (document.cookie.length>0){
		c_start=document.cookie.indexOf(correct_Id + "=");
		if (c_start!=-1){ 
		    c_start=c_start + correct_Id.length+1; 
		    c_end=document.cookie.indexOf(";",c_start);
		    if (c_end==-1) c_end=document.cookie.length;
			    return unescape(document.cookie.substring(c_start,c_end));
   		} 
	}
	return "";
}

function setCookie(correct_Id,correct_Id_value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=correct_Id+ "=" +escape(correct_Id_value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function checkCookie(){
	correctId_Val=getCookie('correctID');
	if (correctId_Val!=null && correctId_Val!=""){

		//alert('Welcome again '+correctId_Val+'!'); Get the cookie
  	}else{
		//correctId_Val=prompt('Please enter your name:',"");
		// set the cookie...................
		if (correctId_Val!=null && correctId_Val!=""){
			setCookie('correctID',correctId_Val,365);
    	}
  	}
}
function checkCorrectIDCookie(){
	return getCookie('correctID');	
	// if cookie find return else set it to the blank
}
function makeActiveInActiveForCookie(obj,correctId){
	if(clickToStart==false){
		if(document.getElementById("alphaBaticRadio").checked){	
			//alert("Helllo----obj   "+obj);
			//alert("Helllo----correctId   "+correctId)	
			deActivateAll();	
			var innerHTMLVal  = document.getElementById(obj.id).innerHTML;
			var browser=navigator.appName;
			var b_version=navigator.appVersion;
			var version=parseFloat(b_version);
			//alert("ID == "+obj.id);
			if (browser=="Microsoft Internet Explorer"){
				if(innerHTMLVal.indexOf("K")>-1){
					//alert("Find K")
					document.getElementById(obj.id).setAttribute("className", "active secondrow");
					//document.getElementById(obj.id).setAttribute("className", "secondrow");
				}else if(innerHTMLVal.indexOf("T")>-1){
					//alert("Find T")
					document.getElementById(obj.id).setAttribute("className", "active thirdrow");
					//document.getElementById(obj.id).setAttribute("className", "secondrow");
				}else{
					document.getElementById(obj.id).setAttribute("className", "active");
				}
			}else if(browser=="Netscape"){
				//alert("innerHTMLVal "+innerHTMLVal);
				if(innerHTMLVal.indexOf("K")>-1){
					//alert("Find K")
					document.getElementById(obj.id).setAttribute("class", "active secondrow");
					//document.getElementById(obj.id).setAttribute("className", "secondrow");
				}else if(innerHTMLVal.indexOf("T")>-1){
					//alert("Find T")
					document.getElementById(obj.id).setAttribute("class", "active thirdrow");
					//document.getElementById(obj.id).setAttribute("className", "secondrow");
				}else{
					document.getElementById(obj.id).setAttribute("class", "active");
				}
			}else{
				document.getElementById(obj.id).setAttribute("class", "active");
			}
			innerHTMLVal = innerHTMLVal.substring(3,4);
			//alert("id == "+obj.id)
			currentIndex = correctId;				
			var selectedCharCode = findTheCharCode(innerHTMLVal);
			//alert(selectedCharCode +"   "+innerHTMLVal);
			maxRange = parseInt(obj.id) + arr[selectedCharCode-65]-1;
			minRange = obj.id;
			//alert("char code "+selectedCharCode)
			var url = "GWS?alphabet="+correctId;
			loadXMLDoc(url);
		}
	}
}
function defineInGoogleWord(){
	//alert('Define In Google')		 
	var googleURL = 'http://www.google.co.in/search?hl=en&q=';
	document.getElementById('googleExSearch').src = googleURL+'define: +'+WordName+'&meta=';
	document.getElementById('googleWordsSearch').innerHTML = '<p class="btxt16" style="font-size:22px;"><strong>'+WordName+'</strong> in context with <img src="images/google.gif" border="0" alt="Google" title="Google" style="vertical-align:middle" /></p>';
	document.getElementById("searchdiv").scrollIntoView();
}