﻿function showImageWidth(ImgD,iwidth,iheight){if(ImgD.width>iwidth){ImgD.width=iwidth;}if(ImgD.height>iheight){ImgD.height=iheight;}}function ClearValue(obj){obj.html('&nbsp;');}function focuslogin(value,obj){if(value==obj.value){obj.value="";}}
function checklogin(){if($('#Aimoo_username')[0].value==""){return false;}if($('#Aimoo_username')[0].value=="username"){return false;}if($('#Aimoo_password')[0].value=="password"){return false;}if($('#Aimoo_password')[0].value==""){return false;}$('#Login_to_Aimoo').submit();}
function PostCommentsValue()
{
	var ispost = true;
	if($('#CommentsValue')[0].value=='')
	{
		$('#CommentsTip').html($('#CommentsTipStrings')[0].value);
		var ispost = false;
		return false;
	}
	if($('#verifycode')[0].value=='' || $('#verifycode')[0].value.length !=4)
	{
		$('#CommentsTip').html($('#CommentsVerifyStrings')[0].value);
		var ispost = false;
		return false;
	}
	$('#PostingArea').show();
	$('#PostArea').hide();
	
	var option = {
		url:"/Profile/SaveComments.cfm",
		ContentType:"text/xml;utf-8",
		success:function(html){
			if(html=="0"){$('#CommentsTip').html($('#CommentsVerifyStrings')[0].value);$('#PostingArea').hide();$('#PostArea').show();}
			else{window.location='http://profile.aimoo.com/'+$('#ProfileNickName')[0].value;}
		},
		error:function(html){$('#CommentsTip').html($('#CommentsPostErrorStrings')[0].value);$('#PostArea').show();$('#PostingArea').hide();}
	}
	
	
	$.ajax({
		url:'/Profile/ProfileAjax.cfm',
		type:'get',
		data:{
		CheckCode:1,
		UrlCode:$('#verifycode')[0].value
		},
		ContentType:"text/xml;utf-8",
		success:function(html){
			if(html=="0"){$('#CommentsTip').html($('#CommentsVerifyStrings')[0].value);$('#PostingArea').hide();$('#PostArea').show();return false;}
			else{$("#SaveComments").ajaxSubmit(option);}
		}
	});
	return false;
	
}

function delcomment(id,shownum,nickname)
{
	boxAlpha();
	$.ajax({
		url:'/Profile/ProfileAjax.cfm',
		type:'get',
		data:{
		Action:'DelComment',
		ShowNum:shownum,
		ID:id,
		UserName:nickname
		},
		ContentType:"text/xml;utf-8",
		success:function(html){
			boxAlpha();
			$('#CommentsAjax').empty();
			$('#CommentsAjax').html(html);
			$('#CommentPageDetail').html($('#AjaxPageDetail').html());
			$('#AjaxPageDetail').remove();
		},
		error:function(respon){boxAlpha();$('#CommentsAjax').html(respon.responseText);}
	});
}


function CommentsList(id,shownum,nickname,page)
{
	//boxAlpha();
	$.ajax({
		url:'/Profile/ProfileAjax.cfm',
		type:'get',
		data:{
		Action:'DelComment',
		ShowNum:shownum,
		ID:id,
		UserName:nickname,
		Cpage:page
		},
		ContentType:"text/xml;utf-8",
		success:function(html){
			//boxAlpha();
			$('#CommentsAjax').empty();
			$('#CommentsAjax').html(html);
			$('#CommentPageDetail').html($('#AjaxPageDetail').html());
			$('#AjaxPageDetail').remove();
		},
		error:function(respon){boxAlpha();$('#CommentsAjax').html(respon.responseText);}
	});
}


function FriendsList(id,shownum,nickname,page)
{
	$.ajax({
		url:'/Profile/ProfileAjax.cfm',
		type:'get',
		data:{
		Action:'FriendsList',
		ShowNum:shownum,
		ID:id,
		UserName:nickname,
		Cpage:page
		},
		ContentType:"text/xml;utf-8",
		success:function(html){
			$('#FriendsAjax').html(html);
			$('#FriendsPageDetail').html($('#AjaxFriendsPageDetail').html());
			$('#AjaxFriendsPageDetail').remove();
		}
		//error:function(respon){boxAlpha();$('#CommentsAjax').html(respon.responseText);}
	});
}

function boxAlpha() {
	var showBox=document.getElementById("showBox");
	var bgalpaha = document.getElementById("alphaBox");
	var content = document.getElementById("contentbox");
	if(showBox.style.display == "none") {
		showBox.style.display = "block";
		showBox.style.height = document.documentElement.scrollHeight;
		bgalpaha.style.height= document.documentElement.scrollHeight+"px";
		if (navigator.appName == "Microsoft Internet Explorer"){
				bgalpaha.style.width = document.documentElement.scrollWidth  + "px";}
		else 
			{
				bgalpaha.style.width = window.screen.availWidth;
			}
		}
	else{
		showBox.style.display = "none";
		}
}

function changecerfication()
 {
	 var param=new Date().getSeconds();
	 var verficationdiv= document.getElementById("chengeverfication");
	 verficationdiv.src="/community/community_create/randimg.cfm?rand="+param;
 }
 
function searchforums(serName){
	var truevalue = "";
	if ($.trim($('#keyword').val()) != "Search Forums") truevalue = $.trim($('#keyword').val());
	if (truevalue=="")
		window.location="http://" + serName + "/Community.html";
	else
		window.location="http://" + serName + "/SearchField-1/SearchValue-"+truevalue+"/Community.html";
}

function SearKeyPress(event, serName) {
	event = event || window.event;
	if(event.keyCode == 13) {
		searchforums(serName);
	}
}

//image start
function reapply(){
setTimeout("slideit()",2000)
return true
}
window.onerror=reapply
var speed=3
var step=1
var whichimage=1

function slideit(){
if (!document.images)
return
if (document.all)
slide.filters.blendTrans.apply()
document.images.slide.src=eval("image"+step+".src")
if (document.all)
slide.filters.blendTrans.play()
whichimage=step
if (step<number_of_images)
step++
else
step=1
if (document.all)
setTimeout("slideit()",speed*1000+3000)
else
setTimeout("slideit()",speed*1000)
}
//image end


function AddFriend(strAction,strNickName)
{
	$.ajax({
		url:'/friends_Manager/Ajax.cfm',
		type:'get',
		data:{
		Action:strAction,
		NickName:strNickName
		},
		success:function(html){
			if($.trim(html) == "1") {
				$('#Friends_'+strNickName).hide();
				alert("Your friend request has been sent successfully, please wait for approval!");
			}
		}
		//error:function(respon){boxAlpha();$('#CommentsAjax').html(respon.responseText);}
	});
}


String.prototype.len=function(){ 
return this.replace(/[^\x00-\xff]/g,"**").length; 
} 

//Set maxlength for multiline TextBox 
function setMaxLength(event,object,length) { 
	event = event || window.event;
	var result = true; 
	var stext = "";
	if (document.selection) stext = document.selection.createRange().text;
	else stext = object.value.substr(object.selectionStart, object.selectionEnd - object.selectionStart);

//var controlid = document.selection.createRange().parentElement().id; 
//var controlValue = document.selection.createRange().text; 
//if (controlid == object.id && controlValue != "") 
	if (stext != "") result = true; 
	else if (object.value.len() >= length) result = false; 
	if (event.keyCode == 8 || event.keyCode == 46) {
		$('#counterText').html(String(length - object.value.len() + stext.length));
		return true;
	}

	if (result)	$('#counterText').html(String(length - object.value.len() + stext.length - 1));
	return result; 
 
} 

//Check maxlength for multiline TextBox when paste 
function limitPaste(object,length) { 
	var tempLength = 0; 
	if(document.selection && document.selection.createRange().parentElement().id == object.id) { 
			tempLength = document.selection.createRange().text.len(); 
	} 
	var tempValue = window.clipboardData.getData("Text"); 
	tempLength = object.value.len() + tempValue.len() - tempLength; 
	if (tempLength > length) { 
		tempLength -= length; 
		var tt=""; 
		for(var i=0;i<tempValue.len()-tempLength;i++) { 
			if(tt.len()<(tempValue.len()-tempLength)) 
				tt=tempValue.substr(0,i+1); 
			else 
				break; 
		} 
		tempValue=tt; 
		window.clipboardData.setData("Text", tempValue); 
	} 

	return true; 
} 