

var ajax = new sack();

function whenLoadingSTF(){
	var e = document.getElementById('sendtofriend'); 
	e.innerHTML = "<p>Loading Data...</p>";
}

function whenLoadedSTF(){
	var e = document.getElementById('sendtofriend'); 
	e.innerHTML = "<p>Data Sent...</p>";
}

function whenInteractiveSTF(){
	var e = document.getElementById('sendtofriend'); 
	e.innerHTML = "<p>getting data...</p>";
}
function whenLoadingRATE(){
	var e = document.getElementById('star-rating'); 
	e.innerHTML = "<span nowrap>Rating Video...</span>";
}

function whenLoadingCOMMENTS(){
	var e = document.getElementById('comments'); 
	e.innerHTML = "<span nowrap>Loading Comments...</span>";
}
function whenLoadingFAVS(){
	var e = document.getElementById('comments'); 
	e.innerHTML = "<span nowrap>Loading Favorites...</span>";
}


function whenCompleted(){
	var e = document.getElementById('sackdata'); 
	if (ajax.responseStatus){
		var string = "<p>Status Code: " + ajax.responseStatus[0] + "</p><p>Status Message: " + ajax.responseStatus[1] + "</p><p>URLString Sent: " + ajax.URLString + "</p>";
	} else {
		var string = "<p>URLString Sent: " + ajax.URLString + "</p>";
	}
	e.innerHTML = string;	
}




function getpoll(id,polllayer) {

var ajax = new sack();
    ajax.setVar("id", id);
	ajax.requestFile = "http://www.1800banners.com/blog//ajaxoperations/poll.php";
    ajax.method = 'POST';
	ajax.element = polllayer;
	//ajax.onLoading = whenLoadingCOMMENTS;
	//ajax.onCompletion = commentscomplete;
	ajax.runAJAX();

  


}

function answerpoll(question_id,id,polllayer,question_type) {

var theanswer_id;

    if(question_type==1) {
    var arraystring='';

eval("theanswer_id=document.pollanswers_"+ question_id + ".answer_id_"+ question_id + "_;");

      for (var i=0; i < theanswer_id.length; i++) { 

			if (theanswer_id[i].checked) {
         arraystring=arraystring + theanswer_id[i].value + ',';
      }  
    }
   
    } else {

eval("theanswer_id=document.pollanswers_"+ question_id + ".answer_id_"+ question_id + "_;");



  var answer_id;
      for (var i=0; i < theanswer_id.length; i++) { 

			if (theanswer_id[i].checked) {
         answer_id=theanswer_id[i].value;
      }
    } 
        
    }
    
    var ajax = new sack();
    ajax.setVar("question_id", question_id);
    ajax.setVar("answer_ids", arraystring);
    ajax.setVar("answer_id", answer_id);
    ajax.setVar("id", id);
	ajax.requestFile = "http://www.1800banners.com/blog//ajaxoperations/poll.php";
    ajax.method = 'POST';
	ajax.element = polllayer;
	//ajax.onLoading = whenLoadingCOMMENTS;
	//ajax.onCompletion = commentscomplete;
	ajax.runAJAX();

  


}



function gotopage(page,id) {

var ajax = new sack();
    ajax.setVar("id", id);
 	ajax.setVar("page",page);
	ajax.requestFile = "http://www.1800banners.com/blog//includes/program/area_pictures/comments.php";
	ajax.method = 'POST';
	ajax.element = 'comments';
	ajax.onLoading = whenLoadingCOMMENTS;
	ajax.onCompletion = commentscomplete;
	ajax.runAJAX();
location.href="#commentanchor";
}


function getloginform(id) {

var ajax = new sack();


 	ajax.setVar("loginform",'1');
	ajax.setVar("forward",'comments');
    ajax.setVar("id",id);
	ajax.requestFile = "http://www.1800banners.com/blog//includes/program/UIclasses/ajaxlogin.php";
	ajax.method = 'POST';
	ajax.element = 'comments';
//	ajax.onLoading = whenLoadingCOMMENTS;

	ajax.runAJAX();

}

function submitlogin(id) {

var ajax = new sack();
 	ajax.setVar("id",id);
	ajax.setVar("loginform",'1');
 	ajax.setVar("go",'login');
    ajax.setVar("forward", document.login.forward.value);
    ajax.setVar("email", document.login.email.value);
    ajax.setVar("password", document.login.password.value);
    ajax.setVar("remember", document.login.remember.value);
	ajax.requestFile = "http://www.1800banners.com/blog//includes/program/UIclasses/ajaxlogin.php";
	ajax.method = 'POST';
	ajax.element = 'comments';
	ajax.onLoading = whenLoadingCOMMENTS;
//	ajax.onCompletion = whenCompleted;
	ajax.runAJAX();
}

function logout(id) {

    var ajax = new sack(); 
 	ajax.setVar("go",'logout');
 	ajax.setVar("forward",'comments');
    ajax.setVar("id",id);

	ajax.requestFile = "http://www.1800banners.com/blog//includes/program/UIclasses/ajaxlogin.php";
	ajax.method = 'POST';
	ajax.element = 'comments';
	ajax.onLoading = whenLoadingCOMMENTS;
	ajax.runAJAX();
}


function postrating(rating,id) {

var ajax = new sack();

 	ajax.setVar("id",id);
	ajax.setVar("rating", rating);

	ajax.requestFile = "http://www.1800banners.com/blog//ajaxoperations/rating.php";
	ajax.method = 'POST';
	ajax.element = 'star-rating';
	ajax.onLoading = whenLoadingRATE;
//	ajax.onCompletion = whenCompleted;
	ajax.runAJAX();
}

function sendtofriend(videourl,videoname) {

var ajax = new sack();

ajax.setVar("post", '1');
ajax.setVar("link", document.sendtofriendform.link.value);
ajax.setVar("title",document.sendtofriendform.title.value);
ajax.setVar("your_name", document.sendtofriendform.your_name.value);
ajax.setVar("friend_email", document.sendtofriendform.friend_email.value);
ajax.setVar("email", document.sendtofriendform.email.value);
ajax.setVar("comment", document.sendtofriendform.comment.value);   

if(document.sendtofriendform.newsletter.value != null) {
ajax.setVar("newsletter", document.sendtofriendform.newsletter.value);
}

	ajax.requestFile = "http://www.1800banners.com/blog//ajaxoperations/sendtofriend.php";
    ajax.method = 'POST';
	ajax.element = 'sendtofriend';
	ajax.onLoading = whenLoadingSTF;
//	ajax.onLoaded = whenLoadedSTF; 
//	ajax.onInteractive = whenInteractiveSTF;
//	ajax.onCompletion = whenCompleted;
	ajax.runAJAX();


}

function sendtofriendindex(i) {

var ajax = new sack();


ajax.setVar("post", '1');
ajax.setVar("i", i);

eval("ajax.setVar('link', document.sendtofriendform_"+ i +".link.value)");

eval("ajax.setVar('title', document.sendtofriendform_"+ i +".title.value)");
eval("ajax.setVar('your_name', document.sendtofriendform_"+ i +".your_name.value)");
eval("ajax.setVar('friend_email', document.sendtofriendform_"+ i +".friend_email.value)");
eval("ajax.setVar('email', document.sendtofriendform_"+ i +".email.value)");
eval("ajax.setVar('comment', document.sendtofriendform_"+ i +".comment.value)");

eval("var check=document.sendtofriendform_"+ i +".newsletter.value;");

if(check != null) {
eval("ajax.setVar('newsletter', document.sendtofriendform_"+ i +".newsletter.value)");
}


	ajax.requestFile = "http://www.1800banners.com/blog//ajaxoperations/sendtofriend.php";
    ajax.method = 'POST';
	ajax.element = 'sendtofriend_'+i;
//	ajax.onLoading = whenLoadingSTF;
//	ajax.onLoaded = whenLoadedSTF; 
//	ajax.onInteractive = whenInteractiveSTF;
//	ajax.onCompletion = whenCompleted;
	ajax.runAJAX();


}




function commentscomplete() {
  
document.getElementById('turing').src = "http://www.1800banners.com/blog//ajaxoperations/turing.php?"+Math.floor(Math.random()*99999999);


}

function comments(id) {
var id=id;
HideContent('comments');
HideContent('sendtofriend');
getcomments(id);
showlayer('comments',0,0);

}

function getcomments(id) {

var ajax = new sack();
    ajax.setVar("id", id);
	ajax.requestFile = "http://www.1800banners.com/blog//includes/program/area_pictures/comments.php";
    ajax.method = 'POST';
	ajax.element = 'comments';
	ajax.onLoading = whenLoadingCOMMENTS;
	ajax.onCompletion = commentscomplete;
	ajax.runAJAX();

  


}

function postcomments(id) {

var ajax = new sack();

ajax.setVar("post", '1');
ajax.setVar("turing", document.commentsform.turing.value);
ajax.setVar("your_name", document.commentsform.your_name.value);
ajax.setVar("comment", document.commentsform.comment.value);
ajax.setVar("id", id);

	ajax.requestFile = "http://www.1800banners.com/blog//includes/program/area_pictures/comments.php";
    ajax.method = 'POST';
	ajax.element = 'comments';
	ajax.onLoading = whenLoadingCOMMENTS;

	ajax.onCompletion = commentscomplete;
	ajax.runAJAX();




}


function showsendtofriend(videourl,videoname) {

var ajax = new sack();
ajax.setVar("link", videourl);
ajax.setVar("title", videoname);

showlayer('sendtofriend',0,0);

	ajax.requestFile = "http://www.1800banners.com/blog//ajaxoperations/sendtofriend.php";

	ajax.element = 'sendtofriend';

	ajax.onLoading = whenLoadingSTF;
	ajax.onLoaded = whenLoadedSTF; 
	ajax.onInteractive = whenInteractiveSTF;
//	ajax.onCompletion = whenCompleted;
	ajax.runAJAX();

}


function showsendtofriendindex(videourl,videoname,i) {

var ajax = new sack();
ajax.setVar("link", videourl);
ajax.setVar("title", videoname);
ajax.setVar("i", i);


showlayer('sendtofriend_'+i,0,0);

	ajax.requestFile = "http://www.1800banners.com/blog//ajaxoperations/sendtofriend.php";

	ajax.element = 'sendtofriend_'+i;


//	ajax.onLoading = whenLoadingSTF;
//	ajax.onLoaded = whenLoadedSTF; 
//	ajax.onInteractive = whenInteractiveSTF;
//	ajax.onCompletion = whenCompleted;
	ajax.runAJAX();

}



function getfavorites(id) {

    var ajax = new sack(); 
    ajax.setVar("id", id);
	ajax.requestFile = "http://www.1800banners.com/blog//includes/program/UIclasses/favorites.php";
	ajax.method = 'POST';
	ajax.element = 'comments';
	ajax.onLoading = whenLoadingFAVS;
	ajax.runAJAX();
}



function showfavorites(id) {
HideContent('comments');
HideContent('sendtofriend');
getfavorites(id);
showlayer('comments',0,0);


}


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;
}