
$(document).ready(function() {
    $(document).pngFix()
})
function GetHtml(url, div) {
    var heightdiv=$(div).height();
    $(div).html("<div style=' height: "+heightdiv+"px; width: 100%;'><center><img src='/Web/images/loadings/ajax-loader.gif' alt='loading...' /></center></div>")
    $.get(encodeURI(url),function(data){
        //get response text only
        $(div).html(data)
    })
}
function GetHtmlEmptyIcon(url, div) {
    $(div).html("<center></center>")
    $.get(encodeURI(url),function(data){
        //get response text only
        $(div).html(data)
    })
}
function GetHtmlEmptyIconEffect(url, div) {
    $(div).html("<center></center>")
    $.get(encodeURI(url), function(data) {
    //get response text only
    
    $(div).html(data)
    $(div).slideToggle(300)
    })
}

function sendcontact(fullnameid,emailid,telid,contentid)
{
    var fullname=$("#"+fullnameid).val()
    var email=$("#"+emailid).val()
    var tel=$("#"+telid).val()
    var content=$("#"+contentid).val()
    
    var url='/Web/AjaxWeb.aspx?ctrl=../Modules/Gallery/Web/Gallery_Contact&fullname='+encodeURIComponent(fullname)+'&email='+encodeURIComponent(email)+'&phone='+encodeURIComponent(tel)+'&content='+encodeURIComponent(content)
    GetHtml(url, "#uc_gallerycontact")
}
function loadaboutme(abmid)
{
    var url='/Web/AjaxWeb.aspx?ctrl=../Modules/Gallery/Web/Gallery_AboutMe_Detail&abmid='+abmid
    GetHtml(url, "#uc_galleryaboutmedetail")
}
// new gal
function loadgallerys(fid)
{
    
    var url='/Web/AjaxWeb.aspx?ctrl=/Modules/Gallery/Web/GalleryDetail_New&folderid='+fid
    GetHtml(url, "#uc_gallerydetail")
}

function loadimage(iid,curPage,maxPage,lstImg)
{
    var url='/Web/AjaxWeb.aspx?ctrl=/Modules/Gallery/Web/Image_Detail&imageid='+iid+"&curPage="+curPage+"&maxPage="+maxPage+"&lstImg="+lstImg
    $("#uc_imagedetail").hide()
    GetHtml(url, "#uc_imagedetail")
    $("#uc_imagedetail").slideToggle("slow")
    $("#container_gal img").each(function (){
        var id_selected=$(this).attr('val')
        var imgid=$(this).attr('id')
        
        if(id_selected!='undefined')
        {
            if(iid==id_selected)
            {
             $("#"+imgid).addClass('img_gal_selected');
            }
        }
        
    })
}
function sendcomment(divid,imageid,emailid,contentid)
{
    var email=$("#"+emailid).val()
    var content=$("#"+contentid).val()
    var url='/Web/AjaxWeb.aspx?ctrl=/Modules/Gallery/Web/SendComment&imageid='+imageid+'&email='+encodeURIComponent(email)+'&content='+encodeURIComponent(content)
    GetHtml(url, "#"+divid)
    if(imageid>0 && content!='Your Message:' && email!='Your Email:')
    {
        var urlCommentList='/Web/AjaxWeb.aspx?ctrl=/Modules/Gallery/Web/Comment_ListAll&imageid='+imageid
        setTimeout('GetHtml("' + urlCommentList + '","#uc_commentlistall")',1000)
        var urlCommentList='/Web/AjaxWeb.aspx?ctrl=/Modules/Gallery/Web/SendComment&imageid='+imageid
        setTimeout("GetHtml('" + urlCommentList + "','"+"#"+divid+"')",3000)    
    }
}
function addtags(imageid, addtagid) {
    var tags_content = $("#" + addtagid).val();
    var url = '/Web/AjaxWeb.aspx?ctrl=/Modules/Gallery/Web/Tag_Add&imageid=' + imageid + '&tags=' + encodeURIComponent(tags_content)
    GetHtml(url, "#uc_tagadd")
    var urTagList = '/Web/AjaxWeb.aspx?ctrl=/Modules/Gallery/Web/Tag_ListAll&imageid=' + imageid
    setTimeout('GetHtml("' + urTagList + '","#uc_taglistall")', 1500)
}
function loadimages(folderid,paddingleft,numbershow,divajaxid,secondloading)
{
    var url='/Web/AjaxWeb.aspx?ctrl=../Modules/Gallery/Web/GallerySlide_More&folderid='+folderid+'&paddingleft='+paddingleft+'&numbershow='+numbershow
    setTimeout("GetHtmlEmptyIcon('"+url+"','"+"#"+divajaxid+"')",secondloading)
}
//disable enterkey for submit
function disableEnterKey(e)
{
     var key;     
     if(window.event)
          key = window.event.keyCode; //IE
     else
          key = e.which; //firefox
     return (key != 13);
}
function updatecouter(iid)
{
    alert(iid)
}
function GetFoldersPaging(url)
{
    GetHtml(url, '#uc_moregallerylistajax')
}
function GetImagePaging(url)
{
    GetHtml(url, '#uc_gallerydetail')
}

function login_user(usernameid, passwordid) {
    var username = $("#" + usernameid).val();
    var password = $("#" + passwordid).val();
    var password_md5 = hex_md5(password)
    var url = '/Web/AjaxWeb.aspx?ctrl=/Modules/Gallery/Web/Login_Panel&act=login&username=' + encodeURIComponent(username) + '&password=' + encodeURIComponent(password_md5)
    GetHtmlEmptyIconEffect(url, "#box_contentmenu")
}
function register_user(usernameid, passwordid, emailid) {
    var username = $("#" + usernameid).val();
    var password = $("#" + passwordid).val();
    var password_md5 = hex_md5(password)
    
    var email = $("#" + emailid).val();

    var url = '/Web/AjaxWeb.aspx?ctrl=/Modules/Gallery/Web/Login_Panel&act=register&username=' + encodeURIComponent(username) + '&password=' + encodeURIComponent(password_md5) + '&email=' + encodeURIComponent(email)
    GetHtmlEmptyIconEffect(url, "#box_contentmenu")
}
function logout_user() {
    
    var url = '/Web/AjaxWeb.aspx?ctrl=/Modules/Gallery/Web/Login_Panel&act=logout'
    GetHtmlEmptyIconEffect(url, "#box_contentmenu")
}

