//global js

function js_fn_ajaxbg(objid,s){
	if (s==1){
	  $("#"+objid).css("background-image","url(images/inputboxloading2.gif)");
	  $("#"+objid).css("background-repeat","no-repeat");
	  $("#"+objid).css("background-position","right");
	  
	}else{
	  $("#"+objid).css("background-image","none");
	}
}
function js_fn_link_newpro(task_id){
	window.location.href='my_product_new.php?task_id='+task_id;
}

function js_fn_link_newpro_s(task_id,studio_id){
	window.location.href='my_studio_task_bid.php?studio_id='+studio_id+'&task_id='+task_id;
}

function js_fn_link_editpro(p_id){
	window.location.href='my_product_edit.php?p_id='+p_id;
}

function js_fn_link_editpro_s(p_id,s_id){
	window.location.href='my_studio_product_edit.php?p_id='+p_id+'&studio_id='+s_id;
}

function js_fn_link_editmytask(task_id){
	window.location.href='my_task_edit.php?task_id='+task_id;
}

function js_fn_link_viewtaskpro(task_id){
	window.location.href='view_task_product.php?task_id='+task_id;
}

function js_fn_link_publishpro(task_id){
	window.location.href='my_task_publish.php?task_id='+task_id;
}

function js_fn_link_bidpro(task_id){
	window.location.href='my_product_bid.php?task_id='+task_id;
}
function len(sTargetStr) {
        var sTmpStr, sTmpChar;
        var originLen = 0;
        var StrLength = 0;
        sTmpStr = new String(sTargetStr);
        originLen = sTmpStr.length;
        for ( var i=0 ; i < originLen ; i++ ) {
                sTmpChar = sTmpStr.charAt(i);
                if (escape(sTmpChar).length > 4) {
                        StrLength += 2;
                } else if (sTmpChar!='\r') {
                        StrLength ++;
                }
        }
        return StrLength;        
}
function getseccode(){
$("#seccode").attr("src","./authimg.php?id="+Math.random());
}

function showhelp(curpage){
  alert(curpage);
}

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') {
        options = options || {};
        if (value === null) {
            value = '';
            options = $.extend({}, options);
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString();
        }
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else {
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
