// JavaScript Document

//Mootools required functions
function hideComments()
{	
$('Comments').slide('out');
$('hidecommentsLink').style.display ='none';
$('showcommentsLink').style.display ='inline-block';

}

function showComments()
{
$('Comments').slide('in');
$('hidecommentsLink').style.display ='inline-block';
$('showcommentsLink').style.display ='none';	
}

//==============FOR COMMENT SYSTEM===========
function toggleCommentForm()
{
 if(document.getElementById('commentForm').style.display=='none')
 {
//document.getElementById('submitCommentLink').innerHTML ="Hide Comment Form";	 
document.getElementById('review_rate_btn').src ="images/review_rate_hide.png";	 

 
 document.getElementById('commentForm').style.display='block';
 }
 else
  {
  document.getElementById('commentForm').style.display='none';
document.getElementById('review_rate_btn').src ="images/review_rate.png";	 
  
 // document.getElementById('submitCommentLink').innerHTML ="Submit a Comment &amp; Rate this Solution";	 

  }
}

function processForm(sid)
{
var TestForm = checkForm('CommentsForm');

if(TestForm)
{
$('contact').disabled = true;	
get(sid);
}

}

//Comment out when using protoype or mootools
/*
function $(id) {
  return document.getElementById(id);
}
*/

function createXMLHttpRequest() {
      try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
      try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
      try { return new XMLHttpRequest(); } catch(e) {}
      alert("XMLHttpRequest not supported");
      return null;
}


 function makePOSTRequest(url, parameters) {
      http_request = false;
	
	http_request = createXMLHttpRequest();
      
	  if (http_request.overrideMimeType)
            http_request.overrideMimeType('text/html');
	  
	  //build body for Form Post
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
				if(result == "success")
				{
					$('commentForm').style.display = 'none';
					$('commentMsg').innerHTML = "Your comment has been received and is pending approval, thank you!<br/><br/>";
				//	$('submitCommentLink').innerHTML ="Submit a Comment";
					$('contact').disabled = false;	
					$('Name').value = '';
					$('Comment').value = '';
					$('rating').value = '5';
					$('review_rate_btn').src ="images/review_rate.png";	
					
				}
				else
				{
					$('commentForm').style.display = 'none';
					$('submitCommentLink').innerHTML ="Submit a Comment";
					$('commentMsg').innerHTML = "There was an error sending your request, please try again later.";	
					$('contact').disabled = false;	
					$('review_rate_btn').src ="images/review_rate.png";
				}

         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   

   //this get function encodes the form values into URIs which can be sent as Post Vars to the CFM page
   function get(sid) 
   {

	var poststr = "reviewer_name=" + encodeURI( $('Name').value ) + "&comment=" + encodeURI( $('Comment').value ) 
	+ "&rating=" + encodeURI( $('rating').value ) + "&key=" + encodeURI( $('key').value ) + "&sid=" + encodeURI( sid);
	
  	//alert(poststr);

   makePOSTRequest('comment_submit.php', poststr);
   }
   
   
   //FOR GOOGLE AD
function moveBanner()
{
	
var browserName=navigator.appName; 
var platformOS =navigator.platform;
var checkOS = platformOS.indexOf('Mac');
var checkOS = checkOS * 1;	
	
if(checkOS != -1) // a mac
{
	//do nothing
}
	
var browserName=navigator.appName; 
if (browserName=="Netscape") //also works with firefox, fixes spacing issue with firefox
{ 
//do nothing
}
else
{
 var ua = window.navigator.appVersion;
 //alert(ua);
//alert(ua.charAt(22));
ua= ua.charAt(22);

	if(ua == "6")
	{
	$('leftBanner').style.left = "-155px";
	$('leftBanner').style.top = "-68px";

	}
	else if(ua == "7")
	{
	//do nothing
	}
}	

}
   