/*
(C) AEwebworks Software Development Ltd., 2002-2003
IMPORTANT: This is a commercial software product and any kind of using it must agree
to the AEwebworks Software Development Ltd. license agreement. It can be found at
http://www.aewebworks.com/license.htm
This notice may not be removed from the source code.
*/

/**
 * Checks/unchecks all tables
 *
 * @param   string   the form name
 * @param   boolean  whether to check or to uncheck the element
 *
 * @return  boolean  always true
 */
 var frmID="";
/////////////////////////////////////////////////////////////////////////////// AJAX FUNCTIONS ////////////////////
var xmlHttp

function getDisabled(i)
{
	if(i=='United States')
	{
		document.form1.distance.disabled = false;
		document.form1.Zipcode.disabled = false;
		document.form1.state.disabled = false;
		document.form1.scan_by[0].disabled = false;
		document.form1.scan_by[1].disabled = false;
		document.form1.scan_by[2].disabled = false;
		document.getElementById("div_scan_by").style.display="";
	}
	else
	{
		document.form1.scan_by[0].disabled = true;
		document.form1.scan_by[1].disabled = true;
		document.form1.scan_by[2].disabled = true;
		document.form1.distance.disabled = true;
		document.form1.Zipcode.disabled = true;
		document.form1.state.disabled = true;
		document.getElementById("div_scan_by").style.display="none";
		document.getElementById("div_zip").style.display="none";
		document.getElementById("div_state").style.display="none";
	}
}
function scan_by_chioce(i)
{
	if(i=='zip_code')
	{
		document.form1.distance.disabled = false;
		document.form1.Zipcode.disabled = false;
		document.form1.state.disabled = true;
		document.getElementById("div_zip").style.display="";
		document.getElementById("div_state").style.display="none";
	}
	else if(i=='state')
	{
		document.form1.distance.disabled = true;
		document.form1.Zipcode.disabled = true;
		document.form1.state.disabled = false;
		document.getElementById("div_state").style.display="";
		document.getElementById("div_zip").style.display="none";
	}
	else
	{
		document.form1.distance.disabled = true;
		document.form1.Zipcode.disabled = true;
		document.form1.state.disabled = true;
		document.getElementById("div_zip").style.display="none";
		document.getElementById("div_state").style.display="none";
	}
}
function showCustomer(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="getcustomer.php";
document.getElementById("double_click").innerHTML="<h3>TO READ A FAN-FIC,<BR>DOUBLE-CLICK ANY HIGHLIGHTED TITLE</h3>";
url=url+"?fanfic_id="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
////////////////////////////////////////////////// FUNCTION FOR SHOW NICK NAMES /////////////////////
function show_nickname(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="getcustomer.php";
url=url+"?nickname="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged2;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////// FUNCTION FOR SHOW NICK NAMES IN ADMIN/////////////////////
function show_gnickname(str,moveto)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var gurl=moveto;
gurl=gurl+"?nickname="+str;
gurl=gurl+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged2;
xmlHttp.open("GET",gurl,true);
xmlHttp.send(null);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////// FUNCTION FOR SHOW FANFIC TITLE IN ADMIN /////////////////////
function show_fanfic(str,moveto)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var furl=moveto;
furl=furl+"?fanfic="+str;
furl=furl+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged2;
xmlHttp.open("GET",furl,true);
xmlHttp.send(null);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
function showUnconfMsg()
{
	alert("NOT YET!\n\nEnter your info BELOW and click SUBMIT to complete your membership.");
}
////////////////////////////////////////////////// FUNCTION FOR OPEN A NEW WINDOW ////////////////////
function open_new_window(url)
{
	//alert(url);
	window.open(url,null,"");
	//window.open(url);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////

/////////// FUNCTION FOR COPYING BILLING ADDRESS TO SHIPPING ADDRESS///////////////////////////////////
function copyField()
{
	var field_name = new Array("user_first_name","user_last_name","user_address1","user_address2","user_city","user_state","user_country","user_pin","user_email","user_phone");
	if(document.getElementById("copyfield").checked)
	{
		for(x in field_name)
		{
			document.getElementById("s_"+field_name[x]).value=document.getElementById(field_name[x]).value;			
		}
	}
	else
	{
		for(x in field_name)
		{
			document.getElementById("s_"+field_name[x]).value="";
		}			
	}
}
/////////// FUNCTION FOR COPYING BILLING ADDRESS TO SHIPPING ADDRESS///////////////////////////////////
/////////// FUNCTION FOR UNCHECKED THE ANY OPTION IN MEMBER SEARCH WHEN OTHER OPTIONS ARE SELECTED //////////////////////
function uncheck_any(FieldName,indexNo)
{
	//alert(FieldName);
	var tempL;
	tempL = document.forms["form1"][FieldName].length-1;
	if(document.forms["form1"][FieldName][indexNo].checked)
	{
		if(document.forms["form1"][FieldName][tempL].checked)
		{
			document.forms["form1"][FieldName][tempL].checked=false;
		}
	}
}
/////////// FUNCTION FOR UNCHECKED THE ANY OPTION IN MEMBER SEARCH WHEN OTHER OPTIONS ARE SELECTED //////////////////////
function chk_productExist(val)
{
		if(document.getElementById(val).value=="1")
		{
				alert("Product already in cart!");
				return false;
		}
}
function IsNumeric(sText)

{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
		//alert("good");	 
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }


function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("blurb_text").innerHTML=xmlHttp.responseText;
}
}
function stateChanged2() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("show_nick_names").innerHTML=xmlHttp.responseText;
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
/////////////////////////////////////////////////////////////////////////////////// AJAX FUNCTIONS ///////////////////
function setCheckboxes(the_form, do_check)
{
    var elts      = document.forms[the_form].elements;
    var elts_cnt  = elts.length;
	
    for (var i = 0; i < elts_cnt; i++) {
        elts[i].checked = do_check;
		if (the_form + "_submit" == elts[i].name) {
			elts[i].disabled = !do_check;
		}
    } // end for

    return true;
} // end of the 'setCheckboxes()' function
//#####################################################################################//
function admincBox(cbox)
{
	var cbxval  = cbox.value;
	if(cbxval=='on')
	{
		var cbxval_cnt  = prf_form.prf_form_submit.length;
		//alert(cbxval_cnt);
		for (var i=0;i<cbxval_cnt;i++)
		{
			prf_form.prf_form_submit[i].disabled = false;
		}
	}
	else
	{
		
	}
}

//#####################################################################################//
function setCheckbox(the_form)
{
    var elts      = document.forms[the_form].elements;
    var elts_cnt  = elts.length;
    
    var allUnchecked = true;
	
    for (var i = 0; i < elts_cnt; i++)
    {
        if(elts[i].checked) allUnchecked = false;
    }
    
    for (var i = 0; i < elts_cnt; i++)
    {
        if(elts[i].name == (the_form + "_submit")) elts[i].disabled = allUnchecked;
    }

    return true;
}


var win = "width=400,height=500,left=100,top=100,copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes";
function get_gallery(id_prof)
{
   window.open("photos_gallery.php?ID="+id_prof,'gallery',win);
}

function launchTellFriend ()
{   
    var win = "width=250,height=260,left=200,top=100,copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=no";
    window.open("tellfriend.php",'tellfriend',win);
    return false;
}

function launchTellFriendProfile ( sID )
{
    var win = "width=300,height=300,left=0,top=100,copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes";
    window.open("tellfriend.php?ID="+sID,'tellfriendprofile',win);
    return false;
}

function ShowShowHide ( show_name, show_name2, hide_name )
{
    if (hide_name) hide_name.style.display = 'none';
    if (show_name) show_name.style.display = 'inline';
    if (show_name2) show_name2.style.display = 'inline';
}

function ShowHideHide ( show_name, hide_name, hide_name2 )
{
    if (hide_name) hide_name.style.display = 'none';
    if (hide_name2) hide_name2.style.display = 'none';
    if (show_name) show_name.style.display = 'inline';
}


/**
 * change images onHover mouse action
 */
function show(FileName,jpg1Name)
{
	document.images[FileName].src = jpg1Name;
}

/**
 * set status of the browser window to 's'
 */
function ss(s) 
{
	window.status = s;
	return true;
}

/**
 * set status of the browser window to empty
 */
function ce()
{
	window.status='';
}


/**
 * insert emotion item
 */
function emoticon( txtarea, text ) {

	text = ' ' + text + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
		txtarea.focus();
	} else {
		txtarea.value  += text;
		txtarea.focus();
	}
}

function launchAddToIM (id)
{
    var win = "width=600,height=160,left=100,top=100,copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes";
    window.open("explanation.php?explain=imadd&ID="+id,'add_to_im',win);
    return false;
}

function docOpen(text)
{
	newWindow=window.open('','','toolbar=no,resizable=yes,scrollbars=yes,width=400,height=300');
	newWindow.document.open("text/html");
	newWindow.document.write(unescape(text));
	newWindow.document.close();
}

function StripSpacesFromEnds(s)
{
	while((s.indexOf(' ',0) == 0) && (s.length> 1))
	{
		s = s.substring(1,s.length);
	}
	while((s.lastIndexOf(' ') == (s.length - 1)) && (s.length> 1))
	{
		s = s.substring(0,(s.length - 1));
	}
	if((s.indexOf(' ',0) == 0) && (s.length == 1)) s = '';
	return s;
}

    function createRequestObject() 
	{ 
       var req; 
       if(window.XMLHttpRequest){ 
          // Firefox, Safari, Opera... 
          req = new XMLHttpRequest(); 
       } else if(window.ActiveXObject) { 
          // Internet Explorer 5+ 
          req = new ActiveXObject("Microsoft.XMLHTTP"); 
       } else { 
          // There is an error creating the object, 
          // just as an old browser is being used. 
          alert('Problem creating the XMLHttpRequest object'); 
       } 
       return req;
    } 
    // Make the XMLHttpRequest object 
    var http = createRequestObject(); 
    
    function sendRequest(zipcode)
	{ 
	   // Open PHP script for requests
	   var zipval = zipcode.value;
	   //alert(zipval);
       http.open('get', 'validate_zip.php?zipcode='+zipval);
       http.onreadystatechange = handleResponse;
       http.send(null);
    }
	function handleResponse() 
	{ 
       if(http.readyState == 4 && http.status == 200){ 
          // Text returned FROM the PHP script 
          var response = http.responseText; 
          if(response) { 
             // UPDATE ajaxTest content 
             //document.getElementById("searchResults").innerHTML = response; 
			 alert(response);
			 //document.getElementById('zip').focus();
          } 
       } 
    }
	function sendNickname(nickname)
	{ 
	   // Open PHP script for requests
	   var nickval = nickname.value;
	   //alert(zipval);
       http.open('get', 'validate_nickname.php?nickname='+nickval);
       http.onreadystatechange = handleNick;
       http.send(null);
    }
	function handleNick() 
	{ 
       if(http.readyState == 4 && http.status == 200){ 
          // Text returned FROM the PHP script 
          var nick_response = http.responseText; 
          if(nick_response) { 
             // UPDATE ajaxTest content 
             //document.getElementById("searchResults").innerHTML = response; 
			 alert(nick_response);
			 document.getElementById('ID').focus();
          } 
       } 
    }
function chkValidation(frmId)
{
	frm = document.getElementById(frmId)
	var checkSelected = false;
	var workSelected = false;
	var petSelected = false;
	var langSelected = false;
	if(!frm.warrant.checked)
	{   alert("Please Accept the legal warrning!!!! ")
	  	frm.warrant.focus();
		return false;
	}
	if (!frm.whois[0].checked && !frm.whois[1].checked && !frm.whois[2].checked && !frm.whois[3].checked )
	{
    	alert("Please choose an option from Who is section to continue.\n");
		frm.whois[0].focus();
    	return false;
    }
	if(frm.country.value!="United States")
	{
		if(document.getElementById("state_text").value=="")
		{
			alert("Please Fill Your State/Province to continue registration.\n");
			document.getElementById("state_text").focus();
			return false;
		}
	}
	if(frm.City.value=="")
	{
		alert("Please Fill Your City to continue registration.\n");
		frm.City.focus();
    	return false;
	}
	if(frm.country.value=="United States")
	{
		if(frm.zip.value=="")
		{
			alert("Please Fill Your Zip Code to continue registration.\n");
			frm.zip.focus();
			return false;
		}
		if(isNaN(frm.zip.value))
		{
			alert("Zip Code must be in numbers.\n");
			frm.zip.focus();
			return false;
		}
		
	}
	if (!frm.life[0].checked && !frm.life[1].checked && !frm.life[2].checked && !frm.life[3].checked && !frm.life[4].checked && !frm.life[5].checked && !frm.life[6].checked && !frm.life[7].checked && !frm.life[8].checked)
	{
    	alert("Please choose an option from My Life Form section to continue.\n");
		frm.life[0].focus();
    	return false;
    }
	/*if (!frm.typical_style[0].checked && !frm.typical_style[1].checked && !frm.typical_style[2].checked && !frm.typical_style[3].checked && !frm.typical_style[4].checked&& !frm.typical_style[5].checked && !frm.typical_style[6].checked&& !frm.typical_style[7].checked && !frm.typical_style[8].checked&& !frm.typical_style[9].checked && !frm.typical_style[10].checked)
	{
    	alert("Please choose an option from Typical Style section to continue.\n");
		frm.typical_style[0].focus();
    	return false;
    }*/
	if (!frm.mystatus[0].checked && !frm.mystatus[1].checked && !frm.mystatus[2].checked && !frm.mystatus[3].checked && !frm.mystatus[4].checked && !frm.mystatus[5].checked && !frm.mystatus[6].checked)
	{
    	alert("Please choose an option from My Status section to continue.\n");
		frm.mystatus[0].focus();
    	return false;
    }
	/*if (!frm.smoking[0].checked && !frm.smoking[1].checked && !frm.smoking[2].checked)
	{
    	alert("Please choose an option from Smoking section to continue.\n");
		frm.smoking[0].focus();
    	return false;
    }
	if (!frm.Drinking[0].checked && !frm.Drinking[1].checked && !frm.Drinking[2].checked && !frm.Drinking[3].checked)
	{
    	alert("Please choose an option from Drinking section to continue.\n");
		frm.Drinking[0].focus();
    	return false;
    }
	if (!frm.Offspring[0].checked && !frm.Offspring[1].checked && !frm.Offspring[2].checked && !frm.Offspring[3].checked)
	{
    	alert("Please choose an option from Offspring section to continue.\n");
		frm.Offspring[0].focus();
    	return false;
    }
	if (!frm.Living_Sitch[0].checked && !frm.Living_Sitch[1].checked && !frm.Living_Sitch[2].checked && !frm.Living_Sitch[3].checked)
	{
    	alert("Please choose an option from Living Sitch section to continue.\n");
		frm.Living_Sitch[0].focus();
    	return false;
    }
	if (!frm.Faith[0].checked && !frm.Faith[1].checked && !frm.Faith[2].checked && !frm.Faith[3].checked && !frm.Faith[4].checked&& !frm.Faith[5].checked && !frm.Faith[6].checked&& !frm.Faith[7].checked && !frm.Faith[8].checked&& !frm.Faith[9].checked && !frm.Faith[10].checked && !frm.Faith[11].checked && !frm.Faith[12].checked && !frm.Faith[13].checked && !frm.Faith[14].checked && !frm.Faith[15].checked && !frm.Faith[16].checked)
	{
    	alert("Please choose an option from Faith section to continue.\n");
		frm.Faith[0].focus();
    	return false;
    }
	if (!frm.Politics[0].checked && !frm.Politics[1].checked && !frm.Politics[2].checked && !frm.Politics[3].checked && !frm.Politics[4].checked&& !frm.Politics[5].checked && !frm.Politics[6].checked&& !frm.Politics[7].checked)
	{
    	alert("Please choose an option from Politics section to continue.\n");
		frm.Politics[0].focus();
    	return false;
    }*/
}
	
		var count;		
		count=0;	
function checkmax(id)
{
		if(document.getElementById(id).checked)
		{
				count++;
		}	
		if(!document.getElementById(id).checked)				
		{
				count--;
		}
		
		if(count>2)
		{
				alert("Two Choices Max");				
				document.getElementById(id).checked=false;
				count--;
				return false;
		}
		return true;
}
function chkTerm(id)
{
		if(document.getElementById(id).checked)
		{
				count++;
		}	
		if(!document.getElementById(id).checked)				
		{
				count--;
		}
		
		if(count>2)
		{
				alert("Please select maximum 2 choises!");				
				document.getElementById(id).checked=false;
				count--;
				return false;
		}
		return true;
}
function chkbox()
{
		tagline = StripSpacesFromEnds(document.form2.para_tagline.value);
		self = StripSpacesFromEnds(document.form2.para_self.value);
		looking_for = StripSpacesFromEnds(document.form2.para_looking_for.value);
		if(tagline.length==0)
		{
			alert("Tagline is required");
			document.form2.para_tagline.focus();
			return false;
		}
		if(self.length==0)
		{
			alert("Paragraph about your awesome SOUL GEEK self cannot be left blank");
			document.form2.para_self.focus();
			return false;
		}
		if(looking_for.length==0)
		{
			alert("Paragraph about your awesome SOUL GEEK you are looking for cannot be left blank");
			document.form2.para_looking_for.focus();
			return false;
		}
		if(document.getElementById("Terms_Of_Service").checked==false)
		{
				alert("Please accept the Terms Of Service");
				return false;
		}
		if(document.getElementById("Privacy_Policy").checked==false)
		{
				alert("Please accept the Privacy Policy");
				return false;
		}
		if(document.getElementById("safety_disclaimer").checked==false)
		{
				alert("Please accept the Safety Tips Disclaimer");
				return false;
		}
	return true;
}
function showhide(one)
{
		if(document.getElementById(one).style.display=="none")
		{
			document.getElementById(one).style.display="block";
		}
		else if(document.getElementById(one).style.display=="block")
		{
			document.getElementById(one).style.display="none"
		}			
}
function joinform_disable()
{
		var q = document.form4.Sign_me_up_as_a.value;
		
		if(q=="UBER MEMBER")
		{
			//document.form4.Shirt_size1.disabled = false;
			//document.form4.Shirt_size2.disabled = false;
			document.form4.Credit_Card_Type.disabled = false;
			document.form4.Credit_Card_Number.disabled = false;
			document.form4.Card_Code.disabled = false;
			document.form4.Expiration_date_month.disabled = false;
			document.form4.Expiration_date_year.disabled = false;
			document.form4.premiumfee.disabled = false;
		}
		else
		{
			//document.form4.Shirt_size1.disabled = true;
			//document.form4.Shirt_size2.disabled = true;
			document.form4.Credit_Card_Type.disabled = true;
			document.form4.Credit_Card_Number.disabled = true;
			document.form4.Card_Code.disabled = true;
			document.form4.Expiration_date_month.disabled = true;
			document.form4.Expiration_date_year.disabled = true;
			document.form4.premiumfee.disabled = true;
		}			
}
function change_state()
{

	//.options[document.getElementById(country).selectedIndex].value);
}

function congrats(formName)
{
	window.location.href="congrats.php";
}

function chkEmail(form)
{	
	var addweb=form;
	em=addweb.Email.value;
	s = StripSpacesFromEnds(addweb.nickname.value);
	//alert(s);
	
	tr = (em.indexOf("@",1)>0) ? em.indexOf(".",3) : -1;
	if(s.length==0)
	{
		alert("Please Enter Nick Name!!!! ")
	  	addweb.nickname.focus();
		return false;
	}
	if (tr<3)
	{
	//alert('WARNING – MAKE SURE YOUR E-MAIL ADDRESS IS VALID AND ACCURATELY SPELLED – ONE TYPO AND YOU COULD BE WAITING AS LONG AS IT TAKES FOR LUCAS TO COME OUT WITH ANOTHER STAR WARS BOX SET AND YOU STILL WON’T GET A PASSWORD!!!');
    alert("Email address is incorrect!");
	addweb.Email.focus();
	return false;
	}
	if(addweb.Email.value!=addweb.Email2.value)
	{
		alert('Email address mismatch!!!');
		addweb.Email2.focus();
		return false;
	}
	return true;
}
function chkFriendEmail(form)
{	
	var friendweb=form;
	em=friendweb.femail.value;
	s = StripSpacesFromEnds(friendweb.urname.value);

	tr = (em.indexOf("@",1)>0) ? em.indexOf(".",3) : -1;
	if(s.length==0)
	{
		alert("Please Enter Your Name!!!! ")
	  	friendweb.urname.focus();
		return false;
	}
	if (tr<3)
	{
		//alert('WARNING – MAKE SURE YOUR E-MAIL ADDRESS IS VALID AND ACCURATELY SPELLED – ONE TYPO AND YOU COULD BE WAITING AS LONG AS IT TAKES FOR LUCAS TO COME OUT WITH ANOTHER STAR WARS BOX SET AND YOU STILL WON’T GET A PASSWORD!!!');
		alert("Email address is incorrect!");
		friendweb.femail.focus();
		return false;
	}
	return true;
}
function mailform(i,j)
{
	//alert(i.value);
	if(i.value=="yes")
	{
		//alert("hello");
		window.location.href="login_membership.php";
	}
	else
	{
		j.style.display = "inline";
	}
}
/*function gotokey(whichpage)
{	
	alert("yes");
	alert(whichpage);
	if(whichpage=="gotokeywordpage")
	{
		document.form1.action="keywords.php";
	}
	else if(whichpage=="bykeyword")
	{
		document.form1.action="member_search_result.php";
	}
	document.form1.submit;
}*/
function chkpass(form1)
{	

em=form1.Email.value;

	tr = (em.indexOf("@",1)>0) ? em.indexOf(".",3) : -1;

	if (tr<3)
	{

	 alert("Email address is incorrect!");
	form1.Email.focus();
	return false;
	}

if(form1.Password.value!=form1.rPassword.value)
		{
			
			alert('Password mismatch!!!');
			form1.rPassword.focus();
			return false;
			 
		}
	return true;
}
function textCounter(field,cntfield,maxlimit) 
{
if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
else
	cntfield.value = maxlimit - field.value.length;
}
function feed_keyword(value,idd)
{		
		var hidden_keywords;
		var indexof;
		var count_coma;
		//alert("value=>"+value);
		hidden_keywords = document.getElementById("hidden_keywords").value;
		indexof=hidden_keywords.indexOf(value);
		
		//alert("index of="+indexof);
		if(indexof<0)
		{
			count_coma = hidden_keywords.split(",");
			//alert(count_coma.length);
			if(count_coma.length<=6)
			{
				idd.style.color="#993366";
				document.getElementById("hidden_keywords").value=document.getElementById("hidden_keywords").value + value + ",";	
			}
			
		}
		else
		{
			value = value+",";
			temp = hidden_keywords.replace(value,"");
			document.getElementById("hidden_keywords").value = temp;			
			//alert("else hidden value=" + temp);
			idd.style.color="#0000FF";
		}
}
function gotokey(whichpage)
{	
	//alert(whichpage);
	if(whichpage=="gotokeywordpage")
	{
		document.form1.action="keywords.php";
	}
	else if(whichpage=="gotokeywordpage")
	{
		document.form1.action="member_search_result.php";
	}
	else if(whichpage=="gobacktosearch")
	{
		//alert("chala");
		document.keywordform.action="member_search.php";
		document.keywordform.submit;
	}

	document.form1.submit;
}
function keyword_form_submit(alph)
{
	hidden_keywords = document.getElementById("hidden_keywords").value;	
	location.href="keywords.php?alphabet=" + alph + "&hidden_keywords=" + hidden_keywords + "&keywords_one=" + document.getElementById("keywords_one").value;		
}

function closingwindow()
	{
	   var returnValue = window.showModalDialog('theUrl.php?page=aboutus&buttonvalue=close', null,'dialogHeight: 140px; dialogWidth: 430px; center: Yes; help: No; resizable: No; status: No;'); 	
	  if(returnValue=='1')
			  {
				  document.frmaboutus.target="_self";
				  window.close();
				  return true;
			  }
			if(returnValue=='2')
			  {
				 return false;
			  }
	}
	
	function chkUpload(form,ind)
	{
		var frm = form;
		
		var index = ind;
	
		if(document.getElementById(index).value=="")
		{
		alert("Please select a file to upload.");	 
		  return false;	
		}
		 return true;
	}
	
	function confnickname()
	{
		var nickname = document.compose_form.ID.value;
		var subject = document.compose_form.subject.value;
		if(nickname=="")
		{
			alert("Enter a Nickname");	
			document.compose_form.ID.focus();
			return false;
		}
		else if(subject=="")
		{
			alert("Enter a Subject");
			document.compose_form.subject.focus();
			return false;
		}
		else
		{
			if (confirm("ARE YOU SURE YOU WANT TO SEND THIS MESSAGE ?"))
			{
				return true;	
			}
			else
			{
				return false;
			}
		}
	}
	
	function chkfanficsave()
	{
		if(document.addfanficform.title.value=="")
		{
			alert("Enter Fan-Fic Title!!!");	
			return false;
		}
		else
		{
			return true;	
		}
	}
	function chkfanficpost()
	{
		if(document.addfanficform.title.value=="")
		{
			alert("Enter Fan-Fic Title!!!");	
			return false;
		}//addfanficform.chtitle.disabled = true
		else if(document.addfanficform.entrytype.value!=0)
		{
			if(document.addfanficform.chtitle.disabled==false)
			{
				if(document.addfanficform.chtitle.value=="")
				{
					alert("Enter Chapter Title!!!");	
					return false;
				}
			}
		}
		else if(document.addfanficform.inspiredby.value=="")
		{
			alert("Enter Inspired By!!!");	
			return false;
		}
		else if(document.addfanficform.disclaimer.value=="")
		{
			alert("Enter Disclaimer!!!");	
			return false;
		}
		else if(document.addfanficform.about.value=="")
		{
			alert("Enter WHAT MY FANFIC IS ABOUT?");	
			return false;
		}
		else if(document.addfanficform.wabout.value=="")
		{
			alert("Enter WHY I WROTE THIS?");	
			return false;
		}
		/*else if(document.addfanficform.compose.value=="")
		{
			alert("Enter COMPOSE FAN-FIC!!!");	
			return false;
		}*/
		else
		{
			return true;	
		}
	}
	function chkffsave()
	{
		if(document.addfanficform.inspiredby.value=="")
		{
			alert("Enter Inspired By!!!");	
			return false;
		}
		else if(document.addfanficform.disclaimer.value=="")
		{
			alert("Enter Disclaimer!!!");	
			return false;
		}
		else if(document.addfanficform.about.value=="")
		{
			alert("Enter WHAT MY FANFIC IS ABOUT?");	
			return false;
		}
		else if(document.addfanficform.wabout.value=="")
		{
			alert("Enter WHY I WROTE THIS?");	
			return false;
		}
		else
		{
			return true;	
		}
	}
	function showchtitle(j)
	{
		var sel = document.addfanficform.entrytype.value;
		if(sel != 0)
		{
			j.style.display = "inline";
		}
		else
		{
			j.style.display = "none";
		}
	}
	function showftitle(j)
	{
		var sel = document.addfanficform.selfanfic.value;
		if(sel != 'new')
		{
			j.style.display = "none";
		}
		else
		{
			j.style.display = "inline";
		}
	}
	function ffchknone()
	{
		if(document.addfanficform.none.checked)
		{
			document.addfanficform.chtitle.disabled = true;
		}
		else
		{
			document.addfanficform.chtitle.disabled = false;
		}
	}
	function ffnone()
	{
		if(document.addfanficform.none.checked)
		{
			document.addfanficform.chtitle.disabled = true;
		}
		else
		{
			document.addfanficform.chtitle.disabled = false;
		}
	}
	function confdelfanfic(agree)
	{
   		if (agree==1)
		{
			chkid = document.ffconfirm.fanficid.value;
			window.close();
		}
		else
		{
			chkid = document.ffconfirm.fanficid.value;
			//objectid = document.frmconfirm.objectid.value;
			//ownerid = document.frmconfirm.ownerid.value;
			window.opener.location="fanfic.php?delete=yes&ffid="+chkid;
			window.close();
		}
	}
	
	function showmgtable(i,j,k,l)
	{
		//alert(k.value);alert(l.value);
		if(i.value=="EG")
		{
			j.style.display = "none";
			k.disabled = false;
			l.disabled = false;
		}
		else
		{
			j.style.display = "inline";
			k.disabled = true;
			l.disabled = true;
		}
	}
	
	function subMG(k,l,status,status2,status3)
	{
		if(status || status2 || status3){
			k.disabled = false;
			l.disabled = false;
		}else{
			k.disabled = true;
			l.disabled = true;
		}
	}
	
	function scanmgtable(i,j)
	{
		//alert(k.value);alert(l.value);
		if(i.value=="MG")
		{
			j.style.display = "inline";
		}
		else
		{
			j.style.display = "none";
		}
	}
	
	var CatText=new Array();
	var CatId=new Array();
	var rowid = "";
	function setText(obj,totalval)
	{
		//rowid = parseInt(obj.id);
		if(rowid=="0")
		{
			document.getElementById(rowid).style.backgroundColor="";
		}
		if(rowid != "" && parseInt(rowid) != parseInt(obj.id))
		{
			document.getElementById(rowid).style.backgroundColor="";	
		}
		
		//alert(rowid);
		//alert(totalval)
		var style2;
				
		style2 = obj.style;
		style2.backgroundColor = style2.backgroundColor? "":"#D09FFD";
		//alert(CatText[obj.id]);
		document.getElementById("commentval").innerHTML = CatText[obj.id];
		
		//document.getElementById("imggallery").href = 'gallery.php?category='+CatId[obj.id]+'&owner='+ownerid+'';
		rowid = obj.id;
	}
//function for Album comments 
	var AlText=new Array();
	var AlId=new Array();
	var arowid = "";
	function setAText(obj,totval)
	{
		if(arowid=="0")
		{
			document.getElementById(arowid).style.backgroundColor="";
		}
		if(arowid != "" && parseInt(arowid) != parseInt(obj.id))
		{
			document.getElementById(arowid).style.backgroundColor="";	
		}
		//alert(arowid);
		//alert(totval);
		var style2;
		
		style2 = obj.style;
		style2.backgroundColor = style2.backgroundColor? "":"#D09FFD";
		//alert(style2.backgroundColor);
		document.getElementById("acommentval").innerHTML = AlText[obj.id];
		//alert(AlId[obj.id]);
		
		//document.getElementById("aimggal").href = 'gallery.php?edit_objects='+AlId[obj.id]+'&owner='+ownerid+'';
		//document.getElementById("aimggallery").href = 'gallery.php?category='+catgalleryid+'&albom='+AlId[obj.id]+'&owner='+ownerid+'';
		arowid = obj.id;
		
	}
//ends here

	function confirmSubmit(agree)
	{
   		if (agree==1)
		{
			chkid = document.frmconfirm.frmid.value;
			window.close();
		}
		else
		{
			chkid = document.frmconfirm.frmid.value;
			objectid = document.frmconfirm.objectid.value;
			ownerid = document.frmconfirm.ownerid.value;
			if(objectid && ownerid)
			{
				//alert(objectid);
				//alert(ownerid);
				window.opener.location="gallery.php?delete="+objectid+"&owner="+ownerid;
				window.close();
			}
			else
			{
				window.opener.document.getElementById(chkid).submit();
				window.close();
			}
		}
	}
	
	function setLink(j)
	{
		var owner = document.catform.owner.value;
		var totalcat = document.catform.totcat.value;
		if (!document.catform.choice[0].checked && !document.catform.choice[1].checked && !document.catform.choice[2].checked )
		{
    		alert("Please choose a option to continue.\n");
    		return false;
    	}
		if(document.catform.choice[0].checked)
		{
			window.location.href="gallery.php?edit_categories="+owner;
		}
		else if(document.catform.choice[1].checked)
		{
			if(totalcat > 0)
			{
				j.style.display = "inline";
			}
			else
			{
				alert("First, Create a Category!");
				return false;
			}
		}
		else if(document.catform.choice[2].checked)
		{
			if(totalcat > 0)
			{
				window.location.href="viewgallery.php?owner="+owner;
			}
			else
			{
				alert("First, Create a Gallery!");
				return false;
			}
		}
		else{}
		
	}
	
	function setGLink(g)
	{
		var owner = document.gform.owner.value;
		var totalg = document.gform.totgal.value;
		var cID = document.gform.catid.value;
		if (!document.gform.choice[0].checked && !document.gform.choice[1].checked )
		{
    		alert("Please choose a option to continue.\n");
    		return false;
    	}
		if(document.gform.choice[0].checked)
		{
			window.location.href="gallery.php?edit_alboms="+cID+"&owner="+owner;
		}
		else if(document.gform.choice[1].checked)
		{
			if(totalg > 0)
			{
				g.style.display = "inline";
			}
			else
			{
				alert("First, Create a Gallery!");
				return false;
			}
		}
		else{}
		
	}
	
	function imageconfirm(a)
	{
		if(a==0)
		{
			alert("First, Create a Gallery!");
		}
		else
		{
			var hrefval = document.getElementById("aimggal").href;
			var viwehrefval = document.getElementById("aimggallery").href;
			//alert(hrefval);
			var chk = hrefval.lastIndexOf('#');
			var chkview = viwehrefval.lastIndexOf('#');
			//alert(chk);
			if(chk>0 && chkview>0)
			{
				alert("First, Highlight a Gallery!");	
			}
		}
	}
	
	function newWindow(mypage,myname,w,h,features,id)
	{
		  if(screen.width)
		  {
			  var winl = (screen.width-w)/2;
			  var wint = (screen.height-h)/2;
		  }
		  else
		  {
			  winl = 0;wint =0;
		  }
		  if (winl < 0) winl = 0;
		
		  if (wint < 0) wint = 0;
		
		  var settings = 'height=' + h + ',';
		
		  settings += 'width=' + w + ',';
		
		  settings += 'top=' + wint + ',';
		
		  settings += 'left=' + winl + ',';
		
		  settings += features;
		
		  win = window.open(mypage,myname,settings);
		
		  win.window.focus();
	}

	function MM_findObj(n, d)
	{ //v4.01
		var p,i,x;
		if(!d)
			d=document;
		if((p=n.indexOf("?"))>0&&parent.frames.length)
		{
			d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
		}
		if(!(x=d[n])&&d.all)
			x=d.all[n];
		for (i=0;!x&&i<d.forms.length;i++)
			x=d.forms[i][n];
		for(i=0;!x&&d.layers&&i<d.layers.length;i++)
			x=MM_findObj(n,d.layers[i].document);
		if(!x && d.getElementById)
			x=d.getElementById(n);
		return x;
	}



	function MM_validateForm()
	{ //v4.0
		var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
		for (i=0; i<(args.length-2); i+=3)
		{
			test=args[i+2]; val=MM_findObj(args[i]);
			if (val)
			{ 
				nm=val.name;
				if ((val=val.value)!="")
				{
					if (test.indexOf('isEmail')!=-1)
					{ 
						p=val.indexOf('@');
						if (p<1 || p==(val.length-1))
							errors+='- '+nm+' must contain an Email address.\n';
					}
					else if (test!='R')
					{
						num = parseFloat(val);
						if (isNaN(val))
							errors+='- '+nm+' must contain a number.\n';
						if (test.indexOf('inRange') != -1)
						{
							p=test.indexOf(':');
		   					min=test.substring(8,p); max=test.substring(p+1);
							if (num<min || max<num) 
							errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
						}
					}
				}
				else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; 
			}
		} 
		if (errors)
		{
			alert('The following error(s) occurred:\n'+errors);
			return false;
		}
		else
		{
		  //window.close();
		}
	}
	//function for VIEW GALLERY
	var viewCatText=new Array();
	var viewCatId=new Array();
	var viewCatName=new Array();
	var viewrowid = "";
	var flag = 0;
	function setViewText(obj,totalval)
	{
		//rowid = parseInt(obj.id);
		if(viewrowid=="0")
		{
			document.getElementById(viewrowid).style.backgroundColor="";
		}
		if(viewrowid != "" && parseInt(viewrowid) != parseInt(obj.id))
		{
			document.getElementById(viewrowid).style.backgroundColor="";	
		}
		flag =1;
		//alert(rowid);
		//alert(totalval)
		var style3;
				
		style3 = obj.style;
		style3.backgroundColor = style3.backgroundColor? "":"#D09FFD";
		document.getElementById("viewcomment").innerHTML = viewCatText[obj.id];
		document.getElementById("viewcname").innerHTML = viewCatName[obj.id];
		document.getElementById("textgal").innerHTML = "CLICK ON A GALLERY FOR A DESCRIPTION<br>DOUBLE-CLICK TO VISIT A GALLERY";
		/*document.getElementById("catgalid").href = 'viewgallery.php?category='+viewCatId[obj.id]+'&albom='+gID;*/
		viewrowid = obj.id;
	}
/////////////////////////////////////////////////////////////// FANFIC SCAN RESULT //////////////////////////

	var viewrowid2 = "";
	function setViewText2(obj)
	{
		//rowid = parseInt(obj.id);
		if(viewrowid2=="0")
		{
			document.getElementById(viewrowid2).style.backgroundColor="";
		}
		if(viewrowid2 != "" && parseInt(viewrowid2) != parseInt(obj.id))
		{
			document.getElementById(viewrowid2).style.backgroundColor="";	
		}
		
		var style3;
				
		style3 = obj.style;
		style3.backgroundColor = style3.backgroundColor? "":"#D09FFD";
		//document.getElementById("viewcomment").innerHTML = viewCatText[obj.id];
	//	document.getElementById("viewcname").innerHTML = viewCatName[obj.id];
		/*document.getElementById("catgalid").href = 'viewgallery.php?category='+viewCatId[obj.id]+'&albom='+gID;*/
		viewrowid2 = obj.id;
	}
function chk_blank_gallery()
{
		if(document.getElementById("keyword").value=="")
		{
				alert("Please Enter the keyword!");
				document.getElementById("keyword").focus();
				return false;
		}
}
/////////////////////////////////////////////////////////CHK_BLANK_BLOG ///////////////////////////
function chk_blank_blog()
{
		if((document.getElementById("keyword").value=="")&&(document.getElementById("nickname").value==""))
		{
				alert("Please Enter the Keyword OR Nickname!");
				document.getElementById("keyword").focus();
				return false;
		}
}
/////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////// GALLERY SCAN RESULT ////////////////////
var gallery_obj = "";
	function gallery_scan(obj,album_id,category_id,owner_id)
	{
			//rowid = parseInt(obj.id);
		if(gallery_obj=="0")
		{
			document.getElementById(gallery_obj).style.backgroundColor="";
		}
		if(gallery_obj != "" && parseInt(gallery_obj) != parseInt(obj.id))
		{
			document.getElementById(gallery_obj).style.backgroundColor="";	
		}
		
		var style3;
				
		style3 = obj.style;
		style3.backgroundColor = style3.backgroundColor? "":"#D09FFD";		
		//document.getElementById("viewcomment").innerHTML = viewCatText[obj.id];
	//	document.getElementById("viewcname").innerHTML = viewCatName[obj.id];
		/*document.getElementById("catgalid").href = 'viewgallery.php?category='+viewCatId[obj.id]+'&albom='+gID;*/
//document.getElementById("aimggallery").href = 'viewgallery.php?owner='+owner_id+'&category='+category_id+'&albom='+album_id+'&gallery_scan=true';
		gallery_obj = obj.id;
	}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////	
//////////////////////////////////////////////////////////////// BLOG SCAN RESULT ////////////////////
var blog_obj = "";
	function blog_scan(obj,owner_id)
	{
		if(blog_obj=="0")
		{
			document.getElementById(blog_obj).style.backgroundColor="";
		}
		if(blog_obj != "" && parseInt(blog_obj) != parseInt(obj.id))
		{
			document.getElementById(blog_obj).style.backgroundColor="";	
		}
		
		var style3;
				
		style3 = obj.style;
		style3.backgroundColor = style3.backgroundColor? "":"#D09FFD";		
		//document.getElementById("viewcomment").innerHTML = viewCatText[obj.id];
	//	document.getElementById("viewcname").innerHTML = viewCatName[obj.id];
		/*document.getElementById("catgalid").href = 'viewgallery.php?category='+viewCatId[obj.id]+'&albom='+gID;*/
//document.getElementById("aimggallery").href = 'viewgallery.php?owner='+owner_id+'&category='+category_id+'&albom='+album_id+'&gallery_scan=true';
		blog_obj = obj.id;
	}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////	
	var genrerowid = "";
	var genreName=new Array();
	var fanflag = 0;
	function setgenre(obj)
	{
		//rowid = parseInt(obj.id);
		/*if(genrerowid=="0")
		{
			document.getElementById(genrerowid).style.backgroundColor="";
		}
		if(genrerowid != "" && parseInt(genrerowid) != parseInt(obj.id))
		{
			document.getElementById(genrerowid).style.backgroundColor="";	
		}*/
		fanflag =1;
		//alert(rowid);
		//alert(totalval)
		/*var style3;
				
		style3 = obj.style;
		style3.backgroundColor = style3.backgroundColor? "":"#FFFF00";*/
		document.getElementById("showdouble").innerHTML = "CLICK ON A FAN-FIC FOR A DESCRIPTION<br/> DOUBLE-CLICK TO READ A FAN-FIC";
		document.getElementById("genrename").innerHTML = genreName[obj.id]+" Fan-Fic";
		/*document.getElementById("catgalid").href = 'viewgallery.php?category='+viewCatId[obj.id]+'&albom='+gID;*/
		//genrerowid = obj.id;
	}
	var genrerowid2 = "";
	var genreName2=new Array();
	var fanflag2 = 0;
	function setgenre2(obj)
	{
		//rowid = parseInt(obj.id);
		if(genrerowid2=="0")
		{
			document.getElementById(genrerowid2).style.backgroundColor="";
		}
		if(genrerowid2 != "" && parseInt(genrerowid2) != parseInt(obj.id))
		{
			document.getElementById(genrerowid2).style.backgroundColor="";	
		}
		fanflag =1;
		//alert(rowid);
		//alert(totalval)
		var style3;
				
		style3 = obj.style;
		style3.backgroundColor = style3.backgroundColor? "":"#FFFF00";
		//document.getElementById("viewcomment").innerHTML = viewCatText[obj.id];
	//	document.getElementById("genrename2").innerHTML = genreName[obj.id]+" Fan-Fic";
		/*document.getElementById("catgalid").href = 'viewgallery.php?category='+viewCatId[obj.id]+'&albom='+gID;*/
		genrerowid = obj.id;
	}
	//for fanfic chapter color
	var chrowid = "";
	function setchaptercolor(obj)
	{
		//rowid = parseInt(obj.id);
		if(chrowid=="0")
		{
			document.getElementById(chrowid).style.backgroundColor="";
		}
		if(chrowid != "" && parseInt(chrowid) != parseInt(obj.id))
		{
			document.getElementById(chrowid).style.backgroundColor="";	
		}
		var chstyle;
				
		chstyle = obj.style;
		chstyle.backgroundColor = chstyle.backgroundColor? "":"#D09FFD";
		
		chrowid = obj.id;
	}
	//fanfic chapter color function Ends here
	
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	/* Ajax Code */
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var zXml={useActiveX:(typeof ActiveXObject!="undefined"),useDom:document.implementation&&document.implementation.createDocument,useXmlHttp:(typeof XMLHttpRequest!="undefined")};zXml.ARR_XMLHTTP_VERS=["MSXML2.XmlHttp.5.0","MSXML2.XmlHttp.4.0","MSXML2.XmlHttp.3.0","MSXML2.XmlHttp","Microsoft.XmlHttp"];zXml.ARR_DOM_VERS=["MSXML2.DOMDocument.5.0","MSXML2.DOMDocument.4.0","MSXML2.DOMDocument.3.0","MSXML2.DOMDocument","Microsoft.XmlDom"];;function zXmlHttp(){}zXmlHttp.createRequest=function(){if(zXml.useXmlHttp){return new XMLHttpRequest();}else if(zXml.useActiveX){if(!zXml.XMLHTTP_VER){for(var i=0;i<zXml.ARR_XMLHTTP_VERS.length;i++){try{new ActiveXObject(zXml.ARR_XMLHTTP_VERS[i]);zXml.XMLHTTP_VER=zXml.ARR_XMLHTTP_VERS[i];break;}catch(oError){;}}}if(zXml.XMLHTTP_VER){return new ActiveXObject(zXml.XMLHTTP_VER);}else{throw new Error("Could not create XML HTTP Request.");}}else{throw new Error("Your browser doesn't support an XML HTTP Request.");}};zXmlHttp.isSupported=function(){return zXml.useXmlHttp||zXml.useActiveX;};function zXmlDom(){}zXmlDom.createDocument=function(){if(zXml.useDom){var oXmlDom=document.implementation.createDocument("","",null);oXmlDom.parseError={valueOf:function(){return this.errorCode;},toString:function(){return this.errorCode.toString()}};oXmlDom.__initError__();oXmlDom.addEventListener("load",function(){this.__checkForErrors__();this.__changeReadyState__(4);},false);return oXmlDom;;}else if(zXml.useActiveX){if(!zXml.DOM_VER){for(var i=0;i<zXml.ARR_DOM_VERS.length;i++){try{new ActiveXObject(zXml.ARR_DOM_VERS[i]);zXml.DOM_VER=zXml.ARR_DOM_VERS[i];break;}catch(oError){;}}}if(zXml.DOM_VER){return new ActiveXObject(zXml.DOM_VER);}else{throw new Error("Could not create XML DOM document.");}}else{throw new Error("Your browser doesn't support an XML DOM document.");}};zXmlDom.isSupported=function(){return zXml.useDom||zXml.useActiveX;};var oMozDocument=null;if(typeof XMLDocument!="undefined"){oMozDocument=XMLDocument;}else if(typeof Document!="undefined"){oMozDocument=Document;}if(oMozDocument&&!window.opera){oMozDocument.prototype.readyState=0;oMozDocument.prototype.onreadystatechange=null;oMozDocument.prototype.__changeReadyState__=function(iReadyState){this.readyState=iReadyState;if(typeof this.onreadystatechange=="function"){this.onreadystatechange();}};oMozDocument.prototype.__initError__=function(){this.parseError.errorCode=0;this.parseError.filepos=-1;this.parseError.line=-1;this.parseError.linepos=-1;this.parseError.reason=null;this.parseError.srcText=null;this.parseError.url=null;};oMozDocument.prototype.__checkForErrors__=function(){if(this.documentElement.tagName=="parsererror"){var reError=/>([\s\S]*?)Location:([\s\S]*?)Line Number(\d+),Column(\d+):<sourcetext>([\s\S]*?)(?:\-*\^)/;reError.test(this.xml);this.parseError.errorCode=-999999;this.parseError.reason=RegExp.$1;this.parseError.url=RegExp.$2;this.parseError.line=parseInt(RegExp.$3);this.parseError.linepos=parseInt(RegExp.$4);this.parseError.srcText=RegExp.$5;}};oMozDocument.prototype.loadXML=function(sXml){this.__initError__();this.__changeReadyState__(1);var oParser=new DOMParser();var oXmlDom=oParser.parseFromString(sXml,"text/xml");while(this.firstChild){this.removeChild(this.firstChild);}for(var i=0;i<oXmlDom.childNodes.length;i++){var oNewNode=this.importNode(oXmlDom.childNodes[i],true);this.appendChild(oNewNode);}this.__checkForErrors__();this.__changeReadyState__(4);};oMozDocument.prototype.__load__=oMozDocument.prototype.load;oMozDocument.prototype.load=function(sURL){this.__initError__();this.__changeReadyState__(1);this.__load__(sURL);};Node.prototype.__defineGetter__("xml",function(){var oSerializer=new XMLSerializer();return oSerializer.serializeToString(this,"text/xml");});Node.prototype.__defineGetter__("text",function(){var sText="";for(var i=0;i<this.childNodes.length;i++){if(this.childNodes[i].hasChildNodes()){sText+=this.childNodes[i].text;}else{sText+=this.childNodes[i].nodeValue;}}return sText;});}function zXslt(){}zXslt.transformToText=function(oXml,oXslt){if(typeof XSLTProcessor!="undefined"){var oProcessor=new XSLTProcessor();oProcessor.importStylesheet(oXslt);var oResultDom=oProcessor.transformToDocument(oXml);var sResult=oResultDom.xml;if(sResult.indexOf("<transformiix:result")>-1){sResult=sResult.substring(sResult.indexOf(">")+1,sResult.lastIndexOf("<"));}return sResult;;}else if(zXml.useActiveX){return oXml.transformNode(oXslt);}else{throw new Error("No XSLT engine found.");}};function zXPath(){}zXPath.selectNodes=function(oRefNode,sXPath,sXmlNs){if(typeof XPathEvaluator!="undefined"){oXmlNs=oXmlNs||{};var nsResolver=function(sPrefix){return oXmlNs[sPrefix];};var oEvaluator=new XPathEvaluator();var oResult=oEvaluator.evaluate(sXPath,oRefNode,nsResolver,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);var aNodes=new Array;if(oResult!=null){var oElement=oResult.iterateNext();while(oElement){aNodes.push(oElement);oElement=oResult.iterateNext();}}return aNodes;}else if(zXml.useActiveX){if(oXmlNs){var sXmlNs="";for(var sProp in oXmlNs){sXmlNs+="xmlns:"+sProp+"="+oXmlNs[sProp]+" ";}oRefNode.ownerDocument.setProperty("SelectionNamespaces",sXmlNs);};return oRefNode.selectNodes(sXPath);}else{throw new Error("No XPath engine found.");}};zXPath.selectSingleNode=function(oRefNode,sXPath,oXmlNs){if(typeof XPathEvaluator!="undefined"){;oXmlNs=oXmlNs||{};var nsResolver=function(sPrefix){return oXmlNs[sPrefix];};var oEvaluator=new XPathEvaluator();var oResult=oEvaluator.evaluate(sXPath,oRefNode,nsResolver,XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(oResult!=null){return oResult.singleNodeValue;}else{return null;};}else if(zXML.useActiveX){if(oXmlNs){var sXmlNs="";for(var sProp in oXmlNs){sXmlNs+="xmlns:"+sProp+"="+oXmlNs[sProp]+" ";}oRefNode.ownerDocument.setProperty("SelectionNamespaces",sXmlNs);};return oRefNode.selectSingleNode(sXPath);}else{throw new Error("No XPath engine found.");}};function zXMLSerializer(){}zXMLSerializer.prototype.serializeToString=function(oNode){var sXml="";switch(oNode.nodeType){case 1:sXml="<"+oNode.tagName;for(var i=0;i<oNode.attributes.length;i++){sXml+=" "+oNode.attributes[i].name+"=\""+oNode.attributes[i].value+"\"";}sXml+=">";for(var i=0;i<oNode.childNodes.length;i++){sXml+=this.serializeToString(oNode.childNodes[i]);}sXml+="</"+oNode.tagName+">";break;case 3:sXml=oNode.nodeValue;break;case 4:sXml="<![CDATA["+oNode.nodeValue+"]]>";break;case 7:sXml="<?"+oNode.nodevalue+"?>";break;case 8:sXml="<!--"+oNode.nodevalue+"-->";break;case 9:for(var i=0;i<oNode.childNodes.length;i++){sXml+=this.serializeToString(oNode.childNodes[i]);}break;};return sXml;};

	var fanrowid=""; // for FANFIC  ROW ID
function setFanfic(genre,owner) {
	var oXmlHttp = zXmlHttp.createRequest();
	var strphp = "getFanficList.php?owner="+owner+"&genre="+genre;
	fanrowid="f0";
	oXmlHttp.open("get", strphp , true);
	oXmlHttp.onreadystatechange = function () {
		if (oXmlHttp.readyState == 4) {
			if (oXmlHttp.status == 200) {
				PopulatefanficList(oXmlHttp.responseXML.documentElement,owner);
			} else {
				alert("problem retrieving data from the server, status code: "  + xmlHttpReq.status);
			}
		}
	};
	oXmlHttp.send(null);
}

function PopulatefanficList(categoryNode, owner)
{
	//document.getElementById("gcomment").innerHTML = "Comments";
	var categoryList = document.getElementById("vfanfic");
	//var index = Array();
	//var i=0;
	// clear the country list 
	//alert(categoryList);
	//alert(categoryNode);
	//var
    var	categoryNodes = categoryNode.getElementsByTagName('composer');
	var length = categoryNodes.length;
	var textValue; 
	//var gcomment;
	//var gid;
	//<div align=\"center\" style=\"overflow:auto;width:480px;border:hidden;height:200px\">;
	//alert(categoryNodes.length);
	// populate the dropdown list with data from the xml doc
	var table = "<div align=\"center\" style=\"overflow:auto;width:480px;border:hidden;height:100px\"><table border=\"0\" cellpadding=\"3\" cellspacing=\"3\" style=\"border: 1px solid  #006633\" width=\"90%\" align=\"center\">";
	if(length==0)
	{
		table+="<tr><td colspan=\"2\" align=\"center\">There are no Fan-Fics to Display</td></tr>";
	}
	else
	{
		for (var count = 0; count < length  ; count++)
		{
			categoryNodes = categoryNode.getElementsByTagName('inspiredby');
			inspiredby=GetInnerText(categoryNodes[count]);
			categoryNodes =  categoryNode.getElementsByTagName('blurb');
			blurb = GetInnerText(categoryNodes[count]);
			categoryNodes = categoryNode.getElementsByTagName('ffid');
			fanficID = GetInnerText(categoryNodes[count]);
			
			table+="<tr onclick=\"setfText(this,"+fanficID+",\'"+blurb+"\',"+owner+")\"  onDblClick=\"fanPage("+fanficID+","+owner+")\" id=f"+count+" style=\"cursor:pointer;\"><td align=\"left\">";
			categoryNodes = categoryNode.getElementsByTagName('composer'); 
			textValue = GetInnerText(categoryNodes[count]);
			table+=textValue;
			table+="</td>";
			table+="<td align=\"left\" >inspired by ";
			categoryNodes = categoryNode.getElementsByTagName('inspiredby'); 
			textValue = GetInnerText(categoryNodes[count]);
			table+=textValue;
			table+="</td>";
			/*table+="<td align=\"center\" class=\"gallery\">";
			categoryNodes = categoryNode.getElementsByTagName('count'); 
			textValue = GetInnerText(categoryNodes[count]);
			table+=textValue;
			table+="</td>";
			table+="<td align=\"center\">";
			categoryNodes = categoryNode.getElementsByTagName('approved'); 
			textValue = GetInnerText(categoryNodes[count]);
			var approved;
			approved = textValue;
			categoryNodes = categoryNode.getElementsByTagName('image'); 
			textValue = GetInnerText(categoryNodes[count]);
			var temp = new Array();
			temp = textValue.split('.');
			if(approved==1)
			{
			if(textValue != "")
			{
				table+="<img border=\"0\" src=\"gallery/"+temp[0]+"_thumb."+temp[1]+"\"/>";
			}
			else
			{
				table+="<img border=\"0\" src=\"images/new.jpg\"/>";
			}
			}
			else
			{
				table+="<img border=\"0\" src=\"images/new.jpg\"/>";
			}
			table+="</td>";*/
			table+="</tr>";
			table+="<tr><td colspan=\"2\" align=\"left\" bgcolor=\"#D09FFD\"><hr /></td></tr>";
		}
	}
table+="</table></div><br/>";
	table+="<table width='98%' style='border:1px solid #FF9933' align='center' cellpadding='0' cellspacing='0'>";
	table+="<tr><td align='center' id='fblurb'>Display Area Fan Fic : Blurb </td></tr>";
	table+="</table>";
//alert(table);
categoryList.innerHTML = table;
}
var growid=""; // FRO GALLERY ROW ID
function setGallery(catID,owner) {
	var oXmlHttp = zXmlHttp.createRequest();
	var strphp = "getGalleryList.php?catID="+escape(catID);
	growid = "g0";
	oXmlHttp.open("get", strphp , true);
	oXmlHttp.onreadystatechange = function () {
		if (oXmlHttp.readyState == 4) {
			if (oXmlHttp.status == 200) {
				PopulateCategoryList(oXmlHttp.responseXML.documentElement,owner);
			} else {
				alert("problem retrieving data from the server, status code: "  + xmlHttpReq.status);
			}
		}
	};
	oXmlHttp.send(null);
}

function PopulateCategoryList(categoryNode, owner)
{
	//document.getElementById("gcomment").innerHTML = "Comments";
	var categoryList = document.getElementById("vgallery");
	//var index = Array();
	//var i=0;
	// clear the country list 
	//alert(categoryList);
	//alert(categoryNode);
	//var
    var	categoryNodes = categoryNode.getElementsByTagName('composer');
	var length = categoryNodes.length;
	var textValue; 
	var gcomment;
	var gid;
	var catID;
	//alert(categoryNodes.length);
	// populate the dropdown list with data from the xml doc
	var table = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border: 1px solid  #006633\" width=\"100%\" align=\"center\">";
	if(length==0)
	{
		table+="<tr><td colspan=\"3\" align=\"center\">There are no Galleries to Display</td></tr>";
	}
	else
	{
		for (var count = 0; count < length  ; count++)
		{
			categoryNodes = categoryNode.getElementsByTagName('gcomment');
			gcomment=GetInnerText(categoryNodes[count]);
			categoryNodes =  categoryNode.getElementsByTagName('gid');
			gid = GetInnerText(categoryNodes[count]);
			categoryNodes = categoryNode.getElementsByTagName('catid');
			catID = GetInnerText(categoryNodes[count]);
			table+="<tr><td colspan=\"3\" align=\"center\">&nbsp;</td></tr>";
			table+="<tr onclick=\'setgText(this,"+catID+","+gid+",\""+gcomment+"\","+owner+")\' onDblClick=\"javascript:window.location.href='viewgallery.php?owner="+owner+"&category="+catID+"&albom="+gid+"'\" id=g"+count+" style=\"cursor:pointer;\"><td align=\"center\" class=\"gallery\">";
			categoryNodes = categoryNode.getElementsByTagName('composer'); 
			textValue = GetInnerText(categoryNodes[count]);
			table+=textValue;
			table+="</td>";
			table+="<td align=\"center\" class=\"gallery\">";
			categoryNodes = categoryNode.getElementsByTagName('lastupdate'); 
			textValue = GetInnerText(categoryNodes[count]);
			table+=textValue;
			table+="</td>";
			table+="<td align=\"center\" class=\"gallery\">";
			categoryNodes = categoryNode.getElementsByTagName('count'); 
			textValue = GetInnerText(categoryNodes[count]);
			table+=textValue;
			table+="</td>";
			table+="<td align=\"center\">";
			categoryNodes = categoryNode.getElementsByTagName('approved'); 
			textValue = GetInnerText(categoryNodes[count]);
			var approved;
			approved = textValue;
			categoryNodes = categoryNode.getElementsByTagName('image'); 
			textValue = GetInnerText(categoryNodes[count]);
			var temp = new Array();
			temp = textValue.split('.');
			if(approved==1)
			{
			if(textValue != "")
			{
				table+="<img border=\"0\" src=\"gallery/"+temp[0]+"_thumb."+temp[1]+"\"/>";
			}
			else
			{
				table+="<img border=\"0\" src=\"images/new.jpg\"/>";
			}
			}
			else
			{
				table+="<img border=\"0\" src=\"images/new.jpg\"/>";
			}
			table+="</td>";
			table+="</tr>";
			table+="<tr><td colspan=\"4\" align=\"left\" bgcolor=\"#D09FFD\"><hr /></td></tr>";
			
		}
	}
	
	table+="</table><br />";
	table+="<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"border: 1px solid  #006633\" >";
	table+="<tr><td align=\"center\" class=\"gallery\" width=\"100%\" id='gcomment'>Comments</td></tr>";
	table+="</table>";
//alert(table);
categoryList.innerHTML = table;
}
function GetInnerText (node)
{
	 return (node.textContent || node.innerText || node.text) ;
}


function setgText(obj,catID,gID,gComment,owner)
	{
 	   flag =0;
		//rowid = parseInt(obj.id);
		//alert(growid);
		if(growid=="0")
		{
			//alert(growid);
			document.getElementById(growid).style.backgroundColor="";
		}
		if(growid != "" && growid != obj.id)
		{
			document.getElementById(growid).style.backgroundColor="";	
		}
		
		//alert(rowid);
		//alert(totalval)
		var style3;
				
		style3 = obj.style;
		style3.backgroundColor = style3.backgroundColor? "":"#D09FFD";
	
		document.getElementById("gcomment").innerHTML = gComment;
		/*var temp = new Array();
		temp = document.getElementById("catgalid").href.split('#');
		document.getElementById("catgalid").href = temp[0]+"&category="+catID+"&albom="+gID;*/
		//document.getElementById("catgalid").href = 'viewgallery.php?owner='+owner+'&category='+catID+'&albom='+gID;
		growid = obj.id;
	}

	function setfText(obj,ffID,blurb,owner)
	{
 	   fanflag =0;
		//rowid = parseInt(obj.id);
		
		if(fanrowid=="0")
		{
			//alert(growid);
			document.getElementById(fanrowid).style.backgroundColor="";
		}
		if(fanrowid != "" && fanrowid != obj.id)
		{
			document.getElementById(fanrowid).style.backgroundColor="";	
		}
		
		//alert(rowid);
		//alert(totalval)
		var style3;
				
		style3 = obj.style;
		style3.backgroundColor = style3.backgroundColor? "":"#D09FFD";
	
		document.getElementById("fblurb").innerHTML = blurb;
		//document.getElementById("fanmoveid").href = 'fanficview.php?owner='+owner+'&ffid='+ffID;
		fanrowid = obj.id;
	}
	function fanPage(ffID,owner)
	{
		window.location.href="fanficview.php?owner="+owner+"&ffid="+ffID;
	}
	//function to show Alert on empty category and/or gallery selection
	function confirmgallery()
	{
		var hrefval = document.getElementById("catgalid").href;
		//alert(hrefval);
		var chkoccurence = hrefval.lastIndexOf('#');
		//alert(chkoccurence);
		if(chkoccurence>0 && !flag)
		{
			alert("You Must Highlight a Category");	
		}
		if(chkoccurence>0 && flag)
		{
			alert("You Must Highlight a Gallery");
		}
		/*if(chkoccurence>0)
		{
			alert("You Must Highlight a Category and then Gallery to Continue!");	
		}*/
	}
	//End here
	//function to show Alert on empty Genre and/or Fan-Fic selection
	function confirmfanfic()
	{
		var hrefval = document.getElementById("fanmoveid").href;
		//alert(hrefval);
		var chkoccurence = hrefval.lastIndexOf('#');
		//alert(chkoccurence);
		if(chkoccurence>0 && !fanflag)
		{
			alert("You Must Highlight a Genre");	
		}
		if(chkoccurence>0 && fanflag)
		{
			alert("You Must Highlight a Fanfic");
		}
		/*if(chkoccurence>0)
		{
			alert("You Must Highlight a Category and then Gallery to Continue!");	
		}*/
	}
	//End here
	//function to enable /disable testimonial form
	function showtest()
	{
		if(document.form1.checkok.checked)
		{
			document.form1.testimonialby.disabled = false;
			document.form1.story.disabled = false;
			document.form1.file.disabled = false;
			document.form1.nickname1.disabled = false;
			document.form1.nickname2.disabled = false;
			//document.form1.select1.disabled = false;
			document.form1.select2.disabled = false;
			//document.form1.select3.disabled = false;
			document.form1.select4.disabled = false;
			document.form1.Submit.disabled = false;
		}
		else
		{
			document.form1.testimonialby.disabled = true;
			document.form1.story.disabled = true;
			document.form1.file.disabled = true;
			document.form1.nickname1.disabled = true;
			document.form1.nickname2.disabled = true;
			//document.form1.select1.disabled = true;
			document.form1.select2.disabled = true;
			//document.form1.select3.disabled = true;
			document.form1.select4.disabled = true;
			document.form1.Submit.disabled = true;
		}
	}
	function chktest(frm)
	{
		var q = document.frm.testimonialby.value;
		if(q=="couple")
		{
			var a = document.frm.nickname2.value;
			if(a=="")
			{
				alert("Nickname2 Cannot be Left Blank!!!");
				return false;
			}
			else
			{
				return true;
			}
		}
		else
		{
			return true;
		}
	}
	function showdiv(i,j,k,l,m,n,o,p)
	{
		var q = document.form1.testimonialby.value;
		if(q=="couple")
		{
			j.style.display = "inline";
			k.style.display = "none";
			l.style.display = "inline";
			m.style.display = "none";
			n.style.display = "inline";
			o.style.display = "none";
			p.style.display = "inline";
		}
		else
		{
			j.style.display = "none";
			k.style.display = "inline";
			l.style.display = "none";
			m.style.display = "inline";
			n.style.display = "none";
			o.style.display = "inline";
			p.style.display = "none";
		}
	}
	
	function changedivc(i,j,k,l,m,n,o,p)
	{
		var q = document.form6.testimonialby.value;
		if(q=="couple")
		{
			//var hide2 =document.getElementById(j);
			j.style.display = "inline";
			k.style.display = "none";
			l.style.display = "inline";
			m.style.display = "none";
			n.style.display = "inline";
			o.style.display = "none";
			p.style.display = "inline";
			document.form6.story.disabled = false;
			document.form6.nickname1.disabled = false;
			//document.form6.select1.disabled = false;
			document.form6.select2.disabled = false;
			document.form6.nickname2.disabled = false;
			//document.form6.select3.disabled = false;
			document.form6.select4.disabled = false;
		}
		else
		{
			j.style.display = "none";
			k.style.display = "inline";
			l.style.display = "none";
			m.style.display = "inline";
			n.style.display = "none";
			o.style.display = "inline";
			p.style.display = "none";
			document.form6.story.disabled = true;
			document.form6.nickname1.disabled = true;
			//document.form6.select1.disabled = true;
			document.form6.select2.disabled = true;
		}
	}
	
	function changediv(i,j,k,l,m,n,o,p)
	{
		var q = document.form6.testimonialby.value;
		if(q=="single")
		{
			j.style.display = "none";
			k.style.display = "none";
			l.style.display = "inline";
			m.style.display = "none";
			n.style.display = "inline";
			o.style.display = "none";
			p.style.display = "inline";
			document.form6.story.disabled = false;
			document.form6.nickname1.disabled = false;
			//document.form6.select1.disabled = false;
			document.form6.select2.disabled = false;
		}
		else
		{
			j.style.display = "inline";
			k.style.display = "inline";
			l.style.display = "none";
			m.style.display = "inline";
			n.style.display = "none";
			o.style.display = "inline";
			p.style.display = "none";
			document.form6.story.disabled = true;
			document.form6.nickname1.disabled = true;
			//document.form6.select1.disabled = true;
			document.form6.select2.disabled = true;
		}
	}
	
	//function for new Testimonial
	function previewImage()
	{
		if(document.form6.testimonialby.value=="couple")
		{
			var a = document.form6.nickname2.value;
			if(a=="")
			{
				alert("Your SoulGeek's Name Cannot be Left Blank!!!");
				document.form6.nickname2.focus();
				return false;
			}
			if(document.form6.story.value=="")
			{
				alert("Please write a Story for your testimonial!!!");
				document.form6.story.focus();
				return false;
			}
		}
		
		if(document.form6.file.value=="")
		{
			alert("Please select a Testimonial Pic to Upload!!!");
			return false;
		}
		else
		{
			return true;
		}
	}
	//Ends here : Function for New Testimonial
	function chkTest()
	{
		if(document.form1.testimonialby.value=="couple")
		{
			var a = document.form1.nickname2.value;
			if(a=="")
			{
				alert("Your SoulGeek's Name Cannot be Left Blank!!!");
				document.form1.nickname2.focus();
				return false;
			}
		}
		if(document.form1.story.value=="")
		{
			alert("Please write a Story for your testimonial!!!");
			document.form1.story.focus();
			return false;
		}
		/*if(document.form1.file.value=="")
		{
			alert("Please select a Testimonial Pic to Upload!!!");
			return false;
		}*/
		else
		{
			return true;
		}
  	}
	function chkfile()
	{
		myfile = document.form6.file.value;
  		if(myfile == "")
  		{
	 		alert("Please select a Testimonial Pic to Upload!!!");
			return false;
		}

  	}
	
	//function fro testimonial ends here
	//Progress bar By Abhishek###############################################################
	
	
	var w3c=(document.getElementById)?true:false;
var ie=(document.all)?true:false;
var N=-1;

function createBar(w,h,bgc,brdW,brdC,blkC,speed,blocks,count,action){
if(ie||w3c){
var t='Image Uploading – Please Wait!!!<div id="_xpbar'+(++N)+'" style="visibility:visible; position:relative; overflow:hidden; width:'+w+'px; height:'+h+'px; background-color:'+bgc+'; border-color:'+brdC+'; border-width:'+brdW+'px; border-style:solid; font-size:1px;">';
t+='<span id="blocks'+N+'" style="left:-'+(h*2+1)+'px; position:absolute; font-size:1px">';
for(i=0;i<blocks;i++){
t+='<span style="background-color:'+blkC+'; left:-'+((h*i)+i)+'px; font-size:1px; position:absolute; width:'+h+'px; height:'+h+'px; '
t+=(ie)?'filter:alpha(opacity='+(100-i*(100/blocks))+')':'-Moz-opacity:'+((100-i*(100/blocks))/100);
t+='"></span>';
}
t+='</span></div>';
document.write(t);
var bA=(ie)?document.all['blocks'+N]:document.getElementById('blocks'+N);
bA.bar=(ie)?document.all['_xpbar'+N]:document.getElementById('_xpbar'+N);
bA.blocks=blocks;
bA.N=N;
bA.w=w;
bA.h=h;
bA.speed=speed;
bA.ctr=0;
bA.count=count;
bA.action=action;
bA.togglePause=togglePause;
bA.showBar=function(){
this.bar.style.visibility="visible";
}
bA.hideBar=function(){
this.bar.style.visibility="hidden";
}
bA.tid=setInterval('startBar('+N+')',speed);
return bA;
}}

function startBar(bn){
var t=(ie)?document.all['blocks'+bn]:document.getElementById('blocks'+bn);
if(parseInt(t.style.left)+t.h+1-(t.blocks*t.h+t.blocks)>t.w){
t.style.left=-(t.h*2+1)+'px';
t.ctr++;
if(t.ctr>=t.count){
eval(t.action);
t.ctr=0;
}}else t.style.left=(parseInt(t.style.left)+t.h+1)+'px';
}

function togglePause(){
if(this.tid==0){
this.tid=setInterval('startBar('+this.N+')',this.speed);
}else{
clearInterval(this.tid);
this.tid=0;
}}

function togglePause(){
if(this.tid==0){
this.tid=setInterval('startBar('+this.N+')',this.speed);
}else{
clearInterval(this.tid);
this.tid=0;
}}

/*This funhction checks the credit card number.*/
var ccErrorNo = 0;
var ccErrors = new Array ()

ccErrors [0] = "Unknown card type";
ccErrors [1] = "Enter Credit Card Number";
ccErrors [2] = "Credit card number is in invalid format";
ccErrors [3] = "Credit card number is invalid";
ccErrors [4] = "Credit card number has an inappropriate number of digits";

function testCreditCard () {
	signup = document.getElementById('Sign_me_up_as_a').value;
  //myCardNo = document.getElementById('Credit_Card_Number').value;
 // myCardType = document.getElementById('Credit_Card_Type').value;
	myCardNo = document.form4.Credit_Card_Number.value;
	mycard = document.form4.Credit_Card_Type.value;
	var  secno = document.form4.Card_Code.value;
	var seclen = secno.length;
 // alert(secno);
 // alert(seclen);
//  alert(signup);
  if(signup == 'Free Member')
  {
	  if(document.getElementById('First_Name').value=="")
		{
			alert("Please fill in your First Name");
			document.getElementById('First_Name').focus();
			return false;
		}
		if(document.getElementById('Last_Name').value=="")
		{
			alert("Please fill in your Last Name");
			document.getElementById('Last_Name').focus();
			return false;
		}
		if(document.getElementById('Address_Line_One').value=="")
		{
			alert("Please fill in your Address Line One");
			document.getElementById('Address_Line_One').focus();
			return false;
		}
		if(document.getElementById('card_state').value=="")
		{
			alert("Please fill in your State");
			document.getElementById('card_state').focus();
			return false;
		}
		if(document.getElementById('card_city').value=="")
		{
			alert("Please fill in your City");
			document.getElementById('card_city').focus();
			return false;
		}
		if(document.getElementById('card_Zip').value=="")
		{
			alert("Please fill in your Zip Code");
			document.getElementById('card_Zip').focus();
			return false;
		}
		else
		{
	  		return true;
		}
  }
  else
  {
	  	if (checkCreditCard (myCardNo,mycard)) 
		{
			if(seclen<3)
			{
				alert("Please enter Credit Card Code");
				document.form4.Card_Code.focus();
				return false;	
			}
			if(document.getElementById('First_Name').value=="")
			{
				alert("Please fill in your First Name");
				document.getElementById('First_Name').focus();
				return false;
			}
			if(document.getElementById('Last_Name').value=="")
			{
				alert("Please fill in your Last Name");
				document.getElementById('Last_Name').focus();
				return false;
			}
			if(document.getElementById('Address_Line_One').value=="")
			{
				alert("Please fill in your Address Line One");
				document.getElementById('Address_Line_One').focus();
				return false;
			}
			if(document.getElementById('card_state').value=="")
			{
				alert("Please fill in your State");
				document.getElementById('card_state').focus();
				return false;
			}
			if(document.getElementById('card_city').value=="")
			{
				alert("Please fill in your City");
				document.getElementById('card_city').focus();
				return false;
			}
			if(document.getElementById('card_Zip').value=="")
			{
				alert("Please fill in your Zip Code");
				document.getElementById('card_Zip').focus();
				return false;
			}
			else
			{
				return true;
			}
		} 
		else
		{
			alert (ccErrors[ccErrorNo]);
			document.form4.Credit_Card_Number.focus();
			return false;
		}
  }
}


function checkCreditCard (cardnumber,cardname) {

     
  // Array to hold the permitted card characteristics
  var cards = new Array();

  // Define the cards we support. You may add addtional card types.
  
  //  Name:      As in the selection box of the form - must be same as user's
  //  Length:    List of possible valid lengths of the card number for the card
  //  prefixes:  List of possible prefixes for the card
  //  checkdigit Boolean to say whether there is a check digit
  
  cards [0] = {name: "Visa", 
               length: "13,16", 
               prefixes: "4",
               checkdigit: true};
  cards [1] = {name: "Master Card", 
               length: "16", 
               prefixes: "51,52,53,54,55",
               checkdigit: true};
  cards [2] = {name: "DinersClub", 
               length: "14,16", 
               prefixes: "300,301,302,303,304,305,36,38,55",
               checkdigit: true};
  cards [3] = {name: "CarteBlanche", 
               length: "14", 
               prefixes: "300,301,302,303,304,305,36,38",
               checkdigit: true};
  cards [4] = {name: "American Express", 
               length: "15", 
               prefixes: "34,37",
               checkdigit: true};
  cards [5] = {name: "Discover", 
               length: "16", 
               prefixes: "6011,650",
               checkdigit: true};
  cards [6] = {name: "JCB", 
               length: "15,16", 
               prefixes: "3,1800,2131",
               checkdigit: true};
  cards [7] = {name: "enRoute", 
               length: "15", 
               prefixes: "2014,2149",
               checkdigit: true};
  cards [8] = {name: "Solo", 
               length: "16,18,19", 
               prefixes: "6334, 6767",
               checkdigit: true};
  cards [9] = {name: "Switch", 
               length: "16,18,19", 
               prefixes: "4903,4905,4911,4936,564182,633110,6333,6759",
               checkdigit: true};
  cards [10] = {name: "Maestro", 
               length: "16", 
               prefixes: "5020,6",
               checkdigit: true};
  cards [11] = {name: "VisaElectron", 
               length: "16", 
               prefixes: "417500,4917,4913",
               checkdigit: true};
               
  // Establish card type
  var cardType = -1;
  for (var i=0; i<cards.length; i++)
  {
    // See if it is this card (ignoring the case of the string)
    if (cardname.toLowerCase() == cards[i].name.toLowerCase()) {
      cardType = i;
      break;
    }
  }
  
  // If card type not found, report an error
  if (cardType == -1) {
     ccErrorNo = 0;
     return false; 
  }
   
  // Ensure that the user has provided a credit card number
  if (cardnumber.length == 0)  {
     ccErrorNo = 1;
     return false; 
  }
  
  // Check that the number is numeric, although we do permit a space to occur  
  // every four digits. 
  var cardNo = cardnumber
  var cardexp = /^([0-9]{4})\s?([0-9]{4})\s?([0-9]{4})\s?([0-9]{1,4})$/;
  if (!cardexp.exec(cardNo))  {
     ccErrorNo = 2;
     return false; 
  }
    
  // Now remove any spaces from the credit card number
  cardexp.exec(cardNo);
  cardNo = RegExp.$1 + RegExp.$2 + RegExp.$3 + RegExp.$4;
       
  // Now check the modulus 10 check digit - if required
  if (cards[cardType].checkdigit) {
    var checksum = 0;                                  // running checksum total
    var mychar = "";                                   // next char to process
    var j = 1;                                         // takes value of 1 or 2
  
    // Process each digit one by one starting at the right
    var calc;
    for (i = cardNo.length - 1; i >= 0; i--) {
    
      // Extract the next digit and multiply by 1 or 2 on alternative digits.
      calc = Number(cardNo.charAt(i)) * j;
    
      // If the result is in two digits add 1 to the checksum total
      if (calc > 9) {
        checksum = checksum + 1;
        calc = calc - 10;
      }
    
      // Add the units element to the checksum total
      checksum = checksum + calc;
    
      // Switch the value of j
      if (j ==1) {j = 2} else {j = 1};
    } 
  
    // All done - if checksum is divisible by 10, it is a valid modulus 10.
    // If not, report an error.
    if (checksum % 10 != 0)  {
     ccErrorNo = 3;
     return false; 
    }
  }  

  // The following are the card-specific checks we undertake.
  var LengthValid = false;
  var PrefixValid = false; 
  var undefined; 

  // We use these for holding the valid lengths and prefixes of a card type
  var prefix = new Array ();
  var lengths = new Array ();
    
  // Load an array with the valid prefixes for this card
  prefix = cards[cardType].prefixes.split(",");
      
  // Now see if any of them match what we have in the card number
  for (i=0; i<prefix.length; i++) {
    var exp = new RegExp ("^" + prefix[i]);
    if (exp.test (cardNo)) PrefixValid = true;
  }
      
  // If it isn't a valid prefix there's no point at looking at the length
  if (!PrefixValid) {
     ccErrorNo = 3;
     return false; 
  }
    
  // See if the length is valid for this card
  lengths = cards[cardType].length.split(",");
  for (j=0; j<lengths.length; j++) {
    if (cardNo.length == lengths[j]) LengthValid = true;
  }
  
  // See if all is OK by seeing if the length was valid. We only check the 
  // length if all else was hunky dory.
  if (!LengthValid) {
     ccErrorNo = 4;
     return false; 
  };   
  
  // The credit card is in the required format.
  return true;
}

/*============================================================================*/
function prtrefresh(val)
{
	var nickname= document.frmvkiss.nickid.value;
	var msg="You HAIL has been successfully sent to "+nickname;
	//alert(msg);
	if (val==1)
	{
		window.opener.location="outbox.php?msg="+msg;
		window.close();
	}
}


//function for Seesion Timeout Alert
/*var mywin;
function ConfirmUpdate(){
  //Ask them to extend
  //alert(document.getElementById('alertshow'));
  var timerObj2;
  if(document.getElementById('alertshow').value=="N")
  {
	  document.getElementById('alertshow').value="Y";
	  timerObj2 = setTimeout("ConfirmUpdate()",1000*60*10);
	  if(showlogoutmsg()){
		//load server side page if ok
		clearTimeout(timerObj2);
		document.getElementById('alertshow').value="N";
		SetTimer();
	  }
	  else
	  {
		//alert("Else  Part");
		SetTimer2();  
	  }
  }
  else if(document.getElementById('alertshow').value=="Y")
  {
	  //mywin.close();
	  SetTimer2();  
  }
  else
  {
	alert("Hello");  
  }
  
}      

function showlogoutmsg(){
	mywin = alert("Your session is about to expire. Press 'OK' to renew your session.");
	return true;
}*/
/*
var win = "width=300,height=300,left=0,top=100,copyhistory=no,directories=no,menubar=no,location=no,resizable=no,scrollbars=yes";
    window.open("tellfriend.php?ID="+sID,'tellfriendprofile',win);
window.open('jstimeout.php','', 'width=280,height=200,menubar=no,status=no,resizable=no,scrollbars=yes,toolbar=no, location=no' ) */
/*var timerObj;
function SetTimer(){
  //How long before timeout (should be a few minutes before your server's timeout
  var dblMinutes = 110;
  
  //set timer to call function to confirm update 
  timerObj = setTimeout("ConfirmUpdate()",1000*60*dblMinutes);
}

function SetTimer2(){
  //How long before timeout (should be a few minutes before your server's timeout
    //set timer to call function to confirm update 
  //timerObj = setTimeout("action()",1000*60*10);
  timerObj = setTimeout("action()",1000*60*10);
}

function action()
{
	window.location.href="logout.php?action=member_logout";  
}
*/
//for Admin Convention Function
function confirmDelete(delUrl)
{
	//alert(delUrl);
	var filename = new Array();
	filename = delUrl.split('?');
	//alert(filename[0]);
	if(filename[0]=="testimonials.php")
	{
  		if (confirm("Are you sure you want to delete this Testimonial!!!"))
		{
    		document.location = delUrl;
  		}
	}
	else if(filename[0]=="convention_news.php")
	{
		if (confirm("Are you sure you want to delete this convention!!!"))
		{
    		document.location = delUrl;
  		}
	}
	else
	{
		if (confirm("Are you sure you want to delete this Records!!!"))
		{
    		document.location = delUrl;
  		}
	}
}
function allowCText()
{
	if(document.frmconvention.nontext.checked)
	{
		document.frmconvention.conText.disabled = true;
	}
	else
	{
		document.frmconvention.conText.disabled = false;
	}
}
function confConvention()
{
	var urlPat=/^(\w*)\.([\-\+a-z0-9]*)\.(\w*)/;
	var matchArray=document.frmconvention.Url.value.match(urlPat);
    if (!document.frmconvention.contype[0].checked && !document.frmconvention.contype[1].checked && !document.frmconvention.contype[2].checked )
	{
    	alert("Please choose a Convention Type.\n");
    	return false;
    }
	else if(document.frmconvention.Title.value=="")
	{
		alert("Convention Title field cannot be left blank!!!");
		document.frmconvention.Title.focus();
		return false;
	}
	else if(document.frmconvention.Url.value=="")
	{
		alert("Convention URL field cannot be left blank!!!");
		document.frmconvention.Url.focus();
		return false;
	}
	else if(matchArray==null)
	{
		alert("Please provide Convention URL in correct format!!!");
		document.frmconvention.Url.focus();
		return false;
	}
	else if(!document.frmconvention.nontext.checked)
	{
		if(document.frmconvention.conText.value=="")
		{
			alert("Convention Text field cannot be left blank!!!");
			document.frmconvention.conText.focus();
			return false;
		}
	}
	else if(document.frmconvention.bannerfile.value=="")
	{
		alert("Banner picture field cannot be left blank!!!");
		document.frmconvention.bannerfile.focus();
		return false;
	}
	else if(document.frmconvention.start_date.value=="")
	{
		alert("Start date cannot be left blank!!!");
		document.frmconvention.start_date.focus();
		return false;
	}
	else if(document.frmconvention.end_date.value=="")
	{
		alert("End date cannot be left blank!!!");
		document.frmconvention.end_date.focus();
		return false;
	}
	else
	{
		return true;
	}
  
}
function confbanner()
{
	if (!document.frmbanners.imgtype[0].checked && !document.frmbanners.imgtype[1].checked)
	{
    	alert("Please choose an Image Type.\n");
    	return false;
    }
	else if(document.frmbanners.Title.value=="")
	{
		alert("Title field cannot be left blank!!!");
		document.frmbanners.Title.focus();
		return false;
	}
	else if(document.frmbanners.bannerfile.value=="")
	{
		alert("Please select file to upload");
		document.frmbanners.bannerfile.focus();
		return false;
	}
	else
	{
		return true;
	}
  
}
//for jpeg validation on profile photo page
function Validatejpg(i)
{
	var objUpload=eval(i);
	var sUpload=objUpload.value;
	if(sUpload!="")
	{
		var iExt=sUpload.indexOf("\\");
		var iDot=sUpload.indexOf(".");
		if(iDot < 0)
		{
			alert("Invalid File Path for Upload!");
			objUpload.focus();
			//event.returnValue=false; 
			return false;
		}
		if(iDot > 0)
		{
			var aUpload=sUpload.split(".");
			//alert(aUpload[aUpload.length-1]);
			if(aUpload[aUpload.length-1]!="jpg" && aUpload[aUpload.length-1]!="JPG")
			{
				alert("Only jpg Files Are Allowed!");
				objUpload.focus();
				//event.returnValue=false; 
				return false; 
			}
		}
	}
}
//for Admin Convention Function
function profileConfirm(moveto)
{
  	var filename = new Array();
	filename = moveto.split('?');
	//alert(filename[0]);
	if(filename[0]=="vkiss.php")
	{
		if (confirm("ARE YOU SURE YOU WANT TO SEND THIS USER A HAIL ?"))
		{
			document.location = moveto;
		}
	}
	else
	{
		var sec_filename = new Array();
		sec_filename = moveto.split('&');
		if(sec_filename[0]=="list_pop.php?action=hot")
		{
			if (confirm("ARE YOU SURE YOU WANT TO ADD THIS USER TO YOUR HOT LIST ?"))
			{
				window.open(moveto, '', 'width=280,height=200,menubar=no,status=no,resizable=no,scrollbars=yes,toolbar=no, location=no');
			}
		}
		else if(sec_filename[0]=="list_pop.php?action=friend")
		{
			if (confirm("ARE YOU SURE YOU WANT TO INVITE THIS USER TO YOUR FRIEND LIST ?"))
			{
				window.open(moveto, '', 'width=280,height=200,menubar=no,status=no,resizable=no,scrollbars=yes,toolbar=no, location=no');
			}

		}
		else{}
	}
}
//for closing child window on Bridge Page
function close_child(move_url)
{
	//alert(move_url);
	window.opener.location=move_url;
	window.close();
}
function show_betweenage(i,j,k,l,m,n,o,p,q)
{
	var whois = i.value;
	if(whois=='A Non-Dating Community Member')
	{
		j.style.display = 'none';
		k.style.display = 'none';
		l.style.display = 'inline';
		m.style.display = 'inline';
		n.style.display = 'inline';
		o.style.display = 'inline';
		p.style.display = 'inline';
		q.style.display = 'inline';
	}
	else
	{
		j.style.display = 'inline';
		k.style.display = 'inline';
		l.style.display = 'none';
		m.style.display = 'none';
		n.style.display = 'none';
		o.style.display = 'none';
		p.style.display = 'none';
		q.style.display = 'none';
	}
}
function show_whoisSection(a,b,c,d,e,f,g,h)
{
	if(a.value=="Married" || a.value=="In a Relationship" || a.value=="Single But Not Looking")
	{
		b.style.display = 'none';
		c.style.display = 'none';
		d.style.display = 'none';
		e.style.display = 'none';
		f.style.display = 'none';
		g.style.display = 'none';
		h.checked = true;
	}
	else
	{
		b.style.display = 'inline';
		c.style.display = 'inline';
		d.style.display = 'inline';
		e.style.display = 'inline';
		f.style.display = 'inline';
		g.style.display = 'inline';
		h.checked = false;
	}
}

function showStatediv(cval)
{
	//alert(cval);
	var ge1=document.getElementById('d1');
	var ge2=document.getElementById('d2');
	var ge3=document.getElementById('d3');
	var ge4=document.getElementById('state_select');
	var ge5=document.getElementById('state_text');
	var ge6=document.getElementById('d4');
	var ge7=document.getElementById('zip');
	if(cval=="United States")
	{
		ge1.style.display="none";
		ge2.style.display="inline";
		ge3.style.display="none";
		ge4.disabled = false;
		ge5.disabled = true;
		ge6.style.display="inline";
		ge7.disabled = false;
	}
	else
	{
		ge1.style.display="inline";
		ge2.style.display="none";
		ge3.style.display="inline";
		ge4.disabled = true;
		ge5.disabled = false;
		ge6.style.display="none";
		ge7.disabled = true;
	}	
}

function showtestimonial(i,j)
{
	window.open('viewtestimonials.php?testby='+i+'&pgname='+j, 'imagePreview','width=600,height=450,left=100,top=75,screenX=100,screenY=75,scrollbars,resizable=1');
}

function submitParent()
{
	var pre = window.opener.document.form1.action;
	//alert(pre);
	var newpre = "middle.php?page=testimonials&pagesubmit=ok";
	window.opener.document.form1.action = newpre;
	window.opener.document.form1.submit();
	window.close();
}
function editParent()
{
	var editpre = window.opener.document.form6.action;
	//alert(editpre);
	var editnewpre = "middle.php?page=edittestimonial";
	window.opener.document.form6.action = editnewpre;
	window.opener.document.form6.submit();
	window.close();
}
function editBoth()
{
	var editpre = window.opener.document.form6.action;
	//alert(editpre);
	var editnewpre = "middle.php?page=testimonialpic";
	window.opener.document.form6.action = editnewpre;
	window.opener.document.form6.submit();
	window.close();
}
function nonsubmitParent()
{
	window.close();
}
function alertDelete(Url)
{
    var agree=confirm("Are you sure you want to delete this comment?");
   	if (agree)
	{
    	document.location = Url;
  	}
}