	var width_screen = screen.availWidth;
	var height_screen = screen.availHeight;
	function isEmail(email){
		var valid_email = true;
		var re =/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,5})$/gi;
			if (email.length == 0)	valid_email = false;
			else{		if(email.match(re)==null) valid_email = false;			}
		return valid_email;
	}
	
	
	function brokenLinks(movieid, epi){		
		var getURL = weburl + 'index.php/post/support/brokenlink/'+movieid+'/'+epi;
		var hrefclose = "<a href='#' onclick='parent.$.akModalRemove();$(\"#movieid_"+movieid+"\").show();'><img src='"+tplurl+"/images/close.png' border=0></a>";
		$('#movieid_'+movieid).hide();				
		$.showAkModal(getURL,230,70, hrefclose);
		return false;
		
	}
	
	
	function ViewReferer(movieid, epi){		
		var getURL = weburl + 'index.php/post/viewreferer/'+movieid+'/'+epi;		
		$.showAkModal(getURL,width_screen-300,height_screen-300, '');
		return false;		
	}
	
	function FullView(movieid, epi){	
	
		var getURL = weburl + 'index.php/post/fullview/'+movieid+'/'+epi;
		var hrefclose = "<a href='#' onclick='parent.$.akModalRemove();$(\"#movieid_"+movieid+"\").show();'><img src='"+tplurl+"/images/close.png' border=0></a>";
		$('#movieid_'+movieid).hide();				
		$.showAkModal(getURL,width_screen-180,height_screen-210, hrefclose);
		return false;		
	}

	function setFavorites(movieid){
		var ok;
		if(memid == 0) alert("You have to login to use this function");
		else{
				var getUrl = weburl+"index.php/post/member/addfav/"+movieid;
				
				$.ajax({
					  type: "GET",
					  url: getUrl, 
					  dataType: "xml",
					  complete: function(data) {					
					   var json = $.xmlToJSON(data.responseXML); 
					   ok = json.ok[0].Text; 
					   if(ok == "TRUE") alert("this Movie has been ADDED SUSCESSFUL");
					   else alert("this Movie is EXISTED in your favourite movies");
					}
					});
				
			
		}
		
		
	}
	function fav_remove(title, id){
		var ask = confirm("Are you sure want to delete Movie : " + title);
		if(ask)	window.location.href = weburl+"index.php/post/member/delfav/"+id;
	}
	
	function rateVote(mark, movieid){
		if(!rated && movieid>0 && (mark > 0 && mark <6)){
				var getUrl = weburl+"index.php/post/support/vote/"+movieid+"/"+mark;				
				$.ajax({
					  type: "GET",
					  url: getUrl, 
					  dataType: "xml",
					  complete: function(data) {					
					   var result = data.responseText; 
					   $('#ratelinks_result').html(result);
					   rated = true;
					  	
						}
					});
		}else alert("Rated. Dont Click More");
	}

	
	function SendGift(){
		alert("Undercontruction");
	}
	function imgNo(img){
		//if (!IsImageOk(img)) {
		//	img.src = tplurl+"images/noimage.jpg";			
		//}
		
	}
	
	function IsImageOk(img) {
				if (!img.complete) {	return false;		}			
				if (typeof img.naturalWidth	!= "undefined"&& img.naturalWidth	== 0) {		return false;			}		
				return true;
	}
	
			
		
	function openPopUp(url, windowName, w, h, scrollbar) {
	   var winl = (screen.width - w) / 2;
	   var wint = (screen.height - h) / 2;
	   winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',status=no,menubar=no,toolbar=no,scrollbars='+ scrollbar +',resizable=no' ;
	   win = window.open(url, windowName, winprops);
	   if (parseInt(navigator.appVersion) >= 4) { 
			win.window.focus(); 
	   } 
	}

	function ChangeLink(list) {
	var newPage = list.options[list.selectedIndex].value
	if (newPage != "noURL") location.href=newPage    
	}
	
	function EpiBroken(movie,epi){
		openPopUp('./?check=errors&id='+movie+'&epi='+epi,'SEND',200,160,'yes') ;
	}

   function SearchClick()
    {
		var txtSearch = Convert($('#txtSearch').val());		
		var ar_txtSearch = txtSearch.split(" ");
		txtSearch = ar_txtSearch[0]
		for(i=1;i<=ar_txtSearch.length-1;i++){
			txtSearch += "+" + ar_txtSearch[i]  ;			
		}
				
		if(txtSearch.length > 2)	window.location.href = weburl+"index.php/home/movie/search/"+txtSearch.toLowerCase();
		else {
			alert("Keyword must be greater than 2 words");
			return false;
		}
	}
	
	function member_add(){
				
			//Check Username
			var username = $('#username').val();
			if(username.length < 3) { alert("Username must be greater than 3 words"); return false;}
			
			//Check Pass
			
			var password = $('#reg_password').val();
			if(password.length < 3) {  alert("Password must be greater than 3 words"); return false;}
			
			//Check Confirm Pass
			var re_password = $('#re_password').val();
			if(re_password.length < 3) { alert("Confirm Password must be greater than 3 words"); return false;}
			else { 
								if(re_password != password){   alert("Confirm Password must be the same Password"); return false; } 
				
				}
			
			//Check Email
			var email = $('#email').val();
			if(!isEmail(email)) { alert("Email Invaild");return false; }
			
			//Check Full Name			
			var fullname = $('#fullname').val();
			if(fullname.length < 3) {  alert("FullName must be greater than 3 words"); return false;}
			
			//Check Secure Code
			
			var security_code = $('#security_code').val();
			if(security_code.length != 5) { alert("Security Code must be has 5 words");return false; }
			
			return true;
			
	}
	
	function member_valid(sw, value){
			
			
			getUrl = weburl + "index.php/post/check/"+ sw + "/"+ value;
			$.ajax({
						  type: "GET",
						  url: getUrl, 
						  dataType: "text",
						  complete: function(data) {					
						  result = data.responseText; 
						  $('#check_'+sw+'_result').html(result);
						  
						  }
					});	
		
		
	}
	
	
	function log_out(theURL){
			ht = document.getElementsByTagName("body");
			ht[0].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
			if (confirm('Do you want logout ? '))
			{
				
				ht[0].style.filter = "";
				window.location.href=theURL;
				return true;
			}
			else
			{
				ht[0].style.filter = "";
				return false;
			}
	}
	

	 function Convert(str){
			str= str.replace(/\u00E1/g,'a');
			str= str.replace(/\u00C1/g,'a');
			str= str.replace(/\u00E0/g,'a');
			str= str.replace(/\u00C0/g,'a');
			str= str.replace(/\u1EA3/g,'a');
			str= str.replace(/\u1EA2/g,'a');
			str= str.replace(/\u00E3/g,'a');
			str= str.replace(/\u00C3/g,'a');
			str= str.replace(/\u1EA1/g,'a');
			str= str.replace(/\u1EA0/g,'a');
			str= str.replace(/\u0103/g,'a');
			str= str.replace(/\u0102/g,'a');
			str= str.replace(/\u1EAF/g,'a');
			str= str.replace(/\u1EAE/g,'a');
			str= str.replace(/\u1EB1/g,'a');
			str= str.replace(/\u1EB0/g,'a');
			str= str.replace(/\u1EB3/g,'a');
			str= str.replace(/\u1EB2/g,'a');
			str= str.replace(/\u1EB5/g,'a');
			str= str.replace(/\u1EB4/g,'a');
			str= str.replace(/\u1EB7/g,'a');
			str= str.replace(/\u1EB6/g,'a');
			str= str.replace(/\u00E2/g,'a');
			str= str.replace(/\u00C2/g,'a');
			str= str.replace(/\u1EA5/g,'a');
			str= str.replace(/\u1EA4/g,'a');
			str= str.replace(/\u1EA7/g,'a');
			str= str.replace(/\u1EA6/g,'a');
			str= str.replace(/\u1EA9/g,'a');
			tr= str.replace(/\u1EA8/g,'a');
			str= str.replace(/\u1EAB/g,'a');
			str= str.replace(/\u1EAA/g,'a');
			str= str.replace(/\u1EAD/g,'a');
			str= str.replace(/\u1EAC/g,'a');
			str= str.replace(/\u00E9/g,'e');
			str= str.replace(/\u00C9/g,'e');
			str= str.replace(/\u00E8/g,'e');
			str= str.replace(/\u00C8/g,'e');
			str= str.replace(/\u1EBB/g,'e');
			str= str.replace(/\u1EBA/g,'e');
			str= str.replace(/\u1EBD/g,'e');
			str= str.replace(/\u1EBC/g,'e');
			str= str.replace(/\u1EB9/g,'e');
			str= str.replace(/\u1EB8/g,'e');
			str= str.replace(/\u00EA/g,'e');
			str= str.replace(/\u00CA/g,'e');
			str= str.replace(/\u1EBF/g,'e');
			str= str.replace(/\u1EBE/g,'e');
			str= str.replace(/\u1EC1/g,'e');
			str= str.replace(/\u1EC0/g,'e');
			str= str.replace(/\u1EC3/g,'e');
			str= str.replace(/\u1EC2/g,'e');
			str= str.replace(/\u1EC5/g,'e');
			str= str.replace(/\u1EC4/g,'e');
			str= str.replace(/\u1EC7/g,'e');
			str= str.replace(/\u1EC6/g,'e');
			str= str.replace(/\u00ED/g,'i');
			str= str.replace(/\u00CD/g,'i');
			str= str.replace(/\u00EC/g,'i');
			str= str.replace(/\u00CC/g,'i');
			str= str.replace(/\u1EC9/g,'i');
			str= str.replace(/\u1EC8/g,'i');
			str= str.replace(/\u0129/g,'i');
			str= str.replace(/\u0128/g,'i');
			str= str.replace(/\u1ECB/g,'i');
			str= str.replace(/\u1ECA/g,'i');
			str= str.replace(/\u00F3/g,'o');
			str= str.replace(/\u00D3/g,'o');
			str= str.replace(/\u00F2/g,'o');
			str= str.replace(/\u00D2/g,'o');
			str= str.replace(/\u1ECF/g,'o');
			str= str.replace(/\u1ECE/g,'o');
			str= str.replace(/\u00F5/g,'o');
			str= str.replace(/\u00D5/g,'o');
			str= str.replace(/\u1ECD/g,'o');
			str= str.replace(/\u1ECC/g,'o');
			str= str.replace(/\u01A1/g,'o');
			str= str.replace(/\u01A0/g,'o');
			str= str.replace(/\u1EDB/g,'o');
			str= str.replace(/\u1EDA/g,'o');
			str= str.replace(/\u1EDD/g,'o');
			str= str.replace(/\u1EDC/g,'o');
			str= str.replace(/\u1EDF/g,'o');
			str= str.replace(/\u1EDE/g,'o');
			str= str.replace(/\u1EE1/g,'o');
			str= str.replace(/\u1EE0/g,'o');
			str= str.replace(/\u1EE3/g,'o');
			str= str.replace(/\u1EE2/g,'o');
			str= str.replace(/\u00F4/g,'o');
			str= str.replace(/\u00D4/g,'o');
			str= str.replace(/\u1ED1/g,'o');
			str= str.replace(/\u1ED0/g,'o');
			str= str.replace(/\u1ED3/g,'o');
			str= str.replace(/\u1ED2/g,'o');
			str= str.replace(/\u1ED5/g,'o');
			str= str.replace(/\u1ED4/g,'o');
			str= str.replace(/\u1ED7/g,'o');
			str= str.replace(/\u1ED6/g,'o');
			str= str.replace(/\u1ED9/g,'o');
			str= str.replace(/\u1ED8/g,'o');
			str= str.replace(/\u00FA/g,'u');
			str= str.replace(/\u00DA/g,'u');
			str= str.replace(/\u00F9/g,'u');
			str= str.replace(/\u00D9/g,'u');
			str= str.replace(/\u1EE7/g,'u');
			str= str.replace(/\u1EE6/g,'u');
			str= str.replace(/\u0169/g,'u');
			str= str.replace(/\u0168/g,'u');
			str= str.replace(/\u1EE5/g,'u');
			str= str.replace(/\u1EE4/g,'u');
			str= str.replace(/\u01B0/g,'u');
			str= str.replace(/\u01AF/g,'u');
			str= str.replace(/\u1EE9/g,'u');
			str= str.replace(/\u1EE8/g,'u');
			str= str.replace(/\u1EEB/g,'u');
			str= str.replace(/\u1EEA/g,'u');
			str= str.replace(/\u1EED/g,'u');
			str= str.replace(/\u1EEC/g,'u');
			str= str.replace(/\u1EEF/g,'u');
			str= str.replace(/\u1EEE/g,'u');
			str= str.replace(/\u1EF1/g,'u');
			str= str.replace(/\u1EF0/g,'u');
			str= str.replace(/\u00FD/g,'y');
			str= str.replace(/\u00DD/g,'y');
			str= str.replace(/\u1EF3/g,'y');
			str= str.replace(/\u1EF2/g,'y');
			str= str.replace(/\u1EF7/g,'y');
			str= str.replace(/\u1EF6/g,'y');
			str= str.replace(/\u1EF9/g,'y');
			str= str.replace(/\u1EF8/g,'y');
			str= str.replace(/\u1EF5/g,'y');
			str= str.replace(/\u1EF4/g,'y');
			str= str.replace(/\u0110/g,'d');
			str= str.replace(/\u0111/g,'d');
			return str;
		}
		function SelectAll(id)
		{
			document.getElementById(id).focus();
			document.getElementById(id).select();
		}
