/*
function generateTextbox() 
{
	//alert('fdfd');exit;
	var i = 1;
	//alert(i);
	var d=document.getElementById("question_add");
	//d.innerHTML+="<p><input type='text' name='food'>";
	while(i <= 15)
	{
		d.innerHTML+="Question"+i+". <input type='text' name='food'>\n";
		//document.write("<br />");	
		i++;
	}
	if(i == 15)
	{
		alert('You can add maximum 15 question!');	
	}
}*/

var num1 = 1;
function getFrontValues(base,id)
{
	
	new Ajax.Updater('user_edit',base+'/fanchallenges/frontview/'+id,{ frequency: 0,
		asynchronous:true, evalScripts:true
	}); 

}


function addElement(eno, obj)
{
    var theStatus_Status = document.getElementById("theStatus").value
	if(eno != 1 )
	{
		obj.parentNode.innerHTML = '<div class="addbtn"><a href="#" onclick="removeElement(this);">Remove</a></div>';
	}
	else
	{
		obj.parentNode.innerHTML = '<div class="addbtn"><a href="#" onclick="removeElementSelect(this);">Remove</a></div>';
	}
	if ( theStatus_Status == 'Yes')
	{
		document.getElementById('MainAddNode').style.display='none';
	}
	if(num1==eno)
	{
	  var ni = document.getElementById('question_add');
	  var numi = document.getElementById('theValue');
	  var num = (document.getElementById('theValue').value -1)+ 2;
	  num1 ++;
	  
	  if(num <= 14)
	  {
		  numi.value = num;
		  var divIdName = 'Question'+num;
	  
		  var newdiv = document.createElement('div');
		  newdiv.setAttribute('id',divIdName);
		  //newdiv.innerHTML = '<input type="text" name="question[]"> &nbsp;&nbsp;<a href=\'#\' onclick=\'removeElement("'+divIdName+'")\'>Remove "'+divIdName+'"</a>';
		  //newdiv.innerHTML = '<br/>'+ (num+1) + '<input type="text" name="question[]" size="50" class="textbox7">&nbsp;&nbsp;<a href="#" onclick="addElement();">Add</a>';
		  //newdiv.innerHTML = '<div class="liedetectorquesbox"><div class="quesno greybold15">'+ (num+1) + '.</div><div class="questextbox greybold15"><input type="text" name="question[]" size="50" class="textbox7"></div><div class="addbtn"><a href="#" onclick="addElement('+ num1 +');"><img src="/fanbase/img/addbtnon.gif" alt="Main Logo" title="Home" border="0"></a></div></div>';
	
			newdiv.innerHTML = '<div class="liedetectorquesbox"><div class="questextbox greybold15"><input type="text" name="question[]" size="50" class="textbox7"></div><div class="addbtn"><a href="#" onclick="addElement('+ num1 +',this);"><img src="/fanbase/img/addbtnon.gif" alt="Main Logo"  border="0"></a></div></div>';	  
					
		  ni.appendChild(newdiv);
	  }
	  else
	  {
		alert('You can add maximum 15 question!');
		
			if(document.getElementById('theValue').value>15)
			{
				document.getElementById('theValue').value=0;
			}  
	  }
 	}
}

function getQuestion(base,id)
{
	if(document.getElementById("theStatus").value == 'yes')
	{
		num = document.getElementById("theValue").value;  
  		document.getElementById("theValue").value =parseInt(num)+1;
  		document.getElementById("theStatus").value = 'No';
  	}	 
	 
	 new Ajax.Updater('question_fill',base+'/fans/getprev_question/'+id,{ frequency: 0,asynchronous:true, evalScripts:true	});
}

function PreviousLieDetector_OnChange(eno, obj) 
{
	
		var ni = document.getElementById('question_fill');
		var numi = document.getElementById('theValue');
		var num = (document.getElementById('theValue').value -1)+ 2;
		num1 ++;
		
		if(num <= 14)
		{
			numi.value = num;
			var divIdName = 'Question'+num;
			var newdiv = document.createElement('div');
			newdiv.setAttribute('id',divIdName);
			newdiv.innerHTML = '<div class="liedetectorquesbox"><div class="questextbox greybold15"><input type="text" value="'+ obj.options[obj.selectedIndex].text +'" name="question[]" size="50" class="textbox7"></div><div class="addbtn"><a href="#" onclick="removeElementSelect(this);">Remove</a></div></div>';	  
				
			ni.appendChild(newdiv);
		
		}
		else
		{
			
			alert('You can add maximum 15 question!');
			if(document.getElementById('theValue').value>15)
			{
			document.getElementById('theValue').value=0;
			}  
		}
		document.getElementById("theStatus").value = 'No';
	
}


function removeElement(obj) {
 
  //alert(obj);
  QuestionNode = obj.parentNode.parentNode.parentNode.parentNode; //a complete question division.
  var d = document.getElementById('question_add');
  //var olddiv = document.getElementById(divNum);
  //alert(olddiv);
  d.removeChild(QuestionNode);
  //	alert(document.getElementById("theValue").value);
  num = document.getElementById("theValue").value;  
  document.getElementById("theValue").value =num-1;
  
}

function removeElementSelect(obj) {
 // alert(obj);
  
  QuestionContainer = obj.parentNode.parentNode.parentNode; //a complete question division.
  TargetNode =  obj.parentNode.parentNode; // a complete divsion node of question.
  QuestionContainer.removeChild(TargetNode);
  
  
  //	alert(document.getElementById("theValue").value);
  num = document.getElementById("theValue").value;  
  document.getElementById("theValue").value =num-1;
  
}


function x(v)
{
	tmp1=document.getElementById('grp1'); 
	tmp2=document.getElementById('grp2'); 
	prz1=document.getElementById('prz1');
	prz2=document.getElementById('FanchallengePrize');
	if(v=="Prize")
	{
		tmp1.style.display = "none"; 
		tmp2.style.display = "none"; 
		prz1.style.display = "block"; 
		prz2.style.display = "block"; 
	}
	else if(v=="Trophy")
	{
		tmp1.style.display = "block";
		tmp2.style.display = "block";
		prz1.style.display = "none"; 
		prz2.style.display = "none"; 
	}
}

	


function getValues(base,id)
{
	
	new Ajax.Updater('user_edit',base+'/admin/fanchallenges/view/'+id,{ frequency: 0,
		asynchronous:true, evalScripts:true
	}); 

}


function x1(v)
{ 
	//alert(v);
	tmp1=document.getElementById('photo_div'); 
	tmp2=document.getElementById('video_div');
	/*tmp3=document.getElementById('grp3');
	tmp4=document.getElementById('grp4'); 
	tmp5=document.getElementById('grp5');
	tmp6=document.getElementById('grp6');
	//tmp2=document.getElementById('grp2'); 
	prz1=document.getElementById('prz1');
	prz2=document.getElementById('prz2');
	prz3=document.getElementById('prz3');
	prz4=document.getElementById('prz4');
	prz5=document.getElementById('prz5');
	prz6=document.getElementById('prz6');*/
	//prz2=document.getElementById('ImageName4');
	if(v==2)
	{
			
		//alert(v);
		tmp1.style.display = "none"; 
		tmp2.style.display = "block"; 
		/*tmp3.style.display = "block"; 
		tmp4.style.display = "block"; 
		tmp5.style.display = "block"; 
		tmp6.style.display = "block"; 
		//tmp2.style.display = "none"; 
		prz1.style.display = "none";
		prz2.style.display = "none";
		prz3.style.display = "none";
		prz4.style.display = "none";
		prz5.style.display = "none";
		prz6.style.display = "none";*/
		
		//prz2.style.display = "block"; 
		//prz2.style.display = "none"; 
	
		
	}
	else if(v==1)
	{
		
		tmp1.style.display = "block"; 
		tmp2.style.display = "none"; 
		/*tmp1.style.display = "none"; 
		tmp2.style.display = "none"; 
		tmp3.style.display = "none"; 
		tmp4.style.display = "none"; 
		tmp5.style.display = "none"; 
		tmp6.style.display = "none"; 
		//tmp2.style.display = "none"; 
		prz1.style.display = "block";
		prz2.style.display = "block";
		prz3.style.display = "block";
		prz4.style.display = "block";
		prz5.style.display = "block";
		prz6.style.display = "block";*/
	}
	
	
}

function x11(v)
{ 
	tmp1=document.getElementById('photo_div'); 
	tmp2=document.getElementById('video_div');
	if(v=='Filmmaker')
	{
		tmp1.style.display = "none"; 
		tmp2.style.display = "block"; 
	}
	else if(v=='Photographer')
	{
		tmp1.style.display = "block"; 
		tmp2.style.display = "none"; 
	}
}

function xxx(v)
{ 
	tmp1=document.getElementById('zip_div'); 
	tmp2=document.getElementById('city_div');
	if(v!='United States')
	{
		tmp1.style.display = "none"; 
		tmp2.style.display = "block"; 
	}
	else
	{
		tmp2.style.display = "none"; 
		tmp1.style.display = "block"; 
	}
}

function doSearch(base,id)
{
			
		//alert(base);
		//alert(id);
		//alert(document.getElementById('UserZip').value);
		id=document.getElementById('UserZipcodeId').value;
		if(id.length==5 || id.length==9)
		{
			new Ajax.Updater('city_state',base+'/photographers/zip/'+id,{ frequency: 0,asynchronous:true, evalScripts:true}); 
		}
		else
		{
			//x.innerHTML="Please Enter Valid Zipcode";
			x=document.getElementById("city_state");
			x.innerHTML="";
		
		}
}

function city_uszip(country)
{
	zip=document.getElementById('zip_div'); 
	city=document.getElementById('city_state'); 
	//alert(v);
	if(country!="United States")
	{
		city.style.display = "block"; 	
		zip.style.display = "none"; 	
	}
	else
	{
		city.style.display = "none"; 	
		zip.style.display = "block"; 	
	}
	
}

function getres(id,base)
{
	new Ajax.Updater('poll_result',base+'/celebrities/getpollresult/'+id,{ frequency: 0,
		asynchronous:true, evalScripts:true
	});
}

function getprevPoll(id,base)
{
	//alert(id);
	new Ajax.Updater('previous_poll',base+'/celebrities/getpreviousPoll/'+id,{ frequency: 0,
		asynchronous:true, evalScripts:true
	});
}



function getTextbox(base)
{
	//alert(id);alert(base);
	new Ajax.Updater('question_add',base+'/fans/getprev_question/',{ frequency: 0,
		asynchronous:true, evalScripts:true
	});
}