﻿function switchlabels() {
    if($('[name=username]').val()=='username') {
        $('[name=username]').val('');
    }
    
    if($('[name=password]').val()=='password') {
        $('[name=password]').val('');
    }
}

function switchbacklabels() {
    if($('[name=username]').val()=='') {
        $('[name=username]').val('username');
    }
    
    if($('[name=password]').val()=='') {
        $('[name=password]').val('password');
    }  
}

function closedialog() {
    $.modal.close();
}

function showmessage(title, msg) {
    $.modal("<div>" + 
                "<h1>" + title + "</h1>" + 
                "<div style='font-size:14px; margin-top:5px;'>" +
                msg + 
                "</div>" +
                "<div style='float:right; font-size:12px; padding:2px; margin-top: 10px;'>" +
                    "<a href='javascript:closedialog();'>close</a>" +
                "</div>" +
            "</div>", 
            {
                overlay:70,
            	overlayCss: {backgroundColor:"#eee"}
            });
}

function showmodalurl(url, width, height) {
    $.modal('<iframe src="' + url + '" height="' + height + '" width="' + width + '" style="border:0">', {
	    containerCss:{
		    backgroundColor:"#fff",
		    height:height,
		    padding:0,
		    width:width
	    },
	    overlayClose:true
    });

}

function showerror(div, msg) {
    $("#" + div).html("<span class='errorfield'>" + msg + "</span>");
}

function expandtextarea(x, areavalue, rowheight, minheight) 
{
    var scrollbarheight = 22;
    var tmpreg = areavalue.match(/[^\n]*\n[^\n]*/gi);
    var rows = (tmpreg?tmpreg.length+1:1);
    height = rows*rowheight+scrollbarheight;
    x.style.height = (height<minheight? minheight:height) + 'px';
}

function preloadimage(imgurl) {
    var pic = new Image(32,32);
    pic.src = imgurl;
}

function moveTo(name) {
    $.scrollTo('#' + name, {duration: 1200});
}

function redirectTo(name) {
    location.href='/my/profile/edit.aspx#' + name;
}



//function addqtip(id, tip)
//{           
//   $(id).qtip(
//   {
//      content: tip,
//      position: {
//        corner: {
//            tooltip: 'bottomLeft',
//            target: 'topRight'
//            }
//        },
//        style: {
//            border: { width: 3, radius: 5},
//            textAlign: 'left',
//            tip: true,
//            name: 'cream'
//        }
//   });
//   
//}