/*
        function siteLogin()
	{
		window.location = 'http://www.godsurfer.com/functions/functionLogin.php?userName='+document.formLogin.userName.value+'&password='+document.formLogin.password.value+'&logOut=false';
	}
	
	function logout()
	{
	 window.location = 'http://www.godsurfer.com/functions/functionLogin.php?logOut=true';		
	}

	function loginCheck(blnVal)
	{
		var fullURL = parent.document.URL 
		var reg = fullURL.substring(fullURL.indexOf('?')+5, fullURL.length)

		if (reg == 'false')
			{
				overlay();				
			}
		if (blnVal == 'on')
			{
			 	myBooleanValue = 'on';
			 	document.getElementById('blnValue').value = 'on';
				ajaxFunction();	
				//ajax.js				
			}
	}

	function regUser()
	{
                document.formRegistration.action = 'http://www.godsurfer.com/functions/functionRegister.php';
                document.formRegistration.submit();
	}
*/

        function selectAll(elementId)
        {
            document.getElementById(elementId).focus();
            document.getElementById(elementId).select();
        }
        
        function verify(){
                //alert('verify');
                var url = document.getElementById("URL").value;
                var title = document.getElementById("storyTitle").value;
                var summary = document.getElementById("storyDescription").value;
                //var category = document.getElementById("cboCategory").value;

                if (url == '') {
                        alert("Please Enter a valid URL");
                        document.getElementById("URL").focus();
                        return;
                }else{
                        var v = new RegExp();
                        v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");

                    if (!v.test(url)) {
                        //alert("There seems to be a problem with the format of the URL entered.  Please double check before submitting.");
                        //document.getElementById("URL").focus();
                        document.getElementById("URLExists").style.visibility = "visible";
                        //return;
                    }else{
                         document.getElementById("URLExists").style.visibility = "hidden";
                         ajaxFunctionGetURL(document.getElementById("URL").value);
                    }

                }

                if  (title == '') {
                        alert("Please Enter a descriptive title for the story you are linking to.");
                        document.getElementById("storyTitle").focus();
                        return;
                }

                if (summary == '') {
                        alert("Please write a summary of the Article, Blog or site that you are submitting.")
                        document.getElementById("storyDescription").focus();
                        return;
                }
                //document.formAddStory.submit();
        }
        
        function textCounter(txtfield, cntFld, maxlimit) {

         var field = document.getElementById(txtfield);
         var countfield = document.getElementById(cntFld);

                if (field.value.length > maxlimit) // if too long...trim it!
                {
                        field.value = field.value.substring(0, maxlimit);
                        // otherwise, update 'characters left' counter
                }else {
                        countfield.innerHTML = maxlimit - field.value.length;
                }


                //alert(document.getElementById("URL").value);
                if(field.value.length == 1){
                    //verify();
                }
                
        }



        function showImage(id){
         //alert(id);
                if(id > 0){
                        document.getElementById("URLExists").style.visibility = "visible";
                        document.getElementById("URLExists").innertext = "X";
                        document.getElementById("URL").value = "URL Exists!";
                        document.formAddStory.cmdSubmit.disabled=true;

                }else{
                        document.getElementById("URLExists").style.visibility = "hidden";
                        document.getElementById("URLExists").innertext = "GOOD!";
                        document.formAddStory.cmdSubmit.disabled=false;
                        //var URL = document.getElementById("URL").value;
                        //alert(URL);
                        //URL = URL.replace("http://", "")
                        //alert(URL);
                        //var CodeCreation = '<br/>&lt;script type="text/javascript"&gt;<br/>GODSurfer_url = "' + URL + '"; &lt;/script&gt;<br/>&lt;script src="http://www.godsurfer.com/tools/GODSurfer.js" type="text/javascript"&gt;&lt;/script&gt;';
                        //document.getElementById("codeText").innerHTML = CodeCreation;


                        //var CodeButton = '<script type="text/javascript"> GODSurfer_url = "' + URL + '";</script><script src="http://www.godsurfer.com/tools/GODSurfer.js" type="text/javascript"></script>';

                        //document.getElementById("codeHTML").innertext = '<script type="text/javascript"> GODSurfer_url = "' + URL + '";</script><script src="http://www.godsurfer.com/tools/GODSurfer.js" type="text/javascript"></script>';

                        //document.getElementById("hdnValue").value = CodeButton;
                        //alert(document.getElementById("hdnValue").value);

                        //document.getElementById("codeCopy").innerHTML = 'Copy this code and place it on your page so your viewers can vote on it! <br/><a href="#" onclick="copy();">Copy Code to Clipboard</a>';



                        //alert(document.getElementById("codeText").innerHTML);
                }
        }

        function addStory(){
                //ajaxFunctionGetURL(document.getElementById("URL").value);
                document.formAddStory.action = 'http://www.godsurfer.com/AlphaProject/functions/functionAddStory.php';
                document.formAddStory.submit();
        }

        function addQuestion(){
                //ajaxFunctionGetURL(document.getElementById("URL").value);
                document.formAddQuestion.action = 'http://www.godsurfer.com/AlphaProject/functions/functionAddQuestion.php';
                document.formAddQuestion.submit();
        }

        function addAnswer(){
         alert('hi');
        }
