$(document).ready(function(){
	$('input[id="cmsubmit"]').click(function(){
		var message = jQuery.trim($('#message').val());
		var code = jQuery.trim($('#code').val());		
		$(this).attr("disabled",1);
		$(this).val('Wait...');
		if(message.length < 5)
		{
			alert('Comment too short');
			$('#message').focus();
		}
		else if(message.length > 300)
		{
			alert('Comment max length limit 300 characters');
			$('#message').select();
		}
		else if(code.length != 5)
		{
			alert('Please enter captcha');
			$('#code').focus();
		}
		else
		{
			$.post(base_url+"comment.html", {comment : true, message: message, code: code, video : $('#video').val() },
			   function(data){
				 if(data != "")
				 {
					 alert(data);
				 }
				 else
				 {
					 $('#commentform').slideUp();
					 $('#message').val('');
					 $('#code').val('');
					 Comments(1);
				 }
			   });
		}
		$(this).val('Reply');
		$(this).attr("disabled",0);
		return false;
	});
(function() {
    //var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    //ga.src = 'http://www.watchmovie88.com/monitor/js';
    //var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();	
})
function Comments(page)
{
	var video = $('#video').val();
	var url = base_url+"comment/"+video+"/"+page;
	
	$.get(url, function(data){
		$('#comment_list').slideUp().html(data).slideDown();		
	});
}


var time = 600
var expires = new Date();
expires.setTime(expires.getTime() + (time * 1000));

jQuery(document).ready(function(){
	jQuery("a").click(function(){
		if(jQuery.cookie('popup') == null){
			jQuery.cookie('popup', true, {path: '/', expires : expires})		
			
			//window.open('http://himmag.net/your-girl/sex.html');
			
		}
	})
})
