/*--- GLOBALS ---*/
function showDiv(divID) {
  var refID = document.getElementById(divID);
  refID.style.display = "block";
  return true;
}
function hideDiv(divID) {
  var refID = document.getElementById(divID);
  refID.style.display = "none";
  return true;
}
function clearValue(el) {
  if (el.defaultValue==el.value) el.value = ""
}

//Signup Validation & Password Strength

function toggle_pass(passid) {
    if (window.XMLHttpRequest) {
        http = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        http = new ActiveXObject("Microsoft.XMLHTTP");
    }
    handle = document.getElementById(passid);
    var url = 'password_strength_check.php?';
    if(handle.value.length > 0) {
        var fullurl = url + 'do=check_password_strength&pass=' + encodeURIComponent(handle.value);
        http.open("GET", fullurl, true);
        http.send(null);
        http.onreadystatechange = statechange_password;
    }else{
        document.getElementById('password_strength').innerHTML = '';
    }
}

function statechange_password() {
    if (http.readyState == 4) {
        var xmlObj = http.responseXML;
        var html = xmlObj.getElementsByTagName('result').item(0).firstChild.data;
        document.getElementById('password_strength').innerHTML = html;
    }
}

  function OnCheckAvailability()
  {
	 	 if (document.Registration.email.value){
    		 if (echeck(document.Registration.email.value))
    		 {
            if(window.XMLHttpRequest)
            {
               oRequest = new XMLHttpRequest();
            }
            else if(window.ActiveXObject)
            {
               oRequest = new ActiveXObject("Microsoft.XMLHTTP");
            }
               oRequest.open("POST", "available_email.php", true);
               oRequest.onreadystatechange = UpdateCheckAvailability;
               oRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
               oRequest.send("strCmd=availability&strEmail=" + document.Registration.email.value);
      	 }
		 }else{
		 		 document.getElementById("Available").innerHTML = "";
		 }
	}
	
	function OnCheckMatch()
	{
	 	 if (document.Registration.password2.value=='' || document.Registration.pass.value != document.Registration.password2.value)
		 {
		 		document.getElementById("pass_match").innerHTML = "Passwords Do Not Match";
		 }else{
		    document.getElementById("pass_match").innerHTML = "Passwords Match";
		 }
	}
	
  function UpdateCheckAvailability()
  {
    if(oRequest.readyState == 4)
    { 
      if(oRequest.status == 200)
      {
         document.getElementById("Available").innerHTML = oRequest.responseText;
      }
      else
      {
         document.getElementById("Available").innerHTML = "Asychronous Error";
      }
    }
  }

	
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		
		if (str.indexOf(at)==-1){
		   document.getElementById("Available").innerHTML = "Invalid Email Address";
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   document.getElementById("Available").innerHTML = "Invalid Email Address";
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    document.getElementById("Available").innerHTML = "Invalid Email Address";
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    document.getElementById("Available").innerHTML = "Invalid Email Address";
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    document.getElementById("Available").innerHTML = "Invalid Email Address";
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    document.getElementById("Available").innerHTML = "Invalid Email Address";
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    document.getElementById("Available").innerHTML = "Invalid Email Address";
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var emailID=document.frmSample.txtEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
 
 function handleFocus(element)  
{  
 if (element.value == element.defaultValue)   
 {  
 element.value = '';  
 }  
}  
  
function handleBlur(element)  
{  
 if (element.value == '')  
 {  
 element.value = element.defaultValue;  
 }  
}
	
	
//Maxlength on Textareas 

function ismaxlength(obj){
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}


//Place Conditionals (Category)

function checkOther(select){
	//show phone
	if( 
		select[select.selectedIndex].value=="Antiques" 
  	||
		select[select.selectedIndex].value=="Art House" 
  	||
		select[select.selectedIndex].value=="Bar or Pub" 
  	||
  	select[select.selectedIndex].value=="Business" 
  	||
		select[select.selectedIndex].value=="Club"
		||
		select[select.selectedIndex].value=="Coffee Shop"
  	||
  	select[select.selectedIndex].value=="Community"
  	||
  	select[select.selectedIndex].value=="Educational"
  	||
		select[select.selectedIndex].value=="Farmers Market"
  	||
  	select[select.selectedIndex].value=="Government"
  	||
		select[select.selectedIndex].value=="Grocery"
  	||
		select[select.selectedIndex].value=="Gym"
  	||
  	select[select.selectedIndex].value=="Landmark"
  	||
		select[select.selectedIndex].value=="Movie Theater"
  	||
  	select[select.selectedIndex].value=="Museum"
  	||
  	select[select.selectedIndex].value=="Parks & Recreation"
  	||
  	select[select.selectedIndex].value=="Place of Worship"
  	||
  	select[select.selectedIndex].value=="Restaurant"
  	||
  	select[select.selectedIndex].value=="Retail"
  	||
  	select[select.selectedIndex].value=="Sports Venue"
		||
  	select[select.selectedIndex].value=="Theme Park"
	){
    document.getElementById("phone").style.display = "inline";
	}else{
    document.getElementById("phone").style.display = "none";
	}	
	
	//show address
	if( 
		select[select.selectedIndex].value=="Antiques" 
  	||
		select[select.selectedIndex].value=="Art House" 
  	||
		select[select.selectedIndex].value=="Bar or Pub" 
  	||
  	select[select.selectedIndex].value=="Business" 
  	||
		select[select.selectedIndex].value=="Club"
		||
		select[select.selectedIndex].value=="Coffee Shop"
  	||
  	select[select.selectedIndex].value=="Community"
  	||
  	select[select.selectedIndex].value=="Educational"
  	||
		select[select.selectedIndex].value=="Farmers Market"
  	||
  	select[select.selectedIndex].value=="Government"
  	||
		select[select.selectedIndex].value=="Grocery"
  	||
		select[select.selectedIndex].value=="Gym"
  	||
  	select[select.selectedIndex].value=="Landmark"
  	||
		select[select.selectedIndex].value=="Movie Theater"
  	||
  	select[select.selectedIndex].value=="Museum"
  	||
  	select[select.selectedIndex].value=="Parks & Recreation"
  	||
  	select[select.selectedIndex].value=="Place of Worship"
  	||
  	select[select.selectedIndex].value=="Restaurant"
  	||
  	select[select.selectedIndex].value=="Retail"
  	||
  	select[select.selectedIndex].value=="Sports Venue"
		||
  	select[select.selectedIndex].value=="Theme Park"
	){
    document.getElementById("address").style.display = "inline";
	}else{
    document.getElementById("address").style.display = "none";
	}
	
	//show city
	if( 
		select[select.selectedIndex].value=="Antiques" 
  	||
		select[select.selectedIndex].value=="Art House" 
  	||
		select[select.selectedIndex].value=="Bar or Pub" 
  	||
  	select[select.selectedIndex].value=="Business" 
  	||
		select[select.selectedIndex].value=="Club"
		||
		select[select.selectedIndex].value=="Coffee Shop"
  	||
  	select[select.selectedIndex].value=="Community"
  	||
  	select[select.selectedIndex].value=="Educational"
  	||
		select[select.selectedIndex].value=="Farmers Market"
  	||
  	select[select.selectedIndex].value=="Government"
  	||
		select[select.selectedIndex].value=="Grocery"
  	||
		select[select.selectedIndex].value=="Gym"
  	||
  	select[select.selectedIndex].value=="Landmark"
  	||
		select[select.selectedIndex].value=="Movie Theater"
  	||
  	select[select.selectedIndex].value=="Museum"
  	||
  	select[select.selectedIndex].value=="Parks & Recreation"
  	||
  	select[select.selectedIndex].value=="Place of Worship"
  	||
  	select[select.selectedIndex].value=="Restaurant"
  	||
  	select[select.selectedIndex].value=="Retail"
  	||
  	select[select.selectedIndex].value=="Sports Venue"
		||
  	select[select.selectedIndex].value=="Theme Park"
	){
    document.getElementById("city").style.display = "inline";
	}else{
    document.getElementById("city").style.display = "none";
	}

	//show state
	if( 
		select[select.selectedIndex].value=="Antiques" 
  	||
		select[select.selectedIndex].value=="Art House" 
  	||
		select[select.selectedIndex].value=="Bar or Pub" 
  	||
		select[select.selectedIndex].value=="Body of Water"
		||
  	select[select.selectedIndex].value=="Business" 
  	||
		select[select.selectedIndex].value=="Club"
		||
		select[select.selectedIndex].value=="City or Town"
		||
		select[select.selectedIndex].value=="Coffee Shop"
  	||
  	select[select.selectedIndex].value=="Community"
  	||
  	select[select.selectedIndex].value=="Educational"
  	||
		select[select.selectedIndex].value=="Farmers Market"
  	||
  	select[select.selectedIndex].value=="Government"
  	||
		select[select.selectedIndex].value=="Grocery"
  	||
		select[select.selectedIndex].value=="Gym"
  	||
  	select[select.selectedIndex].value=="Landmark"
  	||
		select[select.selectedIndex].value=="Movie Theater"
  	||
  	select[select.selectedIndex].value=="Museum"
  	||
  	select[select.selectedIndex].value=="Parks & Recreation"
  	||
  	select[select.selectedIndex].value=="Place of Worship"
  	||
  	select[select.selectedIndex].value=="Restaurant"
  	||
  	select[select.selectedIndex].value=="Retail"
  	||
  	select[select.selectedIndex].value=="Sports Venue"
	||
  	select[select.selectedIndex].value=="Theme Park"
	){
    document.getElementById("state").style.display = "inline";
	}else{
    document.getElementById("state").style.display = "none";
	}
	
	//show postal
	if( 
		select[select.selectedIndex].value=="Antiques" 
  	||
		select[select.selectedIndex].value=="Art House" 
  	||
		select[select.selectedIndex].value=="Bar or Pub" 
  	||
  	select[select.selectedIndex].value=="Business" 
  	||
		select[select.selectedIndex].value=="Club"
		||
		select[select.selectedIndex].value=="Coffee Shop"
  	||
  	select[select.selectedIndex].value=="Community"
  	||
  	select[select.selectedIndex].value=="Educational"
  	||
		select[select.selectedIndex].value=="Farmers Market"
  	||
  	select[select.selectedIndex].value=="Government"
  	||
		select[select.selectedIndex].value=="Grocery"
  	||
		select[select.selectedIndex].value=="Gym"
  	||
  	select[select.selectedIndex].value=="Landmark"
  	||
		select[select.selectedIndex].value=="Movie Theater"
  	||
  	select[select.selectedIndex].value=="Museum"
  	||
  	select[select.selectedIndex].value=="Parks & Recreation"
  	||
  	select[select.selectedIndex].value=="Place of Worship"
  	||
  	select[select.selectedIndex].value=="Restaurant"
  	||
  	select[select.selectedIndex].value=="Retail"
  	||
  	select[select.selectedIndex].value=="Sports Venue"
		||
  	select[select.selectedIndex].value=="Theme Park"
	){
    document.getElementById("postal").style.display = "inline";
	}else{
    document.getElementById("postal").style.display = "none";
	}
	
	//show country
	if( 
		select[select.selectedIndex].value=="Body of Water"
		||
  	select[select.selectedIndex].value=="City or Town"
		||
  	select[select.selectedIndex].value=="Government"
  	||
		select[select.selectedIndex].value=="Landmark"
  	||
  	select[select.selectedIndex].value=="Parks & Recreation"
  	||
  	select[select.selectedIndex].value=="State or Province"
	){
    document.getElementById("country").style.display = "inline";
	}else{
    document.getElementById("country").style.display = "none";
	}
	
}// end



//Forgot Password Function

function ajaxFunction()
{

	var emailadd = document.getElementById('emailadd');

	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){	
			var ajaxDisplay = document.getElementById('messagebox');
			if (ajaxRequest.responseText.length<=7){
				 ajaxDisplay.style.display = 'none';
			}else{
				 ajaxDisplay.style.display = 'block';
				 ajaxDisplay.innerHTML = ajaxRequest.responseText;
			}
		}
	}
	
	var queryString = '?func=forgotpass&email=' + emailadd.value;
	ajaxRequest.open("GET", "functions.php" + queryString, true);
	ajaxRequest.send(null); 
    	
		
}//end





//Add Comments (News Fullstory Page)

function ajaxComment(uID,newsID){

	var newcomment = fix_chars(document.getElementById('comment').value);
	var textarea = document.getElementById('comment');
	var newcomment = nl2br(textarea.value);
	var ajaxRequest;  // The variable that makes Ajax possible!
	var ele = document.getElementById("toggleText");
	var text = document.getElementById("displayText");

	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
    	if(ele.style.display == "block") {
        ele.style.display = "none";
				textarea.value = '';
    		text.innerHTML = "Discuss this Scoop";
      }			
			var ajaxDisplay = document.getElementById('display_comments');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	
	var queryString = '?func=addComment&userID='+ uID +'&newsID=' + newsID + '&comments="' + newcomment + '"';
	ajaxRequest.open("GET", "functions.php" + queryString, true);
	ajaxRequest.send(null); 
}//end 


//Reply to Comments (News Fullstory Page)

function ajaxReply(replyTextID,commentID,uID,newsID){

	//var newcomment = fix_chars(document.getElementById('comment').value);
	var toggleID = "toggleReplyText"+replyTextID;
	var textID = "displayReplyText"+replyTextID;
	var textarea = document.getElementById('reply'+replyTextID);
	var newreply = nl2br(textarea.value);
	var ajaxRequest;  // The variable that makes Ajax possible!
	var ele = document.getElementById(toggleID);
	var text = document.getElementById(textID);

	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
    	if(ele.style.display == "block") {
        ele.style.display = "none";
				textarea.value = '';
    		text.innerHTML = "reply";
      }			
			var ajaxDisplay = document.getElementById('display_comments');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	
	var queryString = '?func=addReply&commentID=' + commentID + '&userID='+ uID +'&newsID=' + newsID + '&reply="' + newreply + '"';
	//alert (queryString);
	ajaxRequest.open("GET", "functions.php" + queryString, true);
	ajaxRequest.send(null); 
}//end
	

//Delete Comments (News Fullstory Page)

function ajaxComDel(commentID,newsID){

	var ajaxRequest;  // The variable that makes Ajax possible!

	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('display_comments');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
	}
	
	var queryString = '?func=delComment&commentID=' + commentID + '&newsID=' + newsID;

	ajaxRequest.open("GET", "functions.php" + queryString, true);
	ajaxRequest.send(null); 
}//end


//Toggle Comments, Add Line Breaks and Strip out characters (News Fullstory Page)
 
function toggle() {
	var ele = document.getElementById("toggleText");
	var text = document.getElementById("displayText");
	var textarea = document.getElementById('comment');
	if(ele.style.display == "block") {
    ele.style.display = "none";
		text.innerHTML = "Discuss this Scoop";
		textarea.value = "What's on your mind?"
  	}
	else {
		ele.style.display = "block";
		text.innerHTML = "cancel";
	}
} 
function toggleReply(dispID) {
	//var ele = document.getElementById("toggleReplyText");
	var toggleID = "toggleReplyText"+dispID;
	var ele = document.getElementById(toggleID);
	var textID = "displayReplyText"+dispID;
	var text = document.getElementById(textID);
	var textarea = document.getElementById('reply');
	if(ele.style.display == "block") {
    ele.style.display = "none";
		text.innerHTML = "reply";
		textarea.value = "What's on your mind?"
  	}
	else {
		ele.style.display = "block";
		text.innerHTML = "cancel";
	}
} 
function nl2br (str, is_xhtml) {
    var breakTag = '';
 
    breakTag = '<br />';
    if (typeof is_xhtml != 'undefined' && !is_xhtml) {
        breakTag = '<br>';
    }
 
    return (str + '').replace(/([^>]?)\n/g, '$1'+ breakTag +'\n');
}
function fix_chars(val)
{
    var strReplaceAll = val;
    var intIndexOfMatch = strReplaceAll.indexOf( "'" );
     
    while (intIndexOfMatch != -1){
      strReplaceAll = strReplaceAll.replace( "'", "&#39;" )
      intIndexOfMatch = strReplaceAll.indexOf( "'" );
    }		
		return strReplaceAll;
}// end


//Add Person Validation

function validate_required(field,alerttxt)
	{
	with (field)
  {
  if (value==null||value=="")
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
	}
	function validate_form(thisform)
	{         
  with (thisform)
    {
    
      if (validate_required(name,"Please tell us who you're reviewing...")==false)
      {name.focus();return false;}
      
      if (validate_required(category,"Please fill in the type of person this is...")==false)
      {category.focus();return false;}
      
      if (validate_required(tags,"Please include at least one tag...")==false)
      {tags.focus();return false;}
      
      if (validate_required(bio,"Please include a short bio...")==false)
      {bio.focus();return false;}
			
			if (validate_required(occupation,"Please include this person's occupation...")==false)
      {occupation.focus();return false;}      
    }
}//end


//Add Place Validation

	function validate_required(field,alerttxt)
	{
	with (field)
  {
  if (value==null||value=="")
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
	}
	function validate_form(thisform)
	{
  with (thisform)
    {

      if (validate_required(name,"Please fill in the name of what you're reviewing...")==false)
      {name.focus();return false;}
      
      if (validate_required(category,"Please fill in the category...")==false)
      {category.focus();return false;}
      
      if (validate_required(tags,"Please include at least one tag...")==false)
      {tags.focus();return false;}
      
      if (validate_required(description,"Please include a description...")==false)
      {description.focus();return false;}
      
			if (thisform.category.options[thisform.category.selectedIndex].value!='City or Town' || thisform.category.options[thisform.category.selectedIndex].value!='Landmark' ||  thisform.category.options[thisform.category.selectedIndex].value!='Parks & Recreation')
			{
			 	 if (validate_required(address1,"Please include the address or closest cross street...")==false) 
					{address1.focus();return false;}
					
	    		if (validate_required(city,"Please include the city...")==false)
      		{city.focus();return false;}
			}
			
			if (validate_required(state,"Please include the state...")==false)
      {state.focus();return false;}
      
      if (validate_required(postal,"Please include a zip or postal code...")==false)
      {postal.focus();return false;}
      
      if (validate_required(country,"Please include the country...")==false)
      {country.focus();return false;}
      
    }	

	} //end
	
	
//Add Thing Validation	

function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {
  alert(alerttxt);return false;
  }
else
  {
  return true;
  }
}
}
function validate_form(thisform)
{
with (thisform)
  {

    if (validate_required(name,"Please tell us what you're reviewing...")==false)
    {name.focus();return false;}
    
    if (validate_required(category,"Please fill in the type of thing this is...")==false)
    {category.focus();return false;}
    
    if (validate_required(tags,"Please include at least one tag...")==false)
    {tags.focus();return false;}
    
    if (validate_required(description,"Please include a short description...")==false)
    {description.focus();return false;}	
	}	
}//end

//Get Inbox Count
  //var parentTitle = top.document.title
	//getTimeFnInterval = setInterval ( "getInbox()", 3000 );

function getInbox()
	{
    	var parentTitle = top.document.title
	getTimeFnInterval = setInterval ( "getInbox()", 3000 );
      var ajaxRequest;  
    	var inboxmsg;
    	try{
    		// Opera 8.0+, Firefox, Safari
    		ajaxRequest = new XMLHttpRequest();
    	} catch (e){
    		// Internet Explorer Browsers
    		try{
    			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    		} catch (e) {
    			try{
    				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
    			} catch (e){
    				// Something went wrong
    				alert("Your browser broke!");
    				return false;
    			}
    		}
    	}
    	// Create a function that will receive data sent from the server
    	ajaxRequest.onreadystatechange = function(){
    		if(ajaxRequest.readyState == 4){	
    			var ajaxDisplay = document.getElementById('inboxCount');
					
    			//if (ajaxRequest.responseText.length<=7){
					//	 ajaxDisplay.style.display = 'none';
					//}else{
					//	 ajaxDisplay.style.display = 'block';
						 ajaxDisplay.innerHTML = ajaxRequest.responseText;
						 var str = ajaxRequest.responseText;
						 var inboxCount = str.substr(1,(str.length)-9 );
						 //alert (inboxCount);
						 //alert(ajaxRequest.responseText);
						 if(inboxCount>0){
						 		top.document.title = parentTitle + ' : ' + ajaxRequest.responseText + 'New Messages!';
						 		//alert('You have a New Message!!');
						 		// $.facebox('You have a New Message!!');
						 }
					//}
    		}
    	}
    	
    	var queryString = '?func=inboxCount';
    	ajaxRequest.open("GET", "/functions.php" + queryString, true);
    	ajaxRequest.send(null); 		
	}	


//Facebox JS for SignUp - Facebook Integration
function openpage(url) { 

	var ajaxRequest;
	try{
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){	
			var direction = ajaxRequest.responseText; 			
			if (direction == 0){
						jQuery.facebox(function($) {jQuery.get(url, function(data) { jQuery.facebox(data, false, "facebox_identifier") }) }, false, "facebox_identifier") 						
			}else{
						window.location = "http://www.youscoopit.com/home.php";
			}			 			
		}
	}
	var queryString = '?func=fbconnect';
	ajaxRequest.open("GET", "/functions.php" + queryString, true);
	ajaxRequest.send(null);
}//end


//get YouTube ID from URL string
function getYouTubeID(urlStr){
//alert (urlStr);
  var startposition;
  var mySubstring = "&";
  var foundAtPosition;
  var youTubeID;
	if (urlStr.search('object')!=-1){
      startposition = urlStr.search('v/')+2;
      foundAtPosition = urlStr.indexOf(mySubstring,urlStr.search('v/')+2);
      youTubeID = urlStr.slice(startposition,foundAtPosition);
			//alert ("OBJECT");
	}else if (urlStr.search('v=')!=-1){
      startposition = urlStr.search(/v=/)+2;
			if ((urlStr.search(mySubstring)==-1)){
				 		foundAtPosition = urlStr.length;
			}else{			
      			foundAtPosition = urlStr.indexOf(mySubstring,urlStr.search(/v=/)+2);
			}			
      youTubeID = urlStr.slice(startposition,foundAtPosition);
			//alert (urlStr.length);
  }else{
			youTubeID = '';
	}
	//alert(foundAtPosition);
  document.getElementById("favvid").value = youTubeID;
  
  //document.write("<P>" + myString.slice(startposition,foundAtPosition));
}














